#include<LiquidCrystal_I2C.h>
#include<esp_sleep.h>
#include"time.h"
#include <WiFi.h>
LiquidCrystal_I2C lcd( 0x27, 16,2);
struct tm timeinfo;
const char* ssid = "Wokwi-GUEST";
const char* password = "";
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected");
lcd.init();
lcd.backlight();
configTime(8 * 3600, 0,"pool.ntp.org");
while(!time(nullptr)){
delay(1000);
}
}
void loop() {
// put your main code here, to run repeatedly:
// this speeds up the simulation
if(!getLocalTime(&timeinfo)){
lcd.print("Failed to get time");
return;
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Time: ");
lcd.print(String(timeinfo.tm_hour) + ":" + String(timeinfo.tm_min) + ":" + String(timeinfo.tm_sec));
delay(1000);
esp_sleep_enable_timer_wakeup(60000000);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
esp_deep_sleep_start();
}