Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <DHT.h>
  2.  
  3. //Constants
  4. #define DHTPIN 2 // 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. 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. //Read data and store it to variables hum and temp
  22. hum = dht.readHumidity();
  23. temp= dht.readTemperature();
  24. //Print temp and humidity values to serial monitor
  25. Serial.print("Humidity: ");
  26. Serial.print(hum);
  27. Serial.print(" %, Temp: ");
  28. Serial.print(temp);
  29. Serial.println(" Celsius");
  30. delay(2000); //Delay 2 sec.
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement