time limit for ESP32 sleep command

If doesn't fit into any other category ....
Zim
Posts: 291
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 267 times
Been thanked: 131 times

time limit for ESP32 sleep command

Post by Zim »

Is there a maximum time you can specify for sleep? Is 24 hours possible?

Thanks
Zim
User avatar
PeterN
Posts: 399
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 189 times
Been thanked: 222 times
Contact:

Re: time limit for ESP32 sleep command

Post by PeterN »

Hi Zim
not shure about the exact number of millis (32bit??) in the hardware counter, but remember that it results in a 71 minutes maximum.
So you may have to wake up x times, read and write a countdown counter into a file and return x-1 times to sleep
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 126 times
Been thanked: 132 times

Re: time limit for ESP32 sleep command

Post by AndyGadget »

Ah yes, that's something I forgot to mention. I'm pretty sure from way back that max asleep is much less than a day. My program would still work as long as you limit the maximum sleep time; it would just wake a few more times.
User avatar
PeterN
Posts: 399
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 189 times
Been thanked: 222 times
Contact:

Re: time limit for ESP32 sleep command

Post by PeterN »

Now I remeber where I saw that 71 minutes maximum:
[Local Link Removed for Guests]
Zim
Posts: 291
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 267 times
Been thanked: 131 times

Re: time limit for ESP32 sleep command

Post by Zim »

Thanks Gents. I found a hardware solution that is adjustable from seconds up to 20 days. I will post my findings if it works.

Thanks
Zim
User avatar
cicciocb
Site Admin
Posts: 2097
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 450 times
Been thanked: 1386 times
Contact:

Re: time limit for ESP32 sleep command

Post by cicciocb »

I did a check in the code and It seems that it is actually limited to 32bits (copy paste from the esp8266);
This means that the max time is around 71 minutes (4294 seconds).

However the ESP32 is not limited at 32 bits so it could be possible to remove this limit in a future release
Zim
Posts: 291
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 267 times
Been thanked: 131 times

Re: time limit for ESP32 sleep command

Post by Zim »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sat Feb 18, 2023 10:51 am However the ESP32 is not limited at 32 bits so it could be possible to remove this limit in a future release
Wow, that would sure simplify my problem! Would it be possible to slip us a Bin file with this mod? Life would be so much simpler! :)

Thanks
Zim
BeanieBots
Posts: 351
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 187 times
Been thanked: 113 times

Re: time limit for ESP32 sleep command

Post by BeanieBots »

When waking from sleep, the RTC RAM is not cleared. Therfore, you could simply increment a counter each sleep period in the non-volatile RAM.
No need to wear out the flash. A wake/read/increment/sleep routine would only keep it awake for a few mS, so no major impact on battery life.
The only downside with sleep periods is that they are +/- 1 brick and temperature sensitive.
Worst I've seen is a 3 minute sleep take 3:12
User avatar
cicciocb
Site Admin
Posts: 2097
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 450 times
Been thanked: 1386 times
Contact:

Re: time limit for ESP32 sleep command

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sat Feb 18, 2023 6:02 pm
[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sat Feb 18, 2023 10:51 am However the ESP32 is not limited at 32 bits so it could be possible to remove this limit in a future release
Wow, that would sure simplify my problem! Would it be possible to slip us a Bin file with this mod? Life would be so much simpler! :)

Thanks
Zim
Hi,
please find here a version that should fix the sleep command.
Now you should be able to go beyond 71 minutes.
I did not tested ...

This version includes also other stuff not yet documented
Annex32.bin
You do not have the required permissions to view the files attached to this post.
Zim
Posts: 291
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 267 times
Been thanked: 131 times

Re: time limit for ESP32 sleep command

Post by Zim »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sat Feb 18, 2023 7:53 pm please find here a version that should fix the sleep command.
Now you should be able to go beyond 71 minutes.
I did not tested ...

This version includes also other stuff not yet documented
Annex32.bin
Thank you! I will test soon.
Zim
Post Reply