Reset time on Adafruit PCF8523

Hey there, I'm trying to get the Adafruit PCF8523 to tell me the accurate time.

I'm using the included sketch to reset the time of it. Here is the snipped that I'm using

void setup() {

void initializeRTC() {
  //detect if Real Time Clock (RTC) is connected
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while(1) delay(10);

  Serial.println("RESET RTC to now");
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  if (! rtc.initialized() || rtc.lostPower()) {
    Serial.println("RTC is NOT initialized, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));



this does set the time, but it appears to be off by about 8 hours?

Using Unix Time Stamp - Epoch Converter I examined what the timestamp was coming out of there versus the timestamp coming off of the logging for the Arduino 1639008937
arduino: 1638981100

that's a difference of 27,837 seconds or 7.7325 hours

This result seems #1 arbitrary and #2 close to my UTC offset (GMT-8)? But since it isn't exact, I'm thinking that's a red herring.

You are setting the RTC to the time that the sketch was compiled, so it would be the local time on your computer.

See Resetting RTC Time is offset by 8-ish hours - adafruit industries

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.