Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <DHT.h>
  2.  
  3. #define DHTPIN 2
  4. #define DHTTYPE DHT22
  5. DHT dht(DHTPIN, DHTTYPE);
  6.  
  7.  
  8. int chk;
  9. float hum;
  10. float temp;
  11.  
  12. void setup()
  13. {
  14. Serial.begin(9600);
  15. dht.begin();
  16.  
  17. }
  18.  
  19. void loop()
  20. {
  21. hum = dht.readHumidity();
  22. temp= dht.readTemperature();
  23.  
  24. Serial.print("Humidity: ");
  25. Serial.print(hum);
  26. Serial.print(" %, Temp: ");
  27. Serial.print(temp);
  28. Serial.println(" Celsius");
  29. delay(2000); //Delay 2 sec.
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement