Created
May 6, 2015 02:48
-
-
Save apocas/a17a28e24b31c0405862 to your computer and use it in GitHub Desktop.
dht11
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 8 | |
#define DHTTYPE DHT11 | |
DHT dht(DHTPIN, DHTTYPE); | |
void setup() { | |
Serial.begin(9600); | |
Serial.println("DHT11 Sensor"); | |
dht.begin(); | |
} | |
void loop() { | |
delay(2000); | |
float h = dht.readHumidity(); | |
float t = dht.readTemperature(); | |
if (isnan(h) || isnan(t)) { | |
Serial.println("Failed to read from DHT sensor!"); | |
return; | |
} | |
Serial.print("Humidity: "); | |
Serial.print(h); | |
Serial.print(" %\t"); | |
Serial.print("Temperature: "); | |
Serial.print(t); | |
Serial.println(" *C"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment