#include #include #include #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif const char *ssid = "xxx"; const char *password = "xxx"; WiFiUDP ntpUDP; U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); const long utcOffsetInSeconds = 3600; char daysOfTheWeek[7][12] = {"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}; String formTime; NTPClient timeClient(ntpUDP, "ptbtime1.ptb.de", utcOffsetInSeconds); void setup(void) { u8g2.begin(); WiFi.begin(ssid, password); timeClient.begin(); } void loop(void) { u8g2.clearBuffer(); // clear the internal memory u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font u8g2.drawStr(0,10,"Hello World!"); // write something to the internal memory u8g2.sendBuffer(); // transfer internal memory to the display delay(5000); timeClient.update(); formTime = ((timeClient.getFormattedTime())+ " "+(daysOfTheWeek[timeClient.getDay()])); char formTime_2[50]; formTime.toCharArray(formTime_2, 50); u8g2.clearBuffer(); u8g2.drawStr(0,40,(formTime_2)); u8g2.sendBuffer(); delay(20000); }