Page 1 of 1

How to keep the system time between reboots?

Posted: Thu Jun 01, 2017 3:00 pm
by jaracil
Hello.

I want to keep the system time between reboots (Obviously not in case of power failure).
Is there any chance without an external real time clock chip?
... if not ... is there any RAM region that is not reset between reboots?

Thanks.

Re: How to keep the system time between reboots?

Posted: Thu Jun 01, 2017 4:53 pm
by kolban
To my way of thinking, an "operating" ESP32 can be either "on" or "off". In the "off" mode, it has no power and will not do any work. With no power, it can't keep track of time. In the "on" mode, it has power and is running. Internally, it is keeping track of elapsed time.

The "on" mode is not just "one" mode. There are sub modes with are there to conserve power such as a variety of "sleep levels". In these sleep levels, the bare minimum is performed by the ESP32 to "keep it alive". This includes maintaining the real-time clock. An ESP32 can "programatically" switch between these on-modes.

The switching between these "on-modes" I distinguish from a "reboot". I consider a reboot as a "power on sequence". I.e. going from the "off" state to the "on" state. This is distinct from going from the "on-deep-sleep" state to the "on-normal-running" state.

If you wish to maintain real-time clock measurement when the ESP32 is in its "off" state, you will need an external real-time clock processor with its companion battery source which will allow it to continue to measure time even when the ESP32 is off.

Re: How to keep the system time between reboots?

Posted: Thu Jun 01, 2017 7:56 pm
by WiFive
Semantics aside, say you wanted to reboot after an ota update without losing the rtc counter. The best way to do that might be a short (or zero?) deepsleep w/ timer wakeup.