Lightsleep works, but crashes randomly when wifi is connected. #16539
-
I'm experiencing a weird problem where lightsleep on a ESP32 works, but it crashes/reboots randomly. I've distilled down to example code below. I'm making an alarmclock (with alarms by weekday) and I'd love a working lightsleep for battery operation.
and it crashes/reboots and produces this output usually within 20 to 100 loops, this run went till nearly 1000. The sleep(0.2) duration just seems to change how long i have to wait, not the probability of a crash. The dump on failure is reproducible:
I'm using a "WEMOS Lite V1.0.0". It reports this info with esptool:
I was getting crashes with both these firmware: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
PS: My boot.py looks like this, and connects to wifi and starts a webrepl.
I've just realised my boot.py does 'from utime import sleep' for me! I've disabled it with a exit() at the start and added that import line above. It seems like having a wifi connection is making lightsleep crash.... I haven't reproduced it yet while wifi is off. Up to 3000 loops so far.... There's another thread here suggesting a lightsleep wifi problem: [(https://github.com/orgs/micropython/discussions/10899)] |
Beta Was this translation helpful? Give feedback.
-
One more update: I think the crashes happen (only occasionally) as it exits lightsleep if there's a wifi connection. So when I was doing 60 second lightsleeps the crashes were infrequent enough (like once an hour) that I wasn't sure what was happening.
Maybe the obvious answer is get rid of the webrepl and boot.py and only use wifi when I need an NTP update. |
Beta Was this translation helpful? Give feedback.
-
PPS: I have now found references to the hardware docs that say you should turn off the wifi before going into lightsleep. |
Beta Was this translation helpful? Give feedback.
PPS: I have now found references to the hardware docs that say you should turn off the wifi before going into lightsleep.
Not a bug, just a limitation. Good to know!