Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include "DHT.h"
  2.  
  3. //Constants
  4. #define DHTPIN 7 // what pin we're connected to
  5. #define DHTTYPE DHT22 // DHT 22 (AM2302)
  6. DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
  7.  
  8.  
  9. //Variables
  10. int chk;
  11. float hum; //Stores humidity value
  12. float temp; //Stores temperature value
  13.  
  14. void setup()
  15. {
  16. Serial.begin(9600);
  17. dht.begin();
  18. }
  19.  
  20. void loop()
  21. {
  22. delay(2000);
  23. //Read data and store it to variables hum and temp
  24. hum = dht.readHumidity();
  25. temp= dht.readTemperature();
  26. //Print temp and humidity values to serial monitor
  27. Serial.print("Humidity: ");
  28. Serial.print(hum);
  29. Serial.print(" %, Temp: ");
  30. Serial.print(temp);
  31. Serial.println(" Celsius");
  32. delay(10000); //Delay 2 sec.
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement