
Programm mit WiFiMulti.h
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
#include "WiFi.h" #include "WiFiMulti.h" WiFiMulti WiFiNetzwerke; // schwarz/weiß Display #include "GxEPD2_BW.h" #include "U8g2_for_Adafruit_GFX.h" // Objekt u8g2Schriften U8G2_FOR_ADAFRUIT_GFX u8g2Schriften; #ifdef ESP8266 #include "ESP8266WiFi.h" #else #include "WiFi.h" #endif #include "time.h" // schwarz/weiß Display #include "GxEPD2_BW.h" #include "U8g2_for_Adafruit_GFX.h" #include "DHT.h" // Pin des DHT-Sensors anpassen // Nano ESP32 // int SENSOR_DHT = D5; // ESP32-Wroom // int SENSOR_DHT = 13; // NodeMCU // int SENSOR_DHT = D3; // ESP32-C6 // int SENSOR_DHT = 13; #define SensorTyp DHT22 // DHT11 // #define SensorTyp DHT11 // Sensor einen Namen zuweisen DHT dht(SENSOR_DHT, SensorTyp); // ESP32-Wroom // Anschlüsse: CLK -> 18, DIN -> 23, CS -> 5, DC-> 2, RST -> 15, BUSY -> 4 // GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> // display(GxEPD2_420_GDEY042T81(/*CS*/ 5, /*DC*/ 2, /*RST*/ 15, /*BUSY*/ 4)); // NodeMCU // CLK - D5, DIN -> D7, CS -> D8, DC -> D6, RST -> D2, BUSY -> D1 // GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> // display(GxEPD2_420_GDEY042T81(/*CS*/ D8, /*DC*/ D6, /*RST*/ D2, /*BUSY*/ D1)); // ESP32-C6 // Anschlüsse: CLK -> 21, DIN -> 19, CS -> 18, DC-> 3, RST -> 10, BUSY -> 11 // GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> // display(GxEPD2_420_GDEY042T81(/*CS*/ 18, /*DC*/ 3, /*RST*/ 10, /*BUSY*/ 11)); // Nano ESP32 // Anschlüsse: CLK -> D13, DIN -> D11, CS -> D10, DC-> D6, RST -> D7, BUSY -> D9 // GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> // display(GxEPD2_420_GDEY042T81(/*CS*/ D10, /*DC*/ D6, /*RST*/ D7, /*BUSY*/ D9)); // NTP-Server aus dem Pool #define Zeitserver "de.pool.ntp.org" /* Liste der Zeitzonen https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv Zeitzone CET = Central European Time ‑1 -> 1 Stunde zurück CEST = Central European Summer Time von M3 = März, 5.0 = Sonntag 5. Woche, 02 = 2 Uhr bis M10 = Oktober, 5.0 = Sonntag 5. Woche 03 = 3 Uhr */ #define Zeitzone "CET-1CEST,M3.5.0/02,M10.5.0/03" // time_t enthält die Anzahl der Sekunden seit dem 1.1.1970 0 Uhr time_t aktuelleZeit; /* Struktur tm tm_hour -> Stunde: 0 bis 23 tm_min -> Minuten: 0 bis 59 tm_sec -> Sekunden 0 bis 59 tm_mday -> Tag 1 bis 31 tm_mon -> Monat: 0 (Januar) bis 11 (Dezember) tm_year -> Jahre seit 1900 tm_yday -> vergangene Tage seit 1. Januar des Jahres tm_isdst -> Wert > 0 = Sommerzeit (dst = daylight saving time) */ tm Zeit; // Variablen für die Zeit int Stunden, Minuten, Sekunden; // Start wird nur beim ersten Start für den Aufbau des TFTs benötigt bool Start = true; const unsigned char Kalender [] PROGMEM = { // 'Kalender, 50x50px 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 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, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0 }; const unsigned char Thermometer [] PROGMEM = { // 'Thermometer, 34x70px 0x00, 0x07, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x00, 0x7c, 0x0f, 0x00, 0x00, 0x00, 0x70, 0x07, 0x80, 0x00, 0x00, 0xe0, 0x03, 0xc0, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0,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0xff, 0x07, 0x80, 0x38, 0x3f, 0xfe, 0x0f, 0x00, 0x3c, 0x0f, 0xfc, 0x0f, 0x00, 0x1e, 0x03, 0xe0, 0x1e, 0x00, 0x1f, 0x00, 0x00, 0x3e, 0x00, 0x0f, 0x00, 0x00, 0x7c, 0x00, 0x07, 0xe0, 0x01, 0xf8, 0x00, 0x03, 0xf8, 0x07, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x7f, 0xff, 0x80, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00 }; const unsigned char Regen [] PROGMEM = { // 'Regen, 60x49px 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x21, 0x04, 0x10, 0x00, 0x00, 0x00, 0x06, 0x18, 0x63, 0x0c, 0x30, 0x80, 0x00, 0x00, 0x06, 0x10, 0x63, 0x0c, 0x31, 0x80, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x84, 0x10, 0x41, 0x08, 0x20, 0x00, 0x00, 0x61, 0x8c, 0x30, 0xc3, 0x18, 0x60, 0x00, 0x08, 0xc1, 0x8c, 0x30, 0xc3, 0x18, 0x61, 0x00, 0x00, 0x41, 0x04, 0x20, 0x82, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x30, 0x86, 0x18, 0x43, 0x04, 0x30, 0x80, 0x18, 0x71, 0x86, 0x18, 0xc3, 0x0c, 0x31, 0x80, 0x18, 0x21, 0x84, 0x10, 0xc3, 0x0c, 0x21, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x18, 0x21, 0x04, 0x10, 0x42, 0x18, 0x40, 0x86, 0x18, 0x63, 0x0c, 0x30, 0xc6, 0x18, 0xc0, 0x86, 0x10, 0x63, 0x0c, 0x30, 0xc6, 0x18, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x21, 0x04, 0x10, 0xc2, 0x0c, 0x21, 0x00, 0x30, 0x63, 0x0c, 0x31, 0xc6, 0x0c, 0x63, 0x00, 0x30, 0x63, 0x0c, 0x31, 0x86, 0x18, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x43, 0x08, 0x20, 0x86, 0x10, 0x00, 0x06, 0x30, 0xc3, 0x18, 0x61, 0x86, 0x30, 0x00, 0x04, 0x30, 0xc2, 0x18, 0x61, 0x8c, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x80, 0x00, 0x00, 0x0c, 0x30, 0xc6, 0x18, 0x61, 0x00, 0x00, 0x00, 0x00, 0x61, 0xc6, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x60, 0x86, 0x10, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; const unsigned char Uhr [] PROGMEM = { // Uhr, 50x50px 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x07, 0x80, 0xc0, 0x00, 0x40, 0x78, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x1f, 0x00, 0x00, 0x80, 0x00, 0x3e, 0x00, 0x1e, 0x00, 0x00, 0xc0, 0x00, 0x1e, 0x00, 0x3e, 0x00, 0x00, 0xc0, 0x00, 0x1f, 0x00, 0x3c, 0x00, 0x00, 0xc0, 0x00, 0x0f, 0x00, 0x38, 0x30, 0x00, 0xc0, 0x01, 0x07, 0x00, 0x78, 0x00, 0x00, 0xc0, 0x00, 0x07, 0x80, 0x78, 0x00, 0x00, 0xc0, 0x00, 0x07, 0x80, 0x70, 0x00, 0x00, 0xc0, 0x00, 0x03, 0x80, 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0xf1, 0x80, 0x00, 0xc0, 0x00, 0x63, 0xc0, 0xf1, 0x80, 0x01, 0x80, 0x00, 0x63, 0xc0, 0xf0, 0x00, 0x07, 0x00, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x1c, 0x00, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x78, 0x00, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0xe0, 0x00, 0x00, 0x03, 0xc0, 0x70, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x78, 0x07, 0x00, 0x00, 0x00, 0x07, 0x80, 0x78, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x78, 0x20, 0x00, 0x00, 0x01, 0x07, 0x80, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x07, 0x80, 0x80, 0x00, 0xc0, 0x78, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, 0x00, 0x01, 0xf8, 0x00, 0xc0, 0x07, 0xe0, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x1f, 0xe0, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x00, 0x00 }; unsigned long Zeitmessung = 0; void setup() { // Schriften von u8g2 display zuordnen u8g2Schriften.begin(display); // localtime_r -> Zeit in die lokale Zeitzone setzen localtime_r(&aktuelleZeit, &Zeit); // Zeitzone: Parameter für die zu ermittelnde Zeit configTzTime(Zeitzone, Zeitserver); Serial.begin(9600); // auf serielle Verbindung warten while (!Serial); delay(1000); // Bildschirm starten display.init(115200, true, 2, false); display.setRotation(0); // vollständigen Bildschirm nutzen display.setFullWindow(); display.fillScreen(GxEPD_WHITE); WiFi.mode(WIFI_STA); // verfügbare WiFi-Netzwerke WiFiNetzwerke.addAP("Router_SSID", "xxxxxxxx"); WiFiNetzwerke.addAP("Repeater-1", "xxxxxxxx"); WiFiNetzwerke.addAP("Repeater-2", "xxxxxxxx"); Serial.println("------------------------"); if (WiFiNetzwerke.run() == WL_CONNECTED) { Serial.println("WiFi verbunden ..."); } else { Serial.println("Keine Verbindung zum WLAN ..."); do { u8g2Schriften.setCursor(10, 20); u8g2Schriften.setForegroundColor(GxEPD_BLACK); u8g2Schriften.setBackgroundColor(GxEPD_WHITE); u8g2Schriften.setFont(u8g2_font_helvB14_tf); u8g2Schriften.print("Keine Verbindung zum WLAN .."); u8g2Schriften.setCursor(10, 60); u8g2Schriften.print("Programm beendet ..."); } while (display.nextPage()); while(1); } delay(2000); Serial.println(); Serial.print("Verbunden mit "); Serial.println(WiFi.SSID()); Serial.print("IP über DHCP: "); Serial.println(WiFi.localIP()); do { u8g2Schriften.setCursor(10, 20); u8g2Schriften.setForegroundColor(GxEPD_BLACK); u8g2Schriften.setBackgroundColor(GxEPD_WHITE); u8g2Schriften.setFont(u8g2_font_helvB14_tf); u8g2Schriften.print("WiFi verbunden ..."); u8g2Schriften.setCursor(10, 60); u8g2Schriften.print("aktuelle Zeit holen ..."); } while (display.nextPage()); int Zaehler = 0; // beim Start entspricht das Datum der Unixtime: 1.1.1970 // das Datum soll erst angezeigt werden, wenn es korrekt ist String Jahr = String(Zeit.tm_year + 1900); // String Jahr nach "1970" durchsuchen int Suche = Jahr.indexOf("1970"); // solange die Suche nicht erfolgreich ist // maximal 40 Sekunden while (Suche != -1 && Zaehler < 40) { // aktuelle Zeit holen time(&aktuelleZeit); // localtime_r -> Zeit in die lokale Zeitzone setzen localtime_r(&aktuelleZeit, &Zeit); Jahr = String(Zeit.tm_year + 1900); // String Jahr nach "1970" durchsuchen Suche = Jahr.indexOf("1970"); delay(1000); Zaehler ++; } // Datum/Zeit konnte nicht synchronisiert werden if (Suche != -1) { do { u8g2Schriften.setCursor(10, 80); u8g2Schriften.print("Zeit synchronisieren fehlgeschlagen!"); u8g2Schriften.setCursor(10, 100); u8g2Schriften.print("Programm beendet!!"); } while (display.nextPage()); while(1); } else { // Datum/Zeit erfolgreich synchronisiert do { u8g2Schriften.setCursor(10, 100); u8g2Schriften.print("Zeit synchronisiert ..."); u8g2Schriften.setCursor(10, 140); u8g2Schriften.print(WiFi.SSID()); u8g2Schriften.setCursor(10, 180); u8g2Schriften.print(String(WiFi.localIP().toString())); u8g2Schriften.setCursor(10, 220); u8g2Schriften.print("Signalstärke: " + String(WiFi.RSSI())); } while (display.nextPage()); } // Sensor starten dht.begin(); delay(3000); Zeitmessung = millis() + 1000; } void loop() { display.fillScreen(GxEPD_WHITE); // Start = true // -> Zeit einmalig synchronisieren if (Start) { Start = false; // Zeit jede Minute mit Zeitserver synchronisieren // aktuelle Zeit holen time(&aktuelleZeit); // localtime_r -> Zeit in die lokale Zeitzone setzen localtime_r(&aktuelleZeit, &Zeit); // Zeit in Stunden, Minuten und Sekunden Stunden = int(Zeit.tm_hour), Minuten = int(Zeit.tm_min), Sekunden = int(Zeit.tm_sec); ZeitAnzeigen(); } // Sekunden weiter zählen if (Zeitmessung < millis()) { Zeitmessung += 1000; Sekunden++; if (Sekunden == 60) { // Zeit jede Minute mit Zeitserver synchronisieren // aktuelle Zeit holen time(&aktuelleZeit); // localtime_r -> Zeit in die lokale Zeitzone setzen localtime_r(&aktuelleZeit, &Zeit); // Zeit in Stunden, Minuten und Sekunden Stunden = int(Zeit.tm_hour), Minuten = int(Zeit.tm_min), Sekunden = int(Zeit.tm_sec); ZeitAnzeigen(); } } } void ZeitAnzeigen() { // Temperatur lesen String Temperatur = String(dht.readTemperature()); // replace -> . durch , ersetzen Temperatur.replace(".", ","); // Luftfeuchtigkeit lesen String Luftfeuchtigkeit = String(dht.readHumidity()); // replace -> . durch , ersetzen Luftfeuchtigkeit.replace(".", ","); // Anzeige aufbauen display.firstPage(); do { u8g2Schriften.setFont(u8g2_font_helvB24_tf); u8g2Schriften.setCursor(100, 30); if (Zeit.tm_mday < 10) u8g2Schriften.print("0"); u8g2Schriften.print(Zeit.tm_mday); u8g2Schriften.print("."); // Monat: führende 0 ergänzen if (Zeit.tm_mon < 9) u8g2Schriften.print("0"); // Zählung beginnt mit 0 -> +1 u8g2Schriften.print(Zeit.tm_mon + 1); u8g2Schriften.print("."); // Anzahl Jahre seit 1900 u8g2Schriften.print(Zeit.tm_year + 1900); u8g2Schriften.setCursor(100, 110); u8g2Schriften.setFont(u8g2_font_fub42_tf); // Stunde: wenn Stunde < 10 -> 0 davor setzen if (Zeit.tm_hour < 10) u8g2Schriften.print("0"); u8g2Schriften.print(Zeit.tm_hour); u8g2Schriften.print(":"); // Minuten if (Zeit.tm_min < 10) u8g2Schriften.print("0"); u8g2Schriften.print(Zeit.tm_min); // x, y, Bild-Array, Breite, Höhe, Farbe display.drawBitmap(5, 1, Kalender, 50, 50, GxEPD_BLACK); display.drawBitmap(5, 70, Uhr, 50, 50, GxEPD_BLACK); display.drawBitmap(15, 140, Thermometer, 34, 70, GxEPD_BLACK); display.drawBitmap(5, 240, Regen, 60, 49, GxEPD_BLACK); // Messdaten anzeigen u8g2Schriften.setCursor(100, 190); u8g2Schriften.print(Temperatur + " °C"); u8g2Schriften.setCursor(100, 280); u8g2Schriften.print(Luftfeuchtigkeit + " %"); } while (display.nextPage()); } |
Mit Router/Passwort
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
#include "WiFi.h" // schwarz/weiß Display #include "GxEPD2_BW.h" #include "U8g2_for_Adafruit_GFX.h" // Objekt u8g2Schriften U8G2_FOR_ADAFRUIT_GFX u8g2Schriften; #ifdef ESP8266 #include "ESP8266WiFi.h" #else #include "WiFi.h" #endif #include "time.h" // schwarz/weiß Display #include "GxEPD2_BW.h" #include "U8g2_for_Adafruit_GFX.h" #include "DHT.h" // SSID und Passwort des Routers char Router[] = "Router_SSID"; char Passwort[] = "xxxxxxxx"; // Pin des DHT-Sensors anpassen // Nano ESP32 int SENSOR_DHT = 13; // ESP32-Wroom // int SENSOR_DHT = 13; // NodeMCU // int SENSOR_DHT = D3; // ESP32-C6 // int SENSOR_DHT = 13; #define SensorTyp DHT22 // DHT11 // #define SensorTyp DHT11 // Sensor einen Namen zuweisen DHT dht(SENSOR_DHT, SensorTyp); // ESP32-Wroom // Anschlüsse: CLK -> 18, DIN -> 23, CS -> 5, DC-> 2, RST -> 15, BUSY -> 4 GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> display(GxEPD2_420_GDEY042T81(/*CS*/ 5, /*DC*/ 2, /*RST*/ 15, /*BUSY*/ 4)); // NodeMCU // CLK - D5, DIN -> D7, CS -> D8, DC -> D6, RST -> D2, BUSY -> D1 // GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> // display(GxEPD2_420_GDEY042T81(/*CS*/ D8, /*DC*/ D6, /*RST*/ D2, /*BUSY*/ D1)); // ESP32-C6 // Anschlüsse: CLK -> 21, DIN -> 19, CS -> 18, DC-> 3, RST -> 10, BUSY -> 11 // GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> // display(GxEPD2_420_GDEY042T81(/*CS*/ 18, /*DC*/ 3, /*RST*/ 10, /*BUSY*/ 11)); // Nano ESP32 // Anschlüsse: CLK -> D13, DIN -> D11, CS -> D10, DC-> D6, RST -> D7, BUSY -> D9 // GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> // display(GxEPD2_420_GDEY042T81(/*CS*/ D10, /*DC*/ D6, /*RST*/ D7, /*BUSY*/ D9)); // NTP-Server aus dem Pool #define Zeitserver "de.pool.ntp.org" /* Liste der Zeitzonen https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv Zeitzone CET = Central European Time ‑1 -> 1 Stunde zurück CEST = Central European Summer Time von M3 = März, 5.0 = Sonntag 5. Woche, 02 = 2 Uhr bis M10 = Oktober, 5.0 = Sonntag 5. Woche 03 = 3 Uhr */ #define Zeitzone "CET-1CEST,M3.5.0/02,M10.5.0/03" // time_t enthält die Anzahl der Sekunden seit dem 1.1.1970 0 Uhr time_t aktuelleZeit; /* Struktur tm tm_hour -> Stunde: 0 bis 23 tm_min -> Minuten: 0 bis 59 tm_sec -> Sekunden 0 bis 59 tm_mday -> Tag 1 bis 31 tm_mon -> Monat: 0 (Januar) bis 11 (Dezember) tm_year -> Jahre seit 1900 tm_yday -> vergangene Tage seit 1. Januar des Jahres tm_isdst -> Wert > 0 = Sommerzeit (dst = daylight saving time) */ tm Zeit; // Variablen für die Zeit int Stunden, Minuten, Sekunden; // Start wird nur beim ersten Start für den Aufbau des TFTs benötigt bool Start = true; const unsigned char Kalender [] PROGMEM = { // 'Kalender, 50x50px 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc7, 0xc0, 0x00, 0x00, 0x01, 0xf0, 0xc0, 0xc7, 0xc0, 0x00, 0x00, 0x01, 0xf0, 0xc0, 0xc7, 0xc0, 0x00, 0x00, 0x01, 0xf0, 0xc0, 0xc7, 0xc0, 0x00, 0x00, 0x01, 0xf0, 0xc0, 0xc7, 0xc0, 0x00, 0x00, 0x01, 0xf0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x03, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x07, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x3e, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x1c, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x18, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0 }; const unsigned char Thermometer [] PROGMEM = { // 'Thermometer, 34x70px 0x00, 0x07, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x00, 0x7c, 0x0f, 0x00, 0x00, 0x00, 0x70, 0x07, 0x80, 0x00, 0x00, 0xe0, 0x03, 0xc0, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0, 0x01, 0xc0, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0, 0x01, 0xc0, 0x00, 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0x70, 0x7f, 0xff, 0x87, 0x80, 0x78, 0x3f, 0xff, 0x07, 0x80, 0x38, 0x3f, 0xfe, 0x0f, 0x00, 0x3c, 0x0f, 0xfc, 0x0f, 0x00, 0x1e, 0x03, 0xe0, 0x1e, 0x00, 0x1f, 0x00, 0x00, 0x3e, 0x00, 0x0f, 0x00, 0x00, 0x7c, 0x00, 0x07, 0xe0, 0x01, 0xf8, 0x00, 0x03, 0xf8, 0x07, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x7f, 0xff, 0x80, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00 }; const unsigned char Regen [] PROGMEM = { // 'Regen, 60x49px 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x21, 0x04, 0x10, 0x00, 0x00, 0x00, 0x06, 0x18, 0x63, 0x0c, 0x30, 0x80, 0x00, 0x00, 0x06, 0x10, 0x63, 0x0c, 0x31, 0x80, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x84, 0x10, 0x41, 0x08, 0x20, 0x00, 0x00, 0x61, 0x8c, 0x30, 0xc3, 0x18, 0x60, 0x00, 0x08, 0xc1, 0x8c, 0x30, 0xc3, 0x18, 0x61, 0x00, 0x00, 0x41, 0x04, 0x20, 0x82, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x30, 0x86, 0x18, 0x43, 0x04, 0x30, 0x80, 0x18, 0x71, 0x86, 0x18, 0xc3, 0x0c, 0x31, 0x80, 0x18, 0x21, 0x84, 0x10, 0xc3, 0x0c, 0x21, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x18, 0x21, 0x04, 0x10, 0x42, 0x18, 0x40, 0x86, 0x18, 0x63, 0x0c, 0x30, 0xc6, 0x18, 0xc0, 0x86, 0x10, 0x63, 0x0c, 0x30, 0xc6, 0x18, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x21, 0x04, 0x10, 0xc2, 0x0c, 0x21, 0x00, 0x30, 0x63, 0x0c, 0x31, 0xc6, 0x0c, 0x63, 0x00, 0x30, 0x63, 0x0c, 0x31, 0x86, 0x18, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x43, 0x08, 0x20, 0x86, 0x10, 0x00, 0x06, 0x30, 0xc3, 0x18, 0x61, 0x86, 0x30, 0x00, 0x04, 0x30, 0xc2, 0x18, 0x61, 0x8c, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x80, 0x00, 0x00, 0x0c, 0x30, 0xc6, 0x18, 0x61, 0x00, 0x00, 0x00, 0x00, 0x61, 0xc6, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x60, 0x86, 0x10, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; const unsigned char Uhr [] PROGMEM = { // Uhr, 50x50px 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x07, 0x80, 0xc0, 0x00, 0x40, 0x78, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x1f, 0x00, 0x00, 0x80, 0x00, 0x3e, 0x00, 0x1e, 0x00, 0x00, 0xc0, 0x00, 0x1e, 0x00, 0x3e, 0x00, 0x00, 0xc0, 0x00, 0x1f, 0x00, 0x3c, 0x00, 0x00, 0xc0, 0x00, 0x0f, 0x00, 0x38, 0x30, 0x00, 0xc0, 0x01, 0x07, 0x00, 0x78, 0x00, 0x00, 0xc0, 0x00, 0x07, 0x80, 0x78, 0x00, 0x00, 0xc0, 0x00, 0x07, 0x80, 0x70, 0x00, 0x00, 0xc0, 0x00, 0x03, 0x80, 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x03, 0xc0, 0xf1, 0x80, 0x00, 0xc0, 0x00, 0x63, 0xc0, 0xf1, 0x80, 0x01, 0x80, 0x00, 0x63, 0xc0, 0xf0, 0x00, 0x07, 0x00, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x1c, 0x00, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0x78, 0x00, 0x00, 0x03, 0xc0, 0xf0, 0x00, 0xe0, 0x00, 0x00, 0x03, 0xc0, 0x70, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x78, 0x07, 0x00, 0x00, 0x00, 0x07, 0x80, 0x78, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x78, 0x20, 0x00, 0x00, 0x01, 0x07, 0x80, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x07, 0x80, 0x80, 0x00, 0xc0, 0x78, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, 0x00, 0x01, 0xf8, 0x00, 0xc0, 0x07, 0xe0, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x1f, 0xe0, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x00, 0x00 }; unsigned long Zeitmessung = 0; void setup() { // Schriften von u8g2 display zuordnen u8g2Schriften.begin(display); // localtime_r -> Zeit in die lokale Zeitzone setzen localtime_r(&aktuelleZeit, &Zeit); // Zeitzone: Parameter für die zu ermittelnde Zeit configTzTime(Zeitzone, Zeitserver); Serial.begin(9600); // auf serielle Verbindung warten while (!Serial); delay(1000); // Bildschirm starten display.init(115200, true, 2, false); display.setRotation(0); // vollständigen Bildschirm nutzen display.setFullWindow(); display.fillScreen(GxEPD_WHITE); WiFi.mode(WIFI_STA); // WiFi starten DHCP WiFi.begin(Router, Passwort); while(WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } do { u8g2Schriften.setCursor(10, 20); u8g2Schriften.setForegroundColor(GxEPD_BLACK); u8g2Schriften.setBackgroundColor(GxEPD_WHITE); u8g2Schriften.setFont(u8g2_font_helvB14_tf); u8g2Schriften.print("WiFi verbunden ..."); u8g2Schriften.setCursor(10, 60); u8g2Schriften.print("aktuelle Zeit holen ..."); } while (display.nextPage()); int Zaehler = 0; // beim Start entspricht das Datum der Unixtime: 1.1.1970 // das Datum soll erst angezeigt werden, wenn es korrekt ist String Jahr = String(Zeit.tm_year + 1900); // String Jahr nach "1970" durchsuchen int Suche = Jahr.indexOf("1970"); // solange die Suche nicht erfolgreich ist // maximal 40 Sekunden while (Suche != -1 && Zaehler < 40) { // aktuelle Zeit holen time(&aktuelleZeit); // localtime_r -> Zeit in die lokale Zeitzone setzen localtime_r(&aktuelleZeit, &Zeit); Jahr = String(Zeit.tm_year + 1900); // String Jahr nach "1970" durchsuchen Suche = Jahr.indexOf("1970"); delay(1000); Zaehler ++; } // Datum/Zeit konnte nicht synchronisiert werden if (Suche != -1) { do { u8g2Schriften.setCursor(10, 80); u8g2Schriften.print("Zeit synchronisieren fehlgeschlagen!"); u8g2Schriften.setCursor(10, 100); u8g2Schriften.print("Programm beendet!!"); } while (display.nextPage()); while(1); } else { // Datum/Zeit erfolgreich synchronisiert do { u8g2Schriften.setCursor(10, 100); u8g2Schriften.print("Zeit synchronisiert ..."); u8g2Schriften.setCursor(10, 140); u8g2Schriften.print(WiFi.SSID()); u8g2Schriften.setCursor(10, 180); u8g2Schriften.print(String(WiFi.localIP().toString())); u8g2Schriften.setCursor(10, 220); u8g2Schriften.print("Signalstärke: " + String(WiFi.RSSI())); } while (display.nextPage()); } // DHT-Sensor starten dht.begin(); delay(3000); Zeitmessung = millis() + 1000; } void loop() { display.fillScreen(GxEPD_WHITE); // Start = true // -> Zeit einmalig synchronisieren if (Start) { Start = false; // Zeit jede Minute mit Zeitserver synchronisieren // aktuelle Zeit holen time(&aktuelleZeit); // localtime_r -> Zeit in die lokale Zeitzone setzen localtime_r(&aktuelleZeit, &Zeit); // Zeit in Stunden, Minuten und Sekunden Stunden = int(Zeit.tm_hour), Minuten = int(Zeit.tm_min), Sekunden = int(Zeit.tm_sec); ZeitAnzeigen(); } // Sekunden weiter zählen if (Zeitmessung < millis()) { Zeitmessung += 1000; Sekunden++; if (Sekunden == 60) { // Zeit jede Minute mit Zeitserver synchronisieren // aktuelle Zeit holen time(&aktuelleZeit); // localtime_r -> Zeit in die lokale Zeitzone setzen localtime_r(&aktuelleZeit, &Zeit); // Zeit in Stunden, Minuten und Sekunden Stunden = int(Zeit.tm_hour), Minuten = int(Zeit.tm_min), Sekunden = int(Zeit.tm_sec); ZeitAnzeigen(); } } } void ZeitAnzeigen() { // Temperatur lesen String Temperatur = String(dht.readTemperature()); // replace -> . durch , ersetzen Temperatur.replace(".", ","); // Luftfeuchtigkeit lesen String Luftfeuchtigkeit = String(dht.readHumidity()); // replace -> . durch , ersetzen Luftfeuchtigkeit.replace(".", ","); // Anzeige aufbauen display.firstPage(); do { u8g2Schriften.setFont(u8g2_font_helvB24_tf); u8g2Schriften.setCursor(100, 30); if (Zeit.tm_mday < 10) u8g2Schriften.print("0"); u8g2Schriften.print(Zeit.tm_mday); u8g2Schriften.print("."); // Monat: führende 0 ergänzen if (Zeit.tm_mon < 9) u8g2Schriften.print("0"); // Zählung beginnt mit 0 -> +1 u8g2Schriften.print(Zeit.tm_mon + 1); u8g2Schriften.print("."); // Anzahl Jahre seit 1900 u8g2Schriften.print(Zeit.tm_year + 1900); u8g2Schriften.setCursor(100, 110); u8g2Schriften.setFont(u8g2_font_fub42_tf); // Stunde: wenn Stunde < 10 -> 0 davor setzen if (Zeit.tm_hour < 10) u8g2Schriften.print("0"); u8g2Schriften.print(Zeit.tm_hour); u8g2Schriften.print(":"); // Minuten if (Zeit.tm_min < 10) u8g2Schriften.print("0"); u8g2Schriften.print(Zeit.tm_min); // x, y, Bild-Array, Breite, Höhe, Farbe display.drawBitmap(5, 1, Kalender, 50, 50, GxEPD_BLACK); display.drawBitmap(5, 70, Uhr, 50, 50, GxEPD_BLACK); display.drawBitmap(15, 140, Thermometer, 34, 70, GxEPD_BLACK); display.drawBitmap(5, 240, Regen, 60, 49, GxEPD_BLACK); // Messdaten anzeigen u8g2Schriften.setCursor(100, 190); u8g2Schriften.print(Temperatur + " °C"); u8g2Schriften.setCursor(100, 280); u8g2Schriften.print(Luftfeuchtigkeit + " %"); } while (display.nextPage()); } |