Difference between revisions of "WeMOS: D1 R1 mini NTP via Serial"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) (Created page with " →NTP Display via Serial: #include <NTPClient.h> #include <ESP8266WiFi.h> #include <WiFiUdp.h> const char *ssid = "o3"; const char *password = "Dzaq1993...") |
Onnowpurbo (talk | contribs) |
||
Line 8: | Line 8: | ||
#include <WiFiUdp.h> | #include <WiFiUdp.h> | ||
− | const char *ssid = " | + | const char *ssid = "o1"; |
const char *password = "Dzaq1993!"; | const char *password = "Dzaq1993!"; | ||
Revision as of 18:24, 1 April 2023
/* NTP Display via Serial */ #include <NTPClient.h> #include <ESP8266WiFi.h> #include <WiFiUdp.h> const char *ssid = "o1"; const char *password = "Dzaq1993!"; const long utcOffsetInSeconds = 25200; char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; // Define NTP Client to get time WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP, "asia.pool.ntp.org", utcOffsetInSeconds); int hh, mm, ss; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while ( WiFi.status() != WL_CONNECTED ) { delay ( 500 ); Serial.print ( "." ); } timeClient.begin(); } void loop() { timeClient.update(); hh = timeClient.getHours(); mm = timeClient.getMinutes(); ss = timeClient.getSeconds(); Serial.print(daysOfTheWeek[timeClient.getDay()]); Serial.print(", "); Serial.print(hh); Serial.print(":"); Serial.print(mm); Serial.print(":"); Serial.println(ss); //Serial.println(timeClient.getFormattedTime()); delay(1000); }