Created
October 20, 2017 08:24
-
-
Save mlsmrc/cd82d4e02d216a3607ae69c97110499f to your computer and use it in GitHub Desktop.
Simple file to check if your DHT11 works well into Arduino/Wemos D1 mini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment