DHT22 prevent fluctuations

I do have a working dht22 temp sensor with esphome however the temps fluctuate too much. How can I filter out these with esphome?
image

sensor:
  # DHT 22
  - platform: dht
    pin: 18
    model: AM2302
    temperature:
      name: "tep1"
      id: "tep1"
      unit_of_measurement: "°C"
      device_class: "temperature"
      state_class: "measurement"
      accuracy_decimals: 2
      filters:
        - offset: -3.3
        - median:
            window_size: 3
            send_every: 3
            send_first_at: 1
    humidity:
      name: "nep1"
      id: "nep1"
      unit_of_measurement: "%"
      device_class: "humidity"
      state_class: "measurement"
      accuracy_decimals: 2
    update_interval: 5s

I use this:

    update_interval: 15s
    filters:
      - sliding_window_moving_average:
          window_size: 15
          send_every: 15
          send_first_at: 1

Gives a nice smooth update every 3m45s. The cycles you see here are my heating turning on and off:

Untitled

I use a htu21d which is not only cheaper than a dht22 but also more precise/stable (means less fluctuations :warning:) beside using i2c which makes life easier!

There are a whole bunch of other sensors that could be used, but that’s not what they asked. I’ve tried BME280’s, DS18B20s, SHT31D’s, various Xaomi sensors, and even a really high precision TMP117.

Comparing the temperature readings of all those sensors to the TMP117 the DHTs came out on top every time. Both in bang for buck, reliability and accuracy.

Admittedly, buying my sensors from Aliexpress could be half the problem. There seem to be a lot of manufacturer rejects on the market.

My point is that the DHT22 (AM2302) is a perfectly acceptable sensor for indoor measurements.

1 Like

That’s very interesting. For sure a bme280, sht30x or htu21d can’t do wonders but in my experience they are all superior to a dht22.

Also if you look around the internet you will most likely find the dht22 (am2302) always at the last position in terms of accuracy even though it’s more expensive than other (comparable) sensors.

For example the am2302 (dht22) in this example is the one which is most off (like 10-20%)


Test i2c humidity sensors - Arduino - WIKI

I actually had my last dht22 exchanged (couple of years ago) because it was regularly maxing out (showing 95-100% humidity) inside even when the real humidity was like 25% (or more) less.

Yep well aware of those measurements. That’s why I initially went for the SHT31. See this topic;

https://community.home-assistant.io/t/bme280-relative-humidity-wrong/274043/11

My results, measured against a few standards did not match those results at all. https://community.home-assistant.io/t/bme280-relative-humidity-wrong/274043/39

Thanks,
I think I will try this out but with shorter time.

You really don’t need to for indoor temperatures.