Advertisement
ambersy314

Untitled

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