Skip to content

Commit

Permalink
Merge pull request #134 from DanielFrykman/patch-2
Browse files Browse the repository at this point in the history
Provide examples to set time regardless of DS3231 losing power
  • Loading branch information
drak7 authored Feb 25, 2020
2 parents 8e77a51 + a07b034 commit f47bcdd
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 f47bcdd

Please sign in to comment.