I'm using an ESP32-S3 with a dual power supply (main and coin cell via TPS2115APWR) to keep the RTC running during power loss. When the main power is disconnected, the ESP32 detects the switch to the coin cell and immediately enters deep sleep.
The problem is that the RTC resets upon waking from deep sleep.
Question: Is there a way to accurately determine how long the ESP32-S3 was in deep sleep so I can correct the Clock on wake-up?
Any suggestions on tracking deep sleep duration or alternative methods for a persistent RTC during power interruptions and deep sleep would be very helpful. Thanks!
I have not studied that RTC, but in all other cases, I am aware that the job of the RTC is to keep the time while the main board is powered off. It sounds like your RTC is missing its backup battery power, or something else is messing with it.
Esp32-S3 is getting sufficient power before deep sleep, during deep sleep and waking up from deep sleep. The problem is, I don't know how to use RTC Timer during deep sleep, and how to keep it running after waking up.
I want to implement Deep-Sleep Mode (RTC timer + RTC memory - 10uA)
I have attached the switching circuit, using State pin i can put Esp32 to deep sleep and wakeup.
This is the alternative method that I'm using. ESP32 does preserve the time during deep sleep although its time runs a bit faster during sleeping. So I synchronize the time with the NTP server immediately after waking up. This corrects the internal ESP32's clock.
Some time ago there was a bug that caused reset on wake up at least on Esp32-C3.
If you aren't using latest core, an update might fix the issue.
Also, try to find out the RTC reset reason.
After using the code, I am getting this reason. Also the timer before reset and after reset. I am saving the rtc timer in rtc memory before going to sleep.
I don't know what time counting you do.
But your topic was about RTC resetting, If you have doubts, try the boot counter example here, it's saving the count in RTC memory.