I'm using an Adafruit HUZZAH feather board (ESP32). It has Wi-Fi built in and I'm successfully pulling the time from an NTP server (pool.ntp.org).
I'd like to update a RTC (Real Time Clock) on an add-on board with the NTP time I obtain, but for some reason I can't structure the line correctly to update the RTC time.
Here is what I'm trying to do:
rtc.adjust(&timeinfo, %Y, %B, %d, %H, %M, %S);
This gives an error which states:
expected primary-expression before '%' token
This is what works to update the RTC that I tried to modify:
rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); // This sets the time to 1/21/2014 at 3:00 am.
For reference, here is the entire function I'm using:
void printLocalTime()
{
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
//Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
Serial.println("Failed to obtain time");
return;
}
Serial.print("NTP time: ");
Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
rtc.adjust(&timeinfo, %Y, %B, %d, %H, %M, %S); // Update the RTC if it found the time from the internet.
Serial.println("Updated the RTC on the Adalogger board.");
}
How do I correctly modify it to use the &timeinfo statement?