How to keep the system time between reboots?

jaracil
Posts: 11
Joined: Sat Apr 02, 2016 4:24 pm

How to keep the system time between reboots?

Postby jaracil » Thu Jun 01, 2017 3:00 pm

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.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: How to keep the system time between reboots?

Postby kolban » Thu Jun 01, 2017 4:53 pm

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.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: How to keep the system time between reboots?

Postby WiFive » Thu Jun 01, 2017 7:56 pm

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.

Who is online

Users browsing this forum: No registered users and 209 guests