-
-
Save bkrajendra/a8f847fc2b4803cae28d5992c6d24fce to your computer and use it in GitHub Desktop.
dht
This file contains hidden or 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
| #include <DHT.h> | |
| #define DHTPIN 15 | |
| #define DHTTYPE DHT22 | |
| DHT dht(DHTPIN, DHTTYPE); | |
| void setup() { | |
| Serial.begin(115200); | |
| dht.begin(); | |
| } | |
| void loop() { | |
| float t = dht.readTemperature(); | |
| float h = dht.readHumidity(); | |
| if (isnan(t) || isnan(h)) { | |
| Serial.println("Sensor error"); | |
| } else { | |
| Serial.printf("T=%.1f°C RH=%.1f%%\n", t, h); | |
| } | |
| delay(2000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment