I have one and have it connected to the ESP8266-01 and that to HASS.IO. I can see the sensor in HASS but I’m having trouble reading values from the DHT-11
When doing an OTA update, the ESPHomeAPI responds (addresses obfuscated):
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.0.XXX using esphomelib API
INFO Connecting to 192.168.0.XXX:6053 (192.168.0.XXX)
WARNING Couldn't connect to API (Error connecting to 192.168.0.XXX: timed out). Trying to reconnect in 1 seconds
INFO Connecting to 192.168.0.XXX:6053 (192.168.0.XXX)
INFO Successfully connected to 192.168.0.XXX
[09:34:17][I][application:097]: You're running esphomelib v1.10.1 compiled on Feb 10 2019, 08:49:24
[09:34:17][C][wifi:341]: WiFi:
[09:34:17][C][wifi:240]: SSID: 'MyWiFi'
[09:34:17][C][wifi:241]: IP Address: 192.168.0.XXX
[09:34:17][C][wifi:243]: BSSID: DE:AD:F0:0D:90:B9
[09:34:17][C][wifi:245]: Hostname: 'esp8266_001'
[09:34:17][C][wifi:250]: Signal strength: -46 dB \u2582\u2584\u2586\u2588
[09:34:17][C][wifi:251]: Channel: 9
[09:34:17][C][wifi:252]: Subnet: 255.255.255.0
[09:34:17][C][wifi:253]: Gateway: 192.168.0.YYY
[09:34:17][C][wifi:254]: DNS1: 0.0.0.0
[09:34:17][C][wifi:255]: DNS2: 0.0.0.0
[09:34:17][C][logger:099]: Logger:
[09:34:17][C][logger:100]: Level: DEBUG
[09:34:17][C][logger:101]: Log Baud Rate: 115200
[09:34:17][C][sensor.dht:035]: DHT:
[09:34:17][C][sensor.dht:036]: Pin: GPIO2 (Mode: OUTPUT)
[09:34:17][C][sensor.dht:042]: Model: DHT22 (or equivalent)
[09:34:17](Message skipped because it was too big to fit in TCP buffer - This is only cosmetic)
[09:34:17][C][sensor.dht:047]: Temperature 'Living Room Temperature'
[09:34:17][C][sensor.dht:047]: Unit of Measurement: '\xb0C'
[09:34:17][C][sensor.dht:047]: Accuracy Decimals: 1
[09:34:17][C][sensor.dht:048]: Humidity 'Living Room Humidity'
[09:34:17][C][sensor.dht:048]: Unit of Measurement: '%'
[09:34:17][C][sensor.dht:048]: Accuracy Decimals: 0
[09:34:17][C][sensor.dht:048]: Icon: 'mdi:water-percent'
[09:34:17][C][api:072]: API Server:
[09:34:17][C][api:073]: Address: 192.168.0.XXX:6053
[09:34:17][C][ota:129]: Over-The-Air Updates:
[09:34:17][C][ota:130]: Address: 192.168.0.XXX:8266
[09:34:19][D][api:531]: Client 'Home Assistant 0.87.0 (192.168.0.ZZZ)' connected successfully!
[09:34:56][W][sensor.dht:141]: Requesting data from DHT failed!
[09:34:56][W][sensor.dht:076]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
I’ve tried the other GPIO pins and they also don’t work. I’ve tried researching pull up resistors in this config but have drawn a blank so any suggestions for getting this sorted would be very welcome!
The circuit diagram on that product page is useless. It’s for a relay board not a DHT sensor. The video does show the correct diagram and the DHT connected to GPIO2. The video also shows a jumper on the back of the pin header shorting two pins. Unless you speak Russian you might have to do a bit of reverse engineering to work out why.
Also try specifying the DHT model in your config. and add a filter as well to smooth out the readings (this will still update every 60sec like your original but it will be the average of 15 readings taken 4 sec apart):
I have a bunch of these deployed but I wrote my own firmware which responds via SNMP and HTTP JSON.
Looking at my code, the DHT11 is on GPIO2.
Had these working in Tasmota as well.
One thing to note is that you’ll find the temperature measurements are wrong as the DHT11 will measure the heat generated by the board components, conducted up via the leads. I had to separate all my DHT11 sensors with a few inches of wire to prevent this.
Also, get the DHT22 version. The DHT11 humidity measurement tops out at 88%, and it doesn’t go below 0C. I’m waiting for my DHT22 sensors to arrive and will be replacing all my DHT11s.
Thank you - yes, I identified GPIO2 as the one in use and it is working.
I did wonder about the temperature rise - I’ll do as you suggest and lengthen the leads. My use case doesn’t really need >88% RH so I’ll probably stick with the DHT11s I have but any future ones will be DHT22s.
Personally I’m now giving up on DHTxx sensors. They suck. Doesn’t matter which library I use, randomly the sensor will stop giving data. Might run for months and then one day the sensor just returns a big negative number (max float?) and will do so until a power cycle.
I have 8 of these sensors (DHT22) that have been running for over a year and have never seen that behaviour. I haven’t updated my ESPs for quite a while either though. Maybe it’s a fault with a newer version of esphome. Or maybe you are reading them too fast? I only update every 15 seconds with a 15x sample moving average. 3-4 minute update is plenty fast enough for house temperatures/humidities.
I am currently having a nightmare with my setup in so far as I can get 1 dht11 working with a relay and 4 other relays just to switch on off in the interface via mqtt.
If I add a second dht11 (all running individually on tasmota esp01s) then I draw a blank and can’t even switch the relay anymore (only via tasmaota web interface).
On these boards, I’m not using esphome (actually I don’t use esphome on anything) nor TASMOTA. I wrote my own firmware that provides temp data via SNMP and an HTTP REST API. The communication with the DHT sensor happens via the often used libraries. Have used ESP_DHT, the Adafruit libraries, etc. in troubleshooting this with the same result.
The interesting part is that it is definitely the senor which becomes unresponsive. The DHT library just returns a large negative number (maxint?), which by my code ends up being rounded to -0.1, which is returned to Home Assistant. The ESP8266 is up and running, just receiving improper values from the library. A reset of the ESP8266 via the reset button resets the processor, however the sensor continues to be unresponsive. Only a power cycle brings it back.
I’m reading the sensor every 10 seconds in code, and when queried the board simply returns the last read value.
I believe that the issue is the long wires to which I have attached the DHT sensors. Because the DHT11 was reading the temperature of the board, I added about 12" of wire between the board and DHT. I’ve had one of these sensors running for over a month on TASMOTA, unmodified (no wire) and it has been reliable. I’m thinking at this point the DHT sensor needs a capacitor across the power pins.
Have noticed that the DHT11 version of the board reads the temperature of the board, but the DHT22 version does not. Looks like the DHT22 sensor has better isolation between the thermistor and board. Yay.
Yep. Wire length makes a huge difference. Originally I tried 1m of Cat5. So many errors. It wasn’t until I had the wire length under 5cm that they started behaving correctly 100% of the time. I tried all sorts of decoupling on the supply and every E24 resistor value between 2K and 10K for the data line resistor. The only thing that made a difference was the wire length.
Hi Aaron,
Sorry for the late reply, I seem to have solved my dilemma with tasmota. In the console for each device I typed “setoption19 1” which turns on automatic discovery. Now they all work flawlessly!
Thanks for the offer of assistance anyway,
Cheers
Kev
[14:21:10][C][wifi:415]: WiFi:
[14:21:10][C][wifi:283]: SSID: [redacted]
[14:21:10][C][wifi:284]: IP Address: 192.168.2.59
[14:21:10][C][wifi:286]: BSSID: [redacted]
[14:21:10][C][wifi:287]: Hostname: ‘temp’
[14:21:10][C][wifi:291]: Signal strength: -53 dB ▂▄▆█
[14:21:10][C][wifi:295]: Channel: 11
[14:21:10][C][wifi:296]: Subnet: 255.255.255.0
[14:21:10][C][wifi:297]: Gateway: 192.168.2.1
[14:21:10][C][wifi:298]: DNS1:
[14:21:10][C][wifi:299]: DNS2:
[14:21:10][C][logger:175]: Logger:
[14:21:10][C][logger:176]: Level: DEBUG
[14:21:10][C][logger:177]: Log Baud Rate: 115200
[14:21:10][C][logger:178]: Hardware UART: UART0
[14:21:10][C][dht:017]: DHT:
[14:21:10][C][dht:018]: Pin: GPIO0 (Mode: INPUT)
[14:21:10][C][dht:022]: Model: DHT11
[14:21:10](Message skipped because it was too big to fit in TCP buffer - This is only cosmetic)
[14:21:10](Message skipped because it was too big to fit in TCP buffer - This is only cosmetic)
[14:21:10][C][api:095]: API Server:
[14:21:10][C][api:096]: Address: temp.local:6053