Last active
April 1, 2019 08:55
-
-
Save janhajk/4dfb8495c25f803e466f4bb9f06f7f5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* ShopOfThings.ch | |
* | |
* Beispiel für DHT22 mit ESP32 DEVKITV1 Entwicklungsboard | |
* | |
* Pinverbindung: | |
* | |
* + > 3V3 | |
* - > GND | |
* out > D23 | |
* | |
* Arduino IDE "Upload" drücken und dabei "BOOT"-Knopf drücken | |
* bis es unten Connecting......______...... heisst | |
* dann sofort BOOT-Knopf loslassen und der Upload sollte beginnen | |
* Ctrl-Shift-M zeigt Serial Monitor wo die Ausgabe stattfindet | |
* | |
*/ | |
#include "DHT.h" | |
#define DHTPIN 23 // GPIO23 / D23 | |
#define DHTTYPE DHT22 | |
DHT dht(DHTPIN, DHTTYPE); | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(F("DHT22 test!")); | |
dht.begin(); | |
} | |
void loop() { | |
delay(2000); | |
float h = dht.readHumidity(); | |
float t = dht.readTemperature(); | |
if (isnan(h) || isnan(t)) { | |
Serial.println(F("Fehler beim Lesen des FHT22 Sensors!")); | |
return; | |
} | |
float hic = dht.computeHeatIndex(t, h, false); // Hitzeindex = gefühlte Temperatur | |
Serial.print(F("Feuchtigkeit: ")); | |
Serial.print(h); | |
Serial.print(F("% Temperatur: ")); | |
Serial.print(t); | |
Serial.print(F("°C ")); | |
Serial.print(F(" Hitzeindex: ")); | |
Serial.print(hic); | |
Serial.println(F("°C ")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment