Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <DHT.h>
- #define DHTPIN 6
- #define DHTYPE DHT22
- DHT dht(DHTPIN, DHTYPE);
- void setup(){
- Serial.begin(115200);
- Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
- }
- void loop(){
- Serial.print("DHT22, \t");
- delay(2000);
- // Reading temperature or humidity takes about 250 milliseconds!
- // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
- float h = dht.readHumidity();
- // Read temperature as Celsius
- float t = dht.readTemperature();
- // Read temperature as Fahrenheit
- float f = dht.readTemperature(true);
- Serial.print("Humidity: ");
- Serial.print(h);
- Serial.print(" %\t");
- Serial.print("Temperature: ");
- Serial.print(t);
- Serial.print(" *C ");
- Serial.print(f);
- Serial.println(" *F\t");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement