init commit
This commit is contained in:
1 parent
08fcc15fa9
commit
451657ed4e
570 files changed
+91845
No files matched your search
@@ -0,0 +1,63 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <time.h>
|
||||
|
||||
const char* ssid = "Wayne Manor";
|
||||
const char* password = "einfach10zeichen!";
|
||||
const char* TZ_INFO = "CET-1CEST,M3.5.0,M10.5.0/3";
|
||||
|
||||
void connectWiFi() {
|
||||
Serial.print("Verbinde mit WLAN");
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
|
||||
Serial.println("\nVerbunden!");
|
||||
Serial.print("IP: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void syncTime() {
|
||||
configTime(TZ_INFO, "pool.ntp.org", "time.nist.gov");
|
||||
|
||||
Serial.print("Synchronisiere Zeit");
|
||||
|
||||
time_t now = time(nullptr);
|
||||
while (now < 100000) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
now = time(nullptr);
|
||||
}
|
||||
|
||||
Serial.println("\nZeit synchronisiert!");
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("\nStarte ESP8266...");
|
||||
|
||||
connectWiFi();
|
||||
syncTime();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
time_t now = time(nullptr);
|
||||
struct tm* t = localtime(&now);
|
||||
|
||||
if (t) {
|
||||
Serial.printf("%02d:%02d:%02d %02d.%02d.%04d\n",
|
||||
t->tm_hour,
|
||||
t->tm_min,
|
||||
t->tm_sec,
|
||||
t->tm_mday,
|
||||
t->tm_mon + 1,
|
||||
t->tm_year + 1900);
|
||||
} else {
|
||||
Serial.println("Fehler beim Lesen der Zeit");
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
Reference in new issue
Block a user