I've been trying to get an RTC clock to display time. I tried using 3 different RTC modules: standard ds1307, pcf8523 and ds3231.
They all give the same results: wrong time and no incrementing. It does not matter if I manually insert a timestamp or if it gets it at compile time.
I am using using a Feather Adalogger and an MPU6050 accelerometer. The battery is good and the connections have been verified. It's as if there is some value in some memory somewhere that reverts to the timestamp below.
Here's the code:
#include <RTClib.h>
#include <Wire.h>
RTC_DS3231 rtc;
char t[32];
void setup() {
Serial.begin(9600);
Wire.begin();
rtc.begin();
rtc.adjust(DateTime(F(DATE),F(TIME)));
//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
void loop() {
DateTime now = rtc.now();
sprintf(t, "%02d:%02d:%02d %02d/%02d/%02d", now.hour(), now.minute(), now.second(), now.day(), now.month(), now.year());
Serial.print(F("Date/Time: "));
Serial.println(t);
delay(1000);
}
Here's the printout:
Date/Time: 00:35:00 04/00/2020
Date/Time: 00:35:01 04/00/2020
Date/Time: 00:35:02 04/00/2020
Date/Time: 00:35:03 04/00/2020
Date/Time: 00:35:00 04/00/2020
Date/Time: 00:35:01 04/00/2020
Date/Time: 00:35:00 04/00/2020
Date/Time: 00:35:01 04/00/2020
Date/Time: 00:35:02 04/00/2020
Date/Time: 00:35:03 04/00/2020
Date/Time: 00:35:00 04/00/2020
Date/Time: 00:35:01 04/00/2020
Date/Time: 00:35:02 04/00/2020
Date/Time: 00:35:03 04/00/2020
Date/Time: 00:35:00 04/00/2020