millis() and light-sleep

tmexlarge
Posts: 4
Joined: Thu Nov 24, 2022 5:01 pm

millis() and light-sleep

Postby tmexlarge » Wed Aug 09, 2023 12:36 pm

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?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: millis() and light-sleep

Postby ESP_igrr » Wed Aug 09, 2023 2:15 pm

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!

tmexlarge
Posts: 4
Joined: Thu Nov 24, 2022 5:01 pm

Re: millis() and light-sleep

Postby tmexlarge » Wed Aug 09, 2023 5:19 pm

Thank you for this information.

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

Who is online

Users browsing this forum: No registered users and 67 guests