/* This code is to use with DS1307 RTC and LCD i²c screen
* It displays the time and date H:M:s D/M/Y as simple format 24h
* Refer to www.surtrtech.com for more details
*/
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#define I2C_ADDR 0x27 //I2C adress, you should use the code to scan the adress first (0x27) here
tmElements_t tm; //RTC instance
LiquidCrystal_I2C lcd(I2C_ADDR, 16, 2);
void setup() {
lcd.begin (16,2);
lcd.home();
lcd.print("Hi"); //Hi :D
delay(1000);
}
void loop() {
lcd.clear();
if (RTC.read(tm)) { //If there's a correct reading
lcd.print(tm.Hour);
lcd.print(':');
lcd.print(tm.Minute);
lcd.print(':');
lcd.print(tm.Second);
lcd.setCursor(0,1);
lcd.print(tm.Day);
lcd.print('/');
lcd.print(tm.Month);
lcd.print('/');
lcd.print(tmYearToCalendar(tm.Year));
}
delay(1000);
}