D1mini and dht22 connection

Hi i have a connection problem with my dht22 humidity sensor on my d1mini, i run esp flasher and said that cant get data im connecting the sensor on board temporary but i dont know why cant get data can you see if its right connected the pins?

[21:08:08][C][api:095]: API Server:
[21:08:08][C][api:096]:   Address: room.local:6053
[21:08:32][W][dht:160]: Requesting data from DHT failed!
[21:08:32][W][dht:060]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
[21:08:32][D][sensor:092]: 'Room Temperature': Sending state nan °C with 1 decimals of accuracy
[21:08:32][D][sensor:092]: 'Room Humidity': Sending state nan % with 0 decimals of accuracy

Three things:

  1. check the continuity. Poking headers into a board without soldering them has tripped people up before.
  2. does your dht22 include a pull up resistor on the data line? If not you have to add one. About 4k7 Ohms, though it’s not fussy. Up to 10k usually works.
  3. do not rely on auto detection of DHT sensor type in esphome. Specify the version you have.

You use a bare dht22. Wiring is incorrect, you need pull up resistors

  1. VCC - Connect to 3.3 - 5V power. Sometime 3.3V power isn’t enough in which case try 5V power.
  2. Data out -
  3. Not connected
  4. Ground -

Simply ignore pin 3, its not used. You will want to place a 10 Kohm resistor between VCC and the data pin, to act as a medium-strength pull up on the data line.

Unfortunately i dont have resistor is there another way to make it work?
my sensor is DHT22

No. You need the resistor.

Some other things I stubled upon:

Here:
https://esphome.io/components/sensor/dht.html

is the information you need regarding the Resistor and all other settings.
Take care to set the “model”. The lib can autodetect the sensor, still I found that this was not reliable with my “China” DHT22’s. So setting the model to the right type solves this.

Also: take care which pins you use. There is a nice overview of the GPIO Pins here:

https://tttapa.github.io/ESP8266/Chap04%20-%20Microcontroller.html

Have a look at the “GPIO Overview”. There is a list of which pins might be problematic for certain applications. You can correlate the GPIO naming to the Weemos D1 mini pins here:


(Link to the original article: here)
For safety, try D1 or D2.

Better I/O reference here: ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

From the original photo it looks like he’s connected to D2 which is fine. But it could be D3. Though even if it is D3 it’s not a problem as there is no boot failure going by the log.

This is also very much my experience which is why I mentioned it above:

1 Like

I Think the cables are right , the problem is that i dont have pull up resistor.

1 Like

Finally I bought 10k resistor but i don’t know the correct way to connect vcc between data,its very unstable doesn’t fit.

You have the resistor properly connected between the VCC and the data.
According to the picture it seems to me that the resistor does not have to have a good contact on the pins. I use a resistor which I have soldered and it works well.

Place the resistor directly to the DHT22. The values will also be affected by the cable length
I use this sensor in the bathroom. A UTP cat5 cable with a length of 3 meters soldered resistor 4K7 is connected to it and it works reliably with the node

I tried to put better the resistor on the d1 mini and i get this error:

[21:00:10][W][dht:162]: Requesting data from DHT failed!
[21:00:10][W][dht:060]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
[21:00:10][D][sensor:092]: 'Room Temperature': Sending state nan °C with 1 decimals of accuracy
[21:00:10][D][sensor:092]: 'Room Humidity': Sending state nan % with 0 decimals of accuracy

Your connections aren’t good enough. As you have been told, you need to solder the header pins to the ESP. Then you can either solder the resistor in place or inset it into the breadboard.

Something other to check.
How have you defined the pins in your yaml file.

I know that I had trouble when I used “D2” for the for the D1mini in the yaml file.
I checked my d1 mini and I use “4” (that’s the gpio number for d2) with my dht22.

But I also had problem with the pull up resistor.

Hope you solve it.

Hello, I have the same problem. The weird thing is that before I flashed my esp32 for the last time, the sensors were working perfectly (dht11 and soil mosture). After the last time I flashed it, they stopped working. I am going to apply the advice I read in this thread but why were they working before and now they are not?

Well, none of us have a crystal ball, so start with posting your config and log files :slight_smile:. Also explain “stop working”. Do they report the values in the log file and not in HA, are they still online in the dashboard, which version (the exact number, not something like “the latest”) of HA and ESPHome are you using. Did you check what info you get when you click on the device in the integration panel. etc.