Maximum ESP32-S2 Deep Sleep Duration
Maximum ESP32-S2 Deep Sleep Duration
Using 'esp_sleep_enable_timer_wakeup()' with an 'unsigned long long' constant, what is the highest value that can be passed and still have wakeup work properly? In other words, what's the longest possible duration of deep sleep? I've looked everywhere I can think to for this and can't find it, but I assume it's some number of bits on a 32.768kHz timebase (32/48/64?), which would correspond to the standard RTC rate. 'esp_sleep_enable_timer_wakeup()' is supposed to return 'ESP_ERR_INVALID_ARG' in some cases, but it appears from the source code that this hasn't been implemented yet. Thanks!
Re: Maximum ESP32-S2 Deep Sleep Duration
Well, I've confirmed that it sleeps fine and wakes after 48 hours, within about two seconds in fact. It'd be nice to know if a month was possible without testing as that's my eventual goal. The maximum time by the uint64_t argument itself seems to be 584558 years, but probably there's a smaller limit internally. Does anyone have a better answer to this?
Re: Maximum ESP32-S2 Deep Sleep Duration
Thank you WiFive! Just what I was looking for. I grepped for this function previously but missed its definition in "rtc_time.c" and incorrectly assumed it was internally provided. In case the link breaks, here is what it says:
Hopefully this helps other people as well as I've seen it asked/discussed here and there. Thanks again!
Code: Select all
uint64_t rtc_time_us_to_slowclk(uint64_t time_in_us, uint32_t period)
{
/* Overflow will happen in this function if time_in_us >= 2^45, which is about 400 days.
* TODO: fix overflow.
*/
return (time_in_us << RTC_CLK_CAL_FRACT) / period;
}
Who is online
Users browsing this forum: No registered users and 109 guests