Skip to content

Commit

Permalink
Update ds3231.ino
Browse files Browse the repository at this point in the history
If the rtc.adjust is inside the the if (rtc.lostpower()) it will not run unless rtc. rtc.lostpower is not running, but if you just uncomment the rtc.adjust it will not set the time unless power was also lost.

I have added a new section for setting the RTC if you need to,
I have with success implemented this changes to my own clone of the library.
  • Loading branch information
DanielFrykman authored Feb 21, 2020
1 parent 04182cb commit a07b034
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/ds3231/ds3231.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ void setup () {

if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
// If the RTC have lost power it will sets the RTC to the date & time this sketch was compiled in the following line
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

// If you need to set the time of the uncomment line 34 or 37
// following line sets the RTC to the date & time this sketch was compiled
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

void loop () {
Expand Down

0 comments on commit a07b034

Please sign in to comment.