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:


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:


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.

Not looking for support, just sharing my own experience with this very weird issue. Using a D1 Mini, two switches: Pin D4 for testing the board operation and D8 to turn on a light. Two sensors: D6 as a working DHT22 sensor and D7 as a faulty DHT22 sensor. Basic templates in use, no fancy code in any way. Everything works except D7, which every time it is manually reconnected, starts working normally and after a few hours it just reports a static value. This one has an extension cable of around 30 cm (CAT 5 cable, soldered to the board) and a 470K resistor between + and signal, also soldered, right next to the sensor. As mentioned before, I have to get the sensor manually disconnected to start sending data. Once it starts operation it sends weird temperatures and RH (for example 1 degree celsius and 4% HR where all the other sensors I have are around 20 celsius and 60% HR). After reinstalling or uploading the unchanged code to the D1 mini, those temperatures get changed to acceptable values, but then after a while the values remain unchanged and I have to repeat the same process to set the sensor and try to make it work again. I have replaced and switched the sensors several times without any changes, I installed mqtt and the D7 temperature sensor won’t send data (if that info is useful for something). It just makes no sense that everything else works fine, so what I’m going to try is to clone the exact same module switching pins to different numbers, to see if there’s any difference, since this one is very difficult to troubleshoot because is sitting inside the ceiling. As I was testing it before deploying to the ceiling it was working just fine, which also does not make sense. That’s the most detailed info I can provide so far, hoping it sheds a light on the issue. The error reported on esphome is: “Invalid readings! Please check your wiring (pull-up resistor, pin number) and consider manually specifying the DHT model using the model option.” Happy troubleshooting.