/************************************************************************************************* PROGRAMMINFO ************************************************************************************************** Funktion: ESP32 TFT 1.77" RTC ************************************************************************************************** Version: 18.02.2023 ************************************************************************************************** Board: ESP32vn IoT UNO ************************************************************************************************** Libraries: https://github.com/espressif/arduino-esp32/tree/master/libraries C:\Users\User\Documents\Arduino D:\gittemp\Arduino II\A156_Wetterdaten_V3 ************************************************************************************************** C++ Arduino IDE V1.8.19 ************************************************************************************************** Einstellungen: https://dl.espressif.com/dl/package_esp32_index.json http://dan.drown.org/stm32duino/package_STM32duino_index.json http://arduino.esp8266.com/stable/package_esp8266com_index.json Verdrahtung: ESP32 1.77" TFT Display GND GND 5V VCC 18 SCK 23 SDA (MOSI) 14 RES (RST) 13 RS (DC) 12 CS 3.3V LEDA RTC -> G, V, SCL, SDA **************************************************************************************************/ #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif #include #include "RTClib.h" RTC_DS3231 rtc; char daysOfTheWeek[7][12] = { "Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag" }; // New background colour #define TFT_BROWN 0x38E0 // Pause in milliseconds between screens, change to 0 to time font rendering #define WAIT 2000 #include // Graphics and font library for ST7735 driver chip #include TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h unsigned long targetTime = 0; // Used for testing draw times void setup(void) { Serial.begin(115200); rtc.begin(); rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); /* To manualy set date and time, remove the coment // signs and enter new values in the followingline in this sequence: year, day, month, hour, minute and second.*/ //rtc.adjust(DateTime(2020, 2, 24, 10, 00, 0)); tft.init(); tft.setRotation(1); tft.fillScreen(TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK); //weiss } void loop() { DateTime now = rtc.now(); //********* TFT ***************** tft.setTextSize (3); //---------- Seite 1 ---------------------------- tft.drawString((daysOfTheWeek[now.dayOfTheWeek()]), 15, 2); //Datum tft.setTextSize (2); if (now.day() < 10) { tft.print("0"); tft.setCursor (18, 30); tft.print(now.day()); } else { tft.setCursor (18, 30); tft.print(now.day(), DEC); } tft.print("."); if (now.month() < 10) { tft.print("0"); tft.print(now.month()); } else { tft.print(now.month(), DEC); } tft.print("."); tft.print(now.year(), DEC); //Uhrzeit tft.setTextColor(0xFBE0, TFT_BLACK); tft.setTextSize (3); tft.setCursor(5, 60); if (now.hour() < 10) { tft.print("0"); tft.print(now.hour()); } else { tft.print(now.hour(), DEC); } tft.print(':'); if (now.minute() < 10) { tft.print("0"); tft.print(now.minute()); } else { tft.print(now.minute(), DEC); } tft.print(':'); if (now.second() < 10) { tft.print("0"); tft.print(now.second()); } else { tft.print(now.second(), DEC); } //Temperatur tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextSize (2); tft.setCursor(40, 95); tft.print(rtc.getTemperature(), (1)); tft.print("\xF7""C"); }