is it a good idea to repeatedly go deepsleep then wake up ?
-
My project is simple enough, read something, then stop, then read again after a while.
I tried put machine.deepsleep(180000) after i read something in a loop. It worked but after a few hours, the Lopy 4 board seem to stay in deep sleep and never awake again. If i hit power reset on the board, it return to normal.
So my question is, is it a good practice to do that ? Is is there a way to prevent this problem (doesnt wake up on its own) from happening ?
-
Thanks for replying.
I just do some testing and it is true that in some random time, the device didnt go to deepsleep but rather skip that step entirely.
What i did to test this is running script where it report will to server within 1 second non stop unless it go to machine.deepsleep step. Base on report, it skip deepsleep stage twice in the last few hours.
Do you know or anyone know where i can find more about this problem ? I have been looking in the forum but not much
-
@soibac35 You don't even need a loop. When the LoPy returns from deep sleep, it acts like a reboot, starting from the top of your script. But that's indeed the whole goal of deep sleep: constantly sleeping, waking up to do a bit of work, and going back to sleep, again and again.
There have been reports of devices getting "stuck". It seems that in most cases it's not so much they don't get out of sleep but more often don't actually enter sleep, though the causes for this are unclear (I think I2C issues have been pointed to as a possible culprit).
If you can monitor power usage over time, that's usually the best way to check the actual state of the LoPy. You can also set the LED to various colours while you are awake to see where it stops.
One option if it does not indeed go to sleep is to use the watchdog timer (WDT) to ensure that if the LoPy does not actually enter sleep, it reboots so it can do its work again and re-attempt sleep.