#include <WiFi.h>
#define NTP_SERVER "pool.ntp.org"
#define UTC_OFFSET 0
#define UTC_OFFSET_DST 0
void printLocalTime() {
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
Serial.println("NTP Connection Error");
return;
}
Serial.println(&timeinfo, "Date: %d/%m/%Y");
Serial.println(&timeinfo, "Time: %H:%M:%S %Z");
}
void setup() {
// Wait for USB Serial to connect
while (!Serial) delay(50);
Serial.begin(115200);
delay(10);
Serial.print("Connecting to Wifi");
WiFi.begin("Wokwi-GUEST", "");
while (WiFi.status() != WL_CONNECTED) {
delay(250);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected! ");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Updating time from NTP server...");
configTime(UTC_OFFSET, UTC_OFFSET_DST, NTP_SERVER);
printLocalTime();
}
void loop() {
delay(100);
}
esp:0
esp:1
esp:2
esp:3
esp:4
esp:5
esp:6
esp:7
esp:8
esp:9
esp:10
esp:11
esp:12
esp:13
esp:14
esp:15
esp:16
esp:17
esp:18
esp:21
esp:26
esp:33
esp:34
esp:35
esp:36
esp:37
esp:38
esp:39
esp:40
esp:41
esp:42
esp:43
esp:44
esp:45
esp:46
esp:3V3.1
esp:GND.1
esp:3V3.2
esp:GND.7
esp:SDA
esp:SCL
esp:5V.1
esp:GND.3
esp:GND.2
esp:5V.2
esp:GND.4
esp:GND.5
esp:GND.6
esp:5V.3
esp:21.2