Hey,
I'm trying out the DS3231 rtc module.
I can't seem to set the correct time. I've tried different libraries and the example codes from there.
I've tried both the IDE and the online version. All with the same result. Date is 2001.01.01 etc
Here's an example code I've been trying:
#include "Sodaq_DS3231.h"
#include <Wire.h>
DateTime now;
void setup() {
Serial.begin(9600);
Wire.begin();
rtc.begin();
now = rtc.now();
uint32_t ts = now.getEpoch();
}
uint32_t old_timeStamp;
void loop() {
now = rtc.now();
uint32_t ts = now.getEpoch();
if (old_timeStamp == 0 || old_timeStamp != ts) {
old_timeStamp = ts;
int Nowyear = now.year();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.date(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.println();
}
delay (5000);
}
Example of the serial output:
2000/1/1 0:9:15
2000/1/1 0:9:20
2000/1/1 0:9:25
2000/1/1 0:9:30
Any Ideas?