#include <WiFi.h>
#include <RTClib.h> // RTC_DS1307 and DateTime
#include "my_lcd.h"
#include "my_wifi.h"
MyLCD lcd;
RTC_DS1307 rtc;
MyWiFi wifi;
void setup() {
Serial.begin(115200);
lcd.begin();
if (!rtc.begin()) {
Serial.println(F("Error: RTC not found!"));
lcd.print("RTC not found!");
while (1); // Halt if RTC fails
}
wifi.begin(&rtc); // Connect WiFi and setup NTP
}
void loop() {
lcd.display("ESP32-DevKitC-v4", "Hello, World!", "Ngee Ann Poly");
delay(2000);
lcd.clear();
DateTime now = rtc.now();
char dtbuf[21] = "YYYY-MM-DD hh:mm:ss";
now.toString(dtbuf);
lcd.datetime(dtbuf);
if (wifi.isTimeSynched()) {
lcd.alarm(1, "Temp UL1:", "40.6", 0);
delay(2000);
lcd.alarm(2, "Curr UL2:", "60.0", "A");
}
delay(2000);
}