DHT22 random fake temperature

I tried all sorts of things to get it working reliably, 5V instead of 3.3V, decoupling capacitors at the DHT, every pull-up resistor value between 2K and 10K, cat 6 cable, etc… Nothing improved it. The longer the run the more likely there were errors but even connected to the pi with 5cm leads there were still occasional glitches.

thanks!! and with this component, in addition to wire dht22, what else could be done?

This is a graphic of my situation. at the top the true read, at the bottom the filtered

Thanks for giving me up to play with the wired DHT RPi option. I tested the Esp MQTT solution and worked like charm.
I made small tutorial and article for you guys, to spare you some time, hope it helps someone else:

https://amphibia.gq/2019/01/04/dht22-home-assistant-nodemcu-esphomelib-mqtt-ultimate-setup-tutorial/

Cheers!

The problem is likely the the tight timing required by the sensor interface to the raspberry pi, and not strictly an electrical problem.

Generating low-jitter delays to bit-bang this interface can be difficult on a LInux time sharing system where you have all sorts of other things going on. This is the same reason why driving WS2812 RGB LEDs required heroic efforts to make work. The “one-wire” DS18B20 sensors have a similar sort of issue, but there’s a kernel driver to help with banging that protocol out the 1-wire interface.

Having an ESP8266 or other microcontroller do this job is much easier, as it’s got many few other things it’s also tyring to do at the same time.

I am suffering the same problem as Corrobor with the DHT connected to the RPi running Hassio. In the plot below this sensor is “main level”. I also have a DHT connected to ESP8266 called loft which reports consistently on 5 minute intervals by my code.

Is there any good work-arounds to fix the DHT signal drop issue on the Pi?

Only this:

Well, when I say “only this” you could also try lodging an issue for the component on github:

It seems to be a well repeatable problem.

Since I went to esp8266 solution with esphome I never ever had to think about it anymore, no errors, no bugs - never. I lost few days with the RPi, but it’s probably not meant to work that way.

I implemented the filter that tom_I suggested above and this smooths out the random dropped values. I understand the benefit of reporting temperature via ESP8266 over MQTT (and I do that for the loft temp), but I wanted to add the bonus of measuring temperature directly on the Rpi without another piece of hardware sitting around.

Filter info for reference: https://www.home-assistant.io/components/sensor.filter/

If you only have the one sensor directly connected to the pi it will probably be ok.

I had a whole heap directly connected and at least one sensor would start up with a glitched value - so the radius filter for this sensor started with this wrong value and rejected all the subsequent good values.

So I’d restart, then another sensor would be wrong.

Restart, restart, restart… until eventually all sensors started with unglitched values. It did my head in (and probably didn’t do my SD card any favours either). So I changed to connecting them all via ESPs.

Dear Sirs
I wanted to add this filter on my DHT22 (with resistance ) directly connected to the Rpi without another piece of hardware as @PK_MO did!

I’m using Home Assistant 0.94.3 on Raspbian OS stretch.

My actual settings for DHT22 in the configuration.yaml is:

# Sensor DHT22 temp-Umidon GPIO4:
- platform: dht
  name: DHTSala
  sensor: DHT22
  pin: 4
  temperature_offset: -0.1
  humidity_offset: -3.5
  monitored_conditions:
    - temperature
    - humidity

Sorry, but I’m not able to add the filter on my config.!!!:hot_face:

Could someone attach his complete settings )configuration.yaml file) for the filter and also to ADD the “Hystorical graph” for Humidity and Temperature on the HOME page ?

NOTE: With my simple actual settings, the sensor works and the graph is did on the “register page”! I just want to add filter and historical graph for some days!

When using HA for the DHT22 you dont add the filter to the sensor config. Instead you create another filtered sensor, there are examples here:

e.g. To use an outlier filter to remove spikes create this sensor and use it instead of the original sensor:

  - platform: filter
    name: "Filtered Temperature"
    entity_id: sensor.your_temperature_sensor
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0

To add a lovelace history graph card follow these instructions, there is an example at the bottom of the page

Thanks Sir,
I had already try this:

default_config:

sensor:
- platform: yr

# Sensore DHT22 
- platform: dht
  name: DHTSala
  sensor: DHT22
  pin: 4 
  temperature_offset: -0.1
  humidity_offset: -3.5
  monitored_conditions:
    - temperature
    - humidity
	
- platform: filter
    name: "SalaTemperatura"
    entity_id: sensor.dhtsala_temperature_sensor
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0

But I’m receiving this error:

hass[21737]: 2019-06-19 09:39:40 ERROR (Thread-2) [homeassistant.util.yaml.loader] mapping values are not allowed here
hass[21737]:   in "/home/homeassistant/.homeassistant/configuration.yaml", line 35, column 9
hass[21737]: 2019-06-19 09:39:40 ERROR (MainThread) [homeassistant.bootstrap] 
Error loading /home/homeassistant/.homeassistant/configuration.yaml: mapping values are not allowed here

This usually means your indentation is incorrect. The line numbers point to where. In this case it’s your filtered sensor config. It should be:

- platform: filter
  name: "SalaTemperatura"
  entity_id: sensor.dhtsala_temperature_sensor
  filters:
    - filter: outlier
      window_size: 4
      radius: 4.0

Note the indentation under ‘platform’ compared to yours.

1 Like