Hi,
I can't figure out why, I adjust my rtc using an accurate unix uint32_t value, and when I get time afterwards, the time is off by like 5 years. It doesn't make sense. my code used to work.
There is nothing else going on in between the lines of code I am sharing, the instructions are litterally back to back and somehow the rtc adjust screw up...
Any Idea? Thanks!
#include <rtclib.h>
uint32_t _ntpUnixTime;
RTC_DS3231 _rtc;
void setup() {
Serial.begin(9600);
_rtc.begin();
_ntpUnixTime = _getTimeFromESP32(); // stores a uint32_t time stamp from a ntp server
Serial.print("time online: ");
Serial.println(_ntpUnixTime);
_rtc.adjust(DateTime(_ntpUnixTime));
Serial.print("rtc after fetched online: ");
Serial.print(_rtc.now().unixtime());
}
Serial monitor output:
time online: 1641769930
rtc after fetched online: 1806623185