unix_timer: set the internal clock values and display the Dtae and time each second

This commit is contained in:
Txus Ordorika 2019-02-14 23:15:09 +01:00
parent 75735e68e7
commit d255f59475
1 changed files with 8 additions and 14 deletions

View File

@ -54,6 +54,11 @@ void setup()
// Initialize the rtc object
rtc.begin();
// The following lines can be uncommented to set the date and time
// rtc.setDOW(THURSDAY); // Set Day-of-Week to SUNDAY
// rtc.setTime(23, 11, 0); // Set the time to 12:00:00 (24hr format)
// rtc.setDate(14, 2, 2019); // Set the date to January 1st, 2014
}
void loop()
@ -66,22 +71,11 @@ void loop()
Serial.print(" -- ");
Serial.println(rtc.getTimeStr());
// Send Unixtime
// ** Note that there may be a one second difference between the current time **
// ** and current unixtime show if the second changes between the two calls **
Serial.print("Current Unixtime.........................: ");
Serial.println(rtc.getUnixTime(rtc.getTime()));
// Send Unixtime for 00:00:00 on January 1th 2014
Serial.print("Unixtime for 00:00:00 on January 1th 2014: ");
t.hour = 0;
t.min = 0;
t.sec = 0;
t.year = 2014;
t.mon = 1;
t.date = 1;
Serial.println(rtc.getUnixTime(t));
Serial.print("Internal temperature: ");
Serial.println(rtc.getTemp());
// Wait indefinitely
while (1) {};
delay(1000);
}