Sleep Mode Description
-
How does sleep work, help doc doesn't explain it? When the device goes to sleep, what memory is retained? Does it continue from where it left off or restarts boot & main. Did I miss the doco for this?
-
@misterlisty If you mean deep sleep, in all cases, all CPU memory and CPU state is lost, and on wake-up it's like the module was just powered on.
This is in the docs, though it's perhaps not that clear.
For
machine.deepsleep:https://docs.pycom.io/firmwareapi/pycom/machine/#machinedeepsleeptimems
Stops the CPU and all peripherals, including the networking interfaces (except for LTE). Execution is resumed from the main script, just as with a reset.
Note that at the ESP32 level the RTC domain including its memory is kept active, but there's no support for that at the micropython level.
In the case of Pysense/Pytrack/Deep Sleep Shield-controlled deep sleep, it's even worse, as power to the ESP32 is cut.
-
The wording on that isnt brilliant. but yes. it restarts from the top of main.py again. ill update the docs to be clearer
-
@paul-thornton To be precise, it actually starts from the top of boot.py :-)
While you're in the docs, I don't think the read_battery_voltage method for the Pysense/Pytrack/etc. is in the docs, you may want to add that as well.
-
From what i read above, it would also restart boot.py?
-
@misterlisty Yes, it acts exactly as on a power on, it executes
boot.pythenmain.py.The only way to know whether it's a power on or a wake from sleep (and what the reason for the wake up was) is to call
machine.wake_reason.The possible reasons are listed in the constants at the bottom of the page:
machine.PWRON_WAKE,machine.PIN_WAKE,machine.RTC_WAKE,machine.ULP_WAKE. -
@jcaron said in Sleep Mode Description:
@paul-thornton To be precise, it actually starts from the top of boot.py :-)
While you're in the docs, I don't think the read_battery_voltage method for the Pysense/Pytrack/etc. is in the docs, you may want to add that as well.Thanks ill get this added today if its missing.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login