Guest User

Untitled

a guest
Oct 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <dht11.h>
  2. #define DHT11_PIN D2
  3.  
  4. dht11 dht;
  5.  
  6.  
  7. void setup() {
  8. Serial.begin(115200);
  9.  
  10. }
  11.  
  12. void loop() {
  13. int chk = dht.read(DHT11_PIN);
  14. Serial.print("Sensor return code: ");
  15. Serial.println(chk);
  16.  
  17. Serial.print("Read sensor: ");
  18. switch (chk)
  19. {
  20. case DHTLIB_OK:
  21. Serial.println("OK");
  22. break;
  23. case DHTLIB_ERROR_CHECKSUM:
  24. Serial.println("Checksum error");
  25. break;
  26. case DHTLIB_ERROR_TIMEOUT:
  27. Serial.println("Timeout error");
  28. break;
  29. default:
  30. Serial.println("Unknown error");
  31. break;
  32.  
  33. }
  34.  
  35. Serial.print("Temperature: ");
  36. Serial.println(dht.temperature);
  37. Serial.print("Humidity: ");
  38. Serial.println(dht.humidity);
  39.  
  40. delay(2000);
  41.  
  42. }
Add Comment
Please, Sign In to add comment