Page 1 of 1

Time keeping in light sleep

Posted: Mon Apr 16, 2018 8:30 pm
by ggoblin
Hi,
I need to keep track of time during light sleep. Since the CPU is off I assume none of the timers will work. Is there another way to keep track of time during light sleep? Can RTC be used somehow?

Thanks

Re: Time keeping in light sleep

Posted: Tue Apr 17, 2018 12:54 am
by ESP_igrr
In light sleep, timekeeping is done by RTC timer. On exiting sleep, system time (as reported by 'gettimeofday') will be updated based to the RTC timer.

There's another change which will be merged soon, which also adjusts time reported by esp_timer_get_time.

If you want to implement your own timekeeping mechanism, you can get RTC time from esp_clk_rtc_time function in esp_clk.h.