Hallo
Wie ist es möglich mehrere DHT22 Sensoren auszulesen und diese an einem TFT anzuzeigen.
Ist dies überhaupt möglich bisher habe ich nur Sketch gefunden für die Anzeige eines Sensors.
Genutzt wird ein MEGA und ein HY-1.8 SPI Display und 3 DHT22
Hat jemand erfahrung mit der maximalen Leitungslänge des DHT ich habe ca. 40m zu überbrücken.
Grundlage für den Sketch wollte ich diesen verwenden.
Muss aber noch gleich dazu sagen das ich noch blutiger Anfänger bin
// DHT11, TinyRTC (DS1307) und 1.8 Zoll TFT-Farb-Display (HY-1.8 SPI)
#include "Adafruit_GFX.h" // Adafruit Grafik-Bibliothek
#include "Adafruit_ST7735.h" // Adafruit ST7735-Bibliothek
#include <SPI.h>
#include <Wire.h>
#
#include <DHT.h>
#define DHTPIN 4 // Zur Messung verwendeter Pin, in unserem Fall also Pin 4
#define DHTTYPE DHT22 // DHT 22
// TFT-Display
#define CS 10 // Arduino-Pin an Display CS
#define DC 9 // Arduino-Pin an Display A0
#define RST 8 // Arduino Reset-Pin
Adafruit_ST7735 tft = Adafruit_ST7735(CS, DC, RST); // Display-Bibliothek Setup
DHT dht(DHTPIN, DHTTYPE); // Initialisieren des DHTs
void setup(void) {
dht.begin(); // DHT starten
// Display
tft.initR(INITR_BLACKTAB); // ST7735-Chip initialisieren
display_show();
}
float temp=1000;
float hum=1000;
float min_temp=1000;
float max_temp=-1000;
float min_humidity=1000;
float max_humidity=-1000;
int tempct=0;
void loop() {
float t;
if(tempct%2==0)t=dht.readTemperature();
else t=bmp.readTemperature();
if(isnan(t)){}
else if((int)t!=(int)temp){
show_temp(temp,true);
temp=t;
if(min_temp>temp)min_temp=temp;
if(max_temp<temp)max_temp=temp;
show_temp(temp,false);
}
tempct++;
float h = dht.readHumidity();
if(isnan(h)){}
else if(h!=hum){
show_hum(hum,true);
hum=h;
if(min_humidity>hum)min_humidity=hum;
if(max_humidity<hum)max_humidity=hum;
show_hum(hum,false);
}
delay(10000);
}
void show_temp(float temp,boolean clear){
int clearcolor=night_mode?ST7735_BLACK:ST7735_WHITE;
int textcolor=night_mode?ST7735_WHITE:ST7735_BLACK;
byte xs=10;
byte ys=36;
String htemp=String((int)temp);
//byte xss=(temp<10?:temp
set_text(xs,ys,htemp,clear?clearcolor:textcolor,3);
set_text(xs+(3*htemp.length()*8),ys,"",(clear?clearcolor:textcolor),2);
tft.write(247); // das °-Zeichen
tft.print("C");
set_text(xs+81,ys+1,String((int)max_temp),clear?clearcolor:ST7735_RED,1);
tft.write(247);tft.print("C");
set_text(xs+81,ys+11,String((int)min_temp),clear?clearcolor:ST7735_BLUE,1);
tft.write(247);tft.print("C");
}
void show_hum(float hum,boolean clear){
int clearcolor=night_mode?ST7735_BLACK:ST7735_WHITE;
int textcolor=night_mode?ST7735_WHITE:ST7735_BLACK;
byte xs=12;
byte ys=96;
set_text(xs,ys,String((int)hum)+"%",clear?clearcolor:textcolor,3);
set_text(xs+81,ys+1,String((int)max_humidity)+"%",clear?clearcolor:ST7735_GREEN,1);
set_text(xs+81,ys+11,String((int)min_humidity)+"%",clear?clearcolor:ST7735_YELLOW,1);
}
DANKE
falls ihr einen Tipp für mich habt
Grüße der Arne