Page 1 of 1

millis() and light-sleep

Posted: Wed Aug 09, 2023 12:36 pm
by tmexlarge
Since my experiences in an earlier esp32 project i was sure that the millis() value isn't maintained over light-sleep. And i had to use the RTC myself to determine the sleep time.

Now more or less by accident i recognized that the millis() value is indeed corrected after wakeup from light-sleep.

Does this behaviour changed over idf or arduino Versions?
Are there any requirements to make this work which are now met by accident?

Re: millis() and light-sleep

Posted: Wed Aug 09, 2023 2:15 pm
by ESP_igrr
It is possible that this hasn't worked in the first arduino-esp32 release, v1.0.0, which came out in July 2018.

arduino-esp32 uses esp_timer_get_time IDF function to implement millis, and esp_timer_get_time has maintained time in light sleep since IDF v3.1, released in September 2018.

If you have observed this behavior in later releases of arduino-esp32, then I don't have an explanation for this. But maintaining the 'millis' value in light sleep is now the expected behavior!

Re: millis() and light-sleep

Posted: Wed Aug 09, 2023 5:19 pm
by tmexlarge
Thank you for this information.

Maybe i can figure out which versions were in use. Just for curiosity.