Advertisement
vawrinekm20

Temp and Humidity Sensor

Jun 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <SimpleDHT.h>
  2. //Matt Vawrinek
  3. //6/18/17
  4. //Temp and Humidity Sensor Basic Code
  5. // for DHT11,
  6. // VCC: 5V or 3V
  7. // GND: GND
  8. // DATA: 2
  9. int pinDHT11 = 3;
  10. SimpleDHT11 dht11; //name of library//
  11.  
  12. void setup() {
  13. Serial.begin(9600);
  14. }
  15.  
  16. void loop() {
  17. // start working...
  18. Serial.println("=================================");
  19. Serial.println("Sample DHT11...");
  20.  
  21. // read without samples.
  22. byte temperature = 0;
  23. byte humidity = 0;
  24. if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
  25. Serial.print("Read DHT11 failed.");
  26. return;
  27. }
  28.  
  29. Serial.print("Sample OK: ");
  30. Serial.print((int)temperature); Serial.print(" *C, ");
  31. Serial.print((int)humidity); Serial.println(" %");
  32.  
  33. // DHT11 sampling rate is 1HZ.
  34. delay(1000);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement