From a07b034d6995a503183be004f170c354d14d40b4 Mon Sep 17 00:00:00 2001 From: Daniel Lilja <60037035+DanielFrykman@users.noreply.github.com> Date: Fri, 21 Feb 2020 14:26:26 +0100 Subject: [PATCH] Update ds3231.ino 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. --- examples/ds3231/ds3231.ino | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/ds3231/ds3231.ino b/examples/ds3231/ds3231.ino index 4bbf062d..bec91d13 100644 --- a/examples/ds3231/ds3231.ino +++ b/examples/ds3231/ds3231.ino @@ -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 () {