#include <ArduinoJson.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include "DHT.h"
//#include <XPT2046_Touchscreen.h> //Touchscreen driver
#include "RTClib.h"
RTC_DS3231 rtc;
#define DHTPIN 6
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
char daysOfTheWeek[7][12] = {"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"};
//pins for touchscreen
/*
#define TOUCH_CS 12
#define TOUCH_IRQ 13
XPT2046_Touchscreen ts(TOUCH_CS, TOUCH_CS);
*/
//pins for display
#define TFT_CS 17
#define TFT_DC 15
#define TFT_RST 14
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(9600);
tft.begin();
tft.fillScreen(ILI9341_BLACK);
//ts.begin();
//ts.setRotation(1);
rtc.begin();
dht.begin();
}
void loop() {
/*
if (ts.touched()) {
TS_Point p = ts.getPoint();
Serial.print("x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.println(p.y);
} */
DateTime now = rtc.now();
float pfTemp = dht.readTemperature();
float pfHum = dht.readHumidity();
float a = 17.67;
float b = 243.5;
float alpha = (a * pfTemp)/(b + pfTemp) + log(pfHum/100);
float pfDew = (b * alpha)/(a - alpha);
tft.setCursor(50, 20);
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK); tft.setTextSize(4);
tft.print( pfTemp);
tft.setTextColor(ILI9341_RED, ILI9341_BLACK); tft.setTextSize(4);
tft.println(" C");
tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2);
tft.println(" Temperatur\n");
tft.setCursor(50, 90);
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK); tft.setTextSize(4);
tft.print( pfHum);
tft.setTextColor(ILI9341_RED, ILI9341_BLACK); tft.setTextSize(4);
tft.println(" %");
tft.setTextColor(ILI9341_GREEN); tft.setTextSize(2);
tft.println(" L-Feuchte\n");
tft.setCursor(20, 160);
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK); tft.setTextSize(4);
tft.print(now.hour( ), DEC);
tft.setTextColor(ILI9341_RED, ILI9341_BLACK); tft.setTextSize(4);
tft.print(".");
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK); tft.setTextSize(4);
tft.print( now.minute( ), DEC);
tft.setTextColor(ILI9341_RED, ILI9341_BLACK); tft.setTextSize(4);
tft.print(".");
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK); tft.setTextSize(4);
tft.print( now.second( ), DEC);
/*
tft.setTextColor(ILI9341_BLACK); tft.setTextSize(4); //XXXXXXXXXXXXLeerzeichenXXX
tft.print("99999999"); */
tft.setCursor(15, 210);
tft.setTextColor(ILI9341_CYAN, ILI9341_BLACK); tft.setTextSize(3);
tft.print(daysOfTheWeek[now.dayOfTheWeek()]);
/*
tft.setTextColor(ILI9341_BLACK); tft.setTextSize(4); //XXXXXXXXXXXXLeerzeichenXXX
tft.print("gggggggg"); */
tft.setTextColor(ILI9341_RED, ILI9341_BLACK); tft.setTextSize(3);
tft.setCursor(35, 260);
tft.setTextColor(ILI9341_BLUE,ILI9341_BLACK); tft.setTextSize(3);
tft.print( now.day(), DEC);
tft.setTextColor(ILI9341_RED, ILI9341_BLACK); tft.setTextSize(3);
tft.print(".");
tft.setTextColor(ILI9341_BLUE, ILI9341_BLACK); tft.setTextSize(3);
tft.print( now.month(), DEC);
tft.setTextColor(ILI9341_RED, ILI9341_BLACK); tft.setTextSize(3);
tft.print(".");
tft.setTextColor(ILI9341_BLUE, ILI9341_BLACK); tft.setTextSize(3);
tft.print( now.year(), DEC);
tft.setTextColor(ILI9341_BLACK); tft.setTextSize(4); //XXXXXXXXXXXXLeerzeichenXXX
tft.print("444444");
delay(1000);
}
Loading
pi-pico-w
pi-pico-w