DHT22 sensor wire length with ESP32?

Are you powering the DHT with 5v or 3v3? I cannot tell

I have it running off 5v in this instance.

So, you’re powering the DHT with 5V and get data using a level shifter? Or it is not necessary to use one?

I simply have it plugged in to the 5V pin on the esp. I am pretty sure the DHTs I have are either 3.3 or 5v. I have only used the 5v pin on the longer cable test. Otherwise I use the 3.3v pin. Either way it works.

@dmayne Could you provide an update on your project? I am looking to do something similar for a wood kiln temp/humidity sensor. I’ve actually already built one sensor and it worked great at first but now reports invalid reading from the DHT22. If I unplug power to the ESP32 it came back for a bit but then started invalid again. @AaronCake can you share how you wired them to be able to power cycle the sensor from the esp controller?

I power the DHT22 sensor directly from one of the MCU pins. Longer wire runs should use isolation ot use a transistor (2N3904/2N2222) on the low side of the DHT22.

I am an ESP and hardware/electrical noob. I have my the DHT22 wired directly to the esp32 using cat 5 cable (approx 8ft). Could you explain what the transistor does and how I would wire that in? I had read elsewhere online that a 4.7k Ohm Resistor should be wired in but then saw that the DHT22 with 3 pins that I have actually has the resistor already in it? I had just wired it up directly and it worked at first but now getting the invalid readings so am wondering if I need to fix the wiring or the power. Sorry for the basic questions, I am trying to learn all of this.

Here’s a schematic of what I am referring to:
DHT

The transistor is used to switch the DHT sensor on/off to power cycle it in the event it stops responding.

The proper resistor for the DHT sensor is 10K. If you have a module, it may already include this resistor. If you just have the raw sensor (in the white case), then it doesn’t include the resistor. A picture of your setup would help.

With the schematic I showed, your code must enable the GPIO power pin to turn on the sensor, then toggle it if the sensor stops responding.

Thank you. Here is a simple diagram of how I have mine wired. I just pulled the power on the esp board and the dht22 came back for a few hours but is now reporting no data again. I’d love to get this stable and would appreciate any help!

It’s unclear from that picture whether the DHT sensor module includes a resistor and filter capacitor. Check the back of the board.

At the very least it needs the pullup resistor between VCC and Data.

And a small value capacitor across the + and - (10uF) helps.

But my experience has been that at 3.3V, with any length of cable, the DHT sensor is unstable.

So best bet would be to use the arrangement I showed to enable the ESP board to power cycle the DHT.

Or, use a better sensor like the BME280 which uses the I2C bus and is stable at 3.3V.

1 Like

Thank your for your patience with me. I don’t know how to tell if it has a resistor built-in. I found varying answers online. Here is a picture and the link to the sensor on Amazon. https://www.amazon.com/gp/product/B07XBVR532

Description says built in pullup resistor, so should be there. There also appears to be a small filter capacitor (beige component). But you can also try a large one of about 10uF - 100uF (exact value unimportant) across the power supply pins.