-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32-S3 simulated deep sleep does not activate when USB re-connected after running on battery #9898
Comments
TL;DR: I suspect there are two related problems: 1) a series of deep sleeps may not allow enough non-sleeping time for USB to enumerate, and 2) CircuitPython's mechanism for simulated deep sleeping does not seem to reliably re-activate when the board has been real deep sleeping on battery power and then gets re-connected to a USB port. Long version... Using the code below for code.py lets me jumper A3 to GND with a wire to get a loop of ESP32 light sleep. With the jumper disconnected, it does a series of deep sleeps like the original reproducing code posted above.
from alarm import light_sleep_until_alarms, exit_and_deep_sleep_until_alarms
from alarm.time import TimeAlarm
import board
from digitalio import DigitalInOut, Direction, Pull
import time
def main():
# This will run each time the board wakes from deep sleep.
print("start of main()")
# If A3 is jumpered to GND, light sleep until jumper is removed
a3_jumper = DigitalInOut(board.A3)
a3_jumper.direction = Direction.INPUT
a3_jumper.pull = Pull.UP
first = True
if not a3_jumper.value:
while not a3_jumper.value:
ta = TimeAlarm(monotonic_time=time.monotonic() + 1)
light_sleep_until_alarms(ta)
if first:
first = False
print("waiting while A3 is grounded...")
print("done")
# When jumper is not grounded, do the deep sleep thing
# uncommenting the time.sleep() line below on macOS causes
# a repeating loop of CIRCUITPY appearing, then disappearing,
# with the OS complaining about "Disk not ejected properly"
# time.sleep(5)
seconds = 8
ta = TimeAlarm(monotonic_time=time.monotonic() + seconds)
exit_and_deep_sleep_until_alarms(ta)
main() |
I had a discord discussion with a user who was having similar issues. I think we may have recently changed the way we check for the presence of a USB connection, which is making deciding whether to do real or fake sleep more difficult. It would be worth doing some tests with older versions, and doing a bisect as needed. |
CircuitPython version
Code/REPL
Behavior
Steps to reproduce the problem:
After re-connecting the USB cable, the CIRCUITPY never shows up, and the USB serial device never shows up.
Description
If I reset the board, everything goes back to normal with CIRCUITPY and USB serial. But, I really don't want to reset the board because I'm trying to make a low cost data logger that uses
alarm.sleep_memory
instead of an SD card. A reset will clear the sleep memory, erasing the measurements.Assuming I can get it working, my intended use case is:
Additional information
No response
The text was updated successfully, but these errors were encountered: