/*
Demo to read RTC module and pring date time
*/
#include <RTClib.h>
RTC_DS1307 rtc;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// initialise RTC module
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
// set RTC to PC date time, if connected to a PC
if (F(__DATE__) != null) {
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
// put your main code here, to run repeatedly:
DateTime now = rtc.now();
Serial.print("Date & Time: ");
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(now.dayOfTheWeek());
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.println(now.second(), DEC);
}