Advertisement
Ruddog

TempAndHumdity

Jan 23rd, 2021
1,066
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include "DHT.h"        // including the library of DHT11 temperature and humidity sensor
  2. #define DHTTYPE DHT11   // DHT 11
  3.  
  4. #define dht_dpin 0
  5. DHT dht(dht_dpin, DHTTYPE);
  6. void setup(void)
  7. {
  8.   dht.begin();
  9.   Serial.begin(9600);
  10.   Serial.println("Humidity and temperature\n\n");
  11.   delay(700);
  12.  
  13. }
  14. void loop() {
  15.     float h = dht.readHumidity();
  16.     float t = dht.readTemperature();        
  17.     Serial.print("Current humidity = ");
  18.     Serial.print(h);
  19.     Serial.print("%  ");
  20.     Serial.print("temperature = ");
  21.     Serial.print(t);
  22.     Serial.println("C  ");
  23.   delay(800);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement