Machine.deepsleep

Hi all.

Am I right in thinking deepsleep does not work in m’python release > 1.23?

Trying to improve the battery life of a Pico WH project and in testing found that running deepsleep on a Pico WH running 1.23 dropped the load from ~70mA to ~30mA but running 1.26.1 there was no change at all.

Cheers,

Mark

It seems that deepsleep causes the Pico to reboot on waking and the lightsleep does next to nothing for power saving anyway.

Hi Mark
Just guessing here as I don’t know a lot about RPi.

If you don’t want it to boot it will have to stay alive.
If it is doing not much anyway while waiting for something to happen it is not going to save any power by sleeping I don’t think. You will always be using idle power at a minimum.

So if booting is a problem then maybe a rethink on power requirements is the go.
Cheers Bob

2 Likes

There seems to be lots of online discussions re the sleep modes and if they work (or work as expected).

i.e. there will be the micro python version, then the pico version.

One thing to keep in mind when thinking about sleep modes is what you are asking the controller to do.
e.g. if you have usb or wifi etc running, then that needs to keep doing things for the connections/sessions to remain valid. As such if you “sleep” then one of three things needs to happen (which one can depend on sleep mode and/or the device you are using)
a) it wont put those things into sleep mode, thus reducing the power savings
b) It will put those things into sleep mode, but come out of sleep mode faster then expected to process data for those things.
c) Put it into sleep mode and whey you wake up, somethings may be in an unstable state.

As such, if you are going for absolute “deep” sleep mode (I have seen this called different things) then when you wake up, its often better to restart everything. Hence a reboot on deep sleep wake-up. I believe that Pico/micro python has a flag that you can check to see if the last boot was due to a sleep or some other cause.

Some documents I read indicate that sleep mode with a timeout, the timeout is the MAX it will sleep, but something else may trigger it to wakeup earlier.
I would assume, for the best sleep modes you really need to be controlling what the chip is doing and turning things on/off as needed.
e.g. If going to sleep, turn of wifi. Then on walkup, if needed, turn wifi back on.
In theory, this should mean that the wifi wont be trying to wakeup the chip and since you “re-connect” the wifi on wakeup, it will be in a known state.

I believe one of the things beginners tend to do is say…
“If I turn on sleep mode I will save power”, then expect no down side to sleep modes. If there was no downside to sleep modes, then the vendors would just auto do it to save power.
In realty, you should be trying to manage your power needs and the way you application works.
e.g. If my device needs to wakeup every 30mins, take a wind speed measurement, send that to my server, then go back to sleep… then this could be written “On Boot” Connect to wifi, get data, upload data, shutdown wifi sleep 30mins.
then a reboot of the device makes no difference.

If on the other hand you need to do something every 10ms, then sleep mode may not give you any real savings as the overhead of booting could be more then your task frequency.

2 Likes

I’ve not had a chance to test the difference in sleep modes between the micropython versions yet, but it does seem that deep sleep uses a surprisingly high amount of current draw on the Pico.

There have been some attempts to alleviate that including the tutorial below which might be worth checking out. They eventually gewt a draw of just 1.4mA on their customer firmware:

1 Like

Thanks so much for the feedback folks.

Michael, its a 15m sleep cycle I’m using so the reboot is no issue.

Jane, that’s an interesting read for sure.

I think I’ll take the cheats way out and use a timer hat to implement the reboot. More robust I think and it’ll simplify my code somewhat.

Cheers,

Mark

Hi Mark

15min??? how much power are you going to save. Surely the boot process would use a fair bit more than idle power so at the end of the day you just might be behind.
Cheers Bob

Base load is ~60mA when sleeping or measuring.

The pico reports to HA via wi-fi and MQTT every 15 minutes. 2000mAh battery with not a lot of pv exposure so at best I get 3 days.

I expect the timer hat to stretch this to weeks, maybe months.

Hi Mark
I shall watch with great interest.
Cheers Bob