Restore RTC value after Pysense go_to_sleep
-
In boot.py I am using rtc.ntp_sync to set up automatic fetch. If I put Pysense to sleep, I lose the automatic datetime info after it wakes up.
Is there any way to restore RTC value without having to start the whole process of connecting to WiFi and syncing again?
I am using Lopy4 + Pysense
-
@gabrielapb You could try the following:
- save the current timestamp to NVS before going to sleep
- on wake-up:
- retrieve the saved timestamp from NVS
- retrieve the "remaining sleep" from the Pysense using
pysense.get_sleep_remaining - current timestamp is approximately saved + sleep interval - remaining
Note this won't get you a very precise time (as it doesn't take into account boot time, and I'm not sure of the accuracy of the Pysense clock), and the offset to the real time will increase with the number of sleep periods, but it's helpful to have at least of rough idea of the time until you can get the actual time through other means.
The alternative is to use the module's deep sleep rather than the Pysense's deep sleep, but that may not be possible depending on your actual use case.
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