/*
https://github.com/Makuna/Rtc
Arduino Real Time Clock library.
*/
#include <ThreeWire.h>
#include <RtcDS1302.h>
ThreeWire myWire(6, 5, 4); // IO, SCLK, CE
RtcDS1302<ThreeWire> Rtc(myWire);
bool rtclock_err;
void setup ()
{
Serial.begin(9600);
Rtc.Begin();
RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__);
Rtc.SetDateTime(compiled + 0 * 8 * 60 * 60);
//Rtc.SetDateTime(RtcDateTime(2018, 1, 17, 7, 53, 00));
}
void loop() {
static char date[11];
static char time[9];
RtcDateTime dt = Rtc.GetDateTime();
snprintf(date, 11, "%04u-%02u-%02u", dt.Year(), dt.Month(), dt.Day());
snprintf(time, 9, "%02d:%02d:%02d", dt.Hour(), dt.Minute(), dt.Second());
Serial.print(date);
Serial.print(" ");
Serial.print(time);
Serial.println("");
delay(300);
}