I ran into some weird issues though:
- If I update the date to test displaying weekdays, it gives the value 6 for both saturdays and sundays
- If I update the date to a day prior to the current one, the date change is not implemented. I can only set a day after the current day. If I need to set it to an earlier moment, I can remove the battery and the power via de Arduino Leonardo for like 10 seconds, then it goes back to 0. Adding rtc.stopClock(); before setting it does not help.
This is the code I use, I stripped away a lot of lines from the samples with the library.
Code: Select all
#include <Wire.h>
#include <I2C_RTC.h>
static DS3231 rtc;
void setup()
{
Serial.begin(9600);
while (!Serial);
rtc.begin();
rtc.setHourMode(CLOCK_H24);
rtc.setDateTime(__DATE__, __TIME__);
rtc.updateWeek();
rtc.startClock(); //Start the Clock;
}
void loop()
{
Serial.print(rtc.getWeek());
Serial.print(" ");
Serial.print(rtc.getDay());
Serial.print(" ");
Serial.print(rtc.getMonth());
Serial.print(" ");
Serial.print(rtc.getYear());
Serial.print(" ");
Serial.print(rtc.getHours());
Serial.print(":");
Serial.print(rtc.getMinutes());
Serial.print(":");
Serial.println(rtc.getSeconds());
delay(1000);
}