While looking over the new Weather carrier board currently holding my ESP32 processor board I realized one of the components on there is a small battery for keeping an RTC alive “if the processor board has one.” Looking at the schematic of the ESP32 processor board it seems like this is hooked up and should keep the RTC alive that’s built in. After installing the ESP32Time library in the Arduino IDE I was able to execute the example and see that it indeed does have an RTC. I took this example and ran with it to make a short demo project where I can set the time over the serial monitor if I need to, otherwise it just loops and reports back what it is.
However whenever I reset the processor or dis/connect power I’m time traveling back to 1970 as if the battery isn’t connected. Is it my sketch or something else fundamental I’m missing?
(Won’t let me include the code for some reason, so here’s the snippets that deal with the RTC)
ESP32Time rtc;
…
void loop()
{
…
Serial.println(“CURRENT TIME:”);
Serial.println(rtc.getTime(“%A, %B %d %Y %H:%M:%S”));
}
// Doesn’t seem to matter if I use a static date/time like below or input from the serial console, still gets lost on power cycle
// This is not called all the time, only on demand when formatted serial data is parsed and ready
set_time()
{
…
rtc.setTime(00, 14, 11, 21, 5, 2021); //May 21 2021, 11:14:00
}
Thanks!