ESP home esp32, DHT sensors dropping out

Hello.
I’ve tried a few, but I think I need a pointer now.
I’ve got 3 esp32 running 2 x Dht22 (am2302) each, and 2 relays.
It all was working for a few hour, and then sensors dropped out… Not aways the same sensor missing… Suddenly I had just reading from 2-3 sensors

I’ve tried adding pullup resistor at the sensor end (never had issues with other sensors around the house)
I used first cat6 cables, changed to better cable 1,5mm (thick for this I think, but ok)
Still no luck. Tried giving id to each sensor. Kinda starting to wonder if some pins om my esp32 wroom 32, don’t like dht? Can’t find the page, but I recall seeing a page sometime about some pins are better and some aren’t better suited for some connections🤔

Code in ESP Home:
esphome:
  name: leviatan
  platform: ESP32
  board: esp-wrover-kit

wifi:
  ssid: "redacted"
  password: "redacted"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "redacted"
    password: "redacted"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "redacted"

ota:
  password: "redacted"

sensor:
  - platform: dht
    model: AM2302
    pin: 22
    temperature:
      name: "leviatan hot"
    humidity:
      name: "leviatan hot1"
    update_interval: 60s
  - platform: dht
    model: AM2302
    pin: 5
    temperature:
      name: "leviatan cold"
    humidity:
      name: "leviatan cold1"
    update_interval: 60s
    
switch:
  - platform: gpio
    pin: GPIO27
    name: "Relay #1"
  - platform: gpio
    pin: GPIO12
```code

using 10K pullup.
as i think of it, don’t think the relays dropped out…

And the LOGFILE prints the usual Error, asking for wiring, and pullup.
And it is correct, and it does sometimes work, and sometimes not, after restart.

How long are your cables to the DHT?

approx 1meter

I’ve never had any luck over 10cm.

1 Like

Have you tried swapping the DHT’s with the ones that work all the time?
Do you have an ESP32 that has been stable? Tried swapping that in?
Have you tried making the connections really short just to rule out EMI (interference)?
Is the wire or sensor or ESP32 anywhere close to anything else electrical?

Are these sensors sensitive to EMI?
I’ve got a few in my house without pullup, in the middle of cluster of buck converters, esp, and other sensors working flawlessly.

I’m trying to monitor hotplate in my terrarium, so it’s its on top of, and cable running next to 230v ac lines

Distances from the 240V cable: 150mm for electrical regulations separation (in Aus). 600mm recommended for EMI separation, preferably run at right angles rather than parallel.

No DHT sensor has ever been reliable for me with a cable over a few CM in length at 3V. Maybe slightly longer at 5V.

running the DHT at 5V

I kinda might bite the dust, and get LM35 or any tips appreciated

DS18B20 might be a candidate…

but seems like i have to order from china…
These days…that is kinda a loong wait…
.

5V… hopefully you have a divider, buffer or something else to get that signal down to 3v3.

I like and prefer dht22’s for the $… dallas are also great but those won’t give you humidity (otoh, they’re excellent for ‘long wires’, can be polled faster, are more accurate, and respond quicker to changes… I prefer them whenever humidity is not needed). The long wire thing is going to limit your choices of what will work (rule out i2c and dht for example). If the wires get really long, you might consider using a uart sensor with an rs485 bus (rs485 is designed for very long wires). If you also need or may eventually want pressure, the bme280 is an excellent choice for temp/humid/pressure. I’ve no personal experience with the LM35, but like I said the driver of your choice is likely going to be your wire length; so educate yourself on expected performance for various protocols and wire lengths (for example, is i2c or uart more noise tolerant… how will data rate, voltage, utp vs non cables, etc… limit performance?).

…and definitely don’t wire up any 5V logic to an esp32 or esp8266 (unless it’s one of those rare and expensive jobs with level shifting on board).

1 Like

A handful of notes:

  • Definitely need a pullup resistor for reliable signals - can sometimes work without, but if it does work you will likely get intermittent issues. If currently (pun intended) using 10k, you might want to try 4.7k.
  • The individual wires in Cat5/6 cable are pretty weedy - what I sometimes do if using that is I’ll join two or more of the wires together to effectively make a thicker cable. Solid core is also usually better although not as flexible. Ideally solder too to make sure the joins are good so you avoid intermittent drop outs.
  • If you don’t need the humidity reading, I really like the DS18B20 jobs that come sealed in a steel tube and have a nice length of cable already attached - accurate, easy to daisy chain, and weather sealed. I used them in fridge/freezers for example.

Cheers

1 Like

I use these atm. 3.3v is what it is, but Vin takes quite higher volt… 5v is OK. It gets hot when going 12v.
esp12 is another issue. Only 3.3vmax.
Trouble is I’ve got nothing else than the dht22 at home…
Any way to use a standard cheap indoor/outdoor sensor? Just the outside sensor? Guess they are the 2wire resistor kind… Will probably be less accurate?

I’ve been replacing all my DHTs with BMP280s (temp/humid/pressure). Haven’t had any issues so far running them on cat5 at about 1M in length. The breakout boards typically contain a 3.3V regulator so they can be powered at 5V and this heats the board. Power from 3.3V and solder blob over the regulator (or remove it and short the in/out pads). For longer distances there are I2C buffers which can go a long way.

1 Like

Not any less accurate necessarily… it depends on how you calibrate it and which ADC you use. In a lab, often a manually calibrated thermocouple is the go to instrument. I think that’s the biggest problem with such things… they require calibration so we usually use fancy digital stuff that’s easy to calibrate or comes factory calibrated.

1 Like

3.3v or 5v will be fine. Pumping up to 12V into Vin is usually fine (although generally I’d max out at 9V to be safe) but the regulator means you won’t get more out of the 3.3v or 5v out pins. The DHT22’s should be fine with either (and I’d usually use 3.3v), but definitely try a 4.7k pullup if the 10k isn’t working for you. Keep in mind that quality control can vary with both resistors and DHTs so there’s always the chance of getting a faulty batch of either. Or even misreading the resistor. Easy to check though - if the 4.7k doesn’t fix it, then I’d try using a shorter wire and seeing if it makes a difference…

1 Like