#include <WiFiManager.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
WiFiUDP udp;
NTPClient timeClient(udp);
void setup() {
Serial.begin(115200);
WiFiManager wm;
// Try to connect to previously saved WiFi credentials.
bool res = wm.autoConnect("Wokwi-Guest");
if (!res) {
Serial.println("Failed to connect and hit timeout");
// Reset and try again, or maybe put it to deep sleep
ESP.restart();
} else {
// If connection successful
Serial.println("Connected to WiFi!");
}
timeClient.begin();
}
void loop() {
// Your main code here
timeClient.update();
Serial.println(timeClient.getFormattedTime());
delay(1000);
}