Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <dht11.h>
- #define DHT11_PIN D2
- dht11 dht;
- void setup() {
- Serial.begin(115200);
- }
- void loop() {
- int chk = dht.read(DHT11_PIN);
- Serial.print("Sensor return code: ");
- Serial.println(chk);
- Serial.print("Read sensor: ");
- switch (chk)
- {
- case DHTLIB_OK:
- Serial.println("OK");
- break;
- case DHTLIB_ERROR_CHECKSUM:
- Serial.println("Checksum error");
- break;
- case DHTLIB_ERROR_TIMEOUT:
- Serial.println("Timeout error");
- break;
- default:
- Serial.println("Unknown error");
- break;
- }
- Serial.print("Temperature: ");
- Serial.println(dht.temperature);
- Serial.print("Humidity: ");
- Serial.println(dht.humidity);
- delay(2000);
- }
Add Comment
Please, Sign In to add comment