As the title says... Chat on...

User avatar
By ErikLem
#37147 After toying around with arduino's for a while, I'm in the process of making the switch to ESP8266 and nodeMCU. I had no problems with most sensors I use, but I'm running into trouble with the DHT11/DHT21

I'm using this library: https://github.com/javieryanez/nodemcu- ... ster/dht22 , but all I get is "Error reading from DHT22" when I try to run the sample.

I noticed that when the sensor is not connected at all, the ESP8266 will reboot, so apparently there's some communication going on when I do connect it.
I've tried it both with a DHT11 and a DHT21 that do work fine when connected to a arduino.

I've also tried it with both a ESP-01 and e ESP-12 (on a nodemcu board), but both give me exactly the same result.

I've also tried this version, but got the same result: https://github.com/nodemcu/nodemcu-firm ... es/dht_lib
I'm using firmware nodemcu_float_0.9.6-dev_20150704.bin and use ESPlorer to upload


any idea where I'm going wrong?
User avatar
By kovales
#37303 +1 Here :) I'got an idea, that *maybe* this sensor requires more than 3.3v (you can find 3.6v as a minimum voltage at some specs), so that's my assumption why it works just fine with 5v Arduino and gives this comm error with NodeMCU board... Today I'll try to supply 5v directly to sensor's VCC

EDIT: Supplying 5V from VCC of devboard to DHT won't solve the problem because it will give 5V at data pin - not a good idea to connect it to ESP I think :(
User avatar
By ErikLem
#37761 I think I found a solution for this problem. It seems that the nodeMCU firmware has a build in library for the DHT sensor.
I am able to get readings by just doing this:

Code: Select allstatus,temp,humi,temp_decimal,humi_decimal = dht.read11(8)
print(status)
print(humi)
print(temp)
print(temp_decimal)
print(humi_decimal)

although I only get proper values for temp and humi, the rest is all 0
User avatar
By LukaszCJokiel
#37908 I've been testing it and DHT22 works with 3,3V works actually from 3V to 6V.
But it seems that using the built in library (the one above) I'm not getting the decimial precision when temperature drops below 0 Celsius. It's OK for positive temperatures, but below 0 - all I got are only full degrees...