Created
November 12, 2020 04:07
-
-
Save kmcallister/54432e0328d8fb0444f77b3cef6c5882 to your computer and use it in GitHub Desktop.
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 2 | |
#define DHTTYPE DHT11 | |
#define PERIOD 5000 | |
DHT dht(DHTPIN, DHTTYPE); | |
void setup() { | |
Serial.begin(9600); | |
dht.begin(); | |
Serial.println(F("# READY")); | |
} | |
void loop() { | |
delay(PERIOD); | |
float h = dht.readHumidity(); | |
float t = dht.readTemperature(); | |
// Check if any reads failed and exit early (to try again). | |
if (isnan(h) || isnan(t)) { | |
Serial.println(F("# ERROR")); | |
return; | |
} | |
Serial.print(t); | |
Serial.print(' '); | |
Serial.println(h); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment