#include <RTClib.h> // Define RTC_DS1307 and DateTime
#include "my_lcd.h"
MyLCD lcd;
RTC_DS1307 rtc;
void setup() {
Serial.begin(115200);
lcd.begin();
if (!rtc.begin()) { // Time is critical
Serial.println(F("Error: RTC not found!"));
while (1); // Halt if RTC fails
}
}
void loop() {
lcd.display("ESP32-DevKitC-v4", "Hello, World!", "Ngee Ann Poly");
delay(5000);
lcd.clear();
DateTime now = rtc.now();
char dtbuf[21] = "YYYY-MM-DD hh:mm:ss";
now.toString(dtbuf); // Formats time into dtbuf
lcd.datetime(dtbuf);
lcd.alarm(1, "Temp UL1:", "40.6", 0);
delay(5000);
lcd.alarm(2, "Curr UL2:", "60.0", "A");
delay(5000);
}LCD (20x4) (I2C)
DS1307 RTC