ESp8266-01 and DHT11 board - configuration question

Has anyone successfully used a “DHT11 Temperature Module and Humidity Shiled Board Temp Sensor Module for ESP8266 ESP-01/ ESP-01S” with ESPHome?

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).

The config in esp8266_002.yaml file is:

esphomeyaml:
  name: esp8266_001
  platform: ESP8266
  board: esp01_1m
wifi:
  ssid: 'MyWiFi'
  password: 'password_goes_here'
  manual_ip:
    static_ip: 192.168.0.XXX
    gateway: 192.168.0.YYY
    subnet: 255.255.255.0
  
# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

sensor:
  - platform: dht
    pin: GPIO2
    temperature:
      name: "Living Room Temperature"
    humidity:
      name: "Living Room Humidity"
    update_interval: 60s

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!

1 Like

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):

sensor:
  - platform: dht
    pin: GPIO2
    model: DHT11
    update_interval: 4s
    temperature:
      name: "Living Room Temperature"
      filters:
        - sliding_window_moving_average:
            window_size: 15
            send_every: 15
            send_first_at: 15
    humidity:
      name: "Living Room Humidity"
      filters:
        - sliding_window_moving_average:
            window_size: 15
            send_every: 15
            send_first_at: 15
5 Likes

Thank you, Tom, I’ll give that a go. Yeah, my lack of Russian was a real limiting factor!

I’ll report back shortly.

Tom, thank you - that sorted it. No jumper required - it now works perfectly!

Thanks again!

1 Like

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.

Thanks.

I am using the above configuration with model: DHT22 and I am getting these errors:

[09:54:15][W][sensor.dht:147]: Requesting data from DHT failed!
[09:54:15][W][sensor.dht:077]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
[09:54:19][D][sensor.dht:067]: Got Temperature=29.4┬░C Humidity=97.7%
[09:54:23][W][sensor.dht:147]: Requesting data from DHT failed!
[09:54:23][W][sensor.dht:077]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
[09:54:27][W][sensor.dht:147]: Requesting data from DHT failed!
[09:54:27][W][sensor.dht:077]: Invalid readings! Please check your wiring (pull-up resistor, pin number).

Is that normal?

It is sending correct readings on the esp_dht_sensor/sensor/living_room_humidity/state topics.

No that is not normal.

1 Like

thanks just been having the same issues saved a new thread

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.

Going to switch everything out with BME280s.

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.

The BME is a better sensor though.

Hi all,

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).

Any ideas would be welcome,

Thanks.

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.

Can you post a bit of info about your setup? Pictures of the relays/DHT connections, TASMOTA config, and your YAML config.

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.

Well then looks like I have some wires to shorten.

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

Help is all i can say cant get this to work

esphome:
name: temp
platform: ESP8266
board: esp01_1m

wifi:
ssid: “Wireless”
password: “0000000”

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Temp Fallback Hotspot”
password: “xxxx”

captive_portal:

Enable logging

logger:

Enable Home Assistant API

api:

ota:

sensor:

  • platform: dht
    pin: GPIO0
    model: DHT11
    update_interval: 4s
    temperature:
    name: “Living Room Temperature”
    filters:
    - sliding_window_moving_average:
    window_size: 15
    send_every: 15
    send_first_at: 15
    humidity:
    name: “Living Room Humidity”
    filters:
    - sliding_window_moving_average:
    window_size: 15
    send_every: 15
    send_first_at: 15

Tried every pin number

and every DHT as the one i have is a 22

[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