Tips on choosing a humidity sensor and IoT connection protocol?

I’m looking to buy a humidity sensor for my bathroom. All of my existing devices connect to HA over WiFi (except my Hue hub of course) but it seems that WiFi devices are often the most expensive and I’m a little overwhelmed with the other kinds (z wave, Zigbee, ble, etc) of IoT devices and their nuances. Any pointers?

Sincerely,
Analysis Paralysis

DHT22 + Wemos D1 Mini running ESPhome will cost you less than $15.

They are extremely easy to set up. Read the ESPhome getting started page and the ESPHome DHT22 sensor page.

No programming cable required. Just a USB A to USB mini cable.

Example of a configuration file:

esphomeyaml:
  name: bathroom_dht
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: 'WAPDI'
  password: !secret wifi_pwd
  manual_ip:
    static_ip: 10.1.1.70
    gateway: 10.1.1.1
    subnet: 255.255.255.0


mqtt:
  broker: 10.1.1.100
  username: !secret mqtt_usr
  password: !secret mqtt_pwd

logger:
  level: WARN

ota:
  password: !secret esp_pwd

binary_sensor:
  - platform: status
    name: "Bathroom DHT Status"

sensor:
  - platform: wifi_signal
    name: "Bathroom DHT WiFi Signal"
    update_interval: 15s
    filters:
      - sliding_window_moving_average:
          window_size: 15
          send_every: 15
          send_first_at: 15

  - platform: dht
    pin: D5
    model: DHT22
    update_interval: 15s
    temperature:
      name: "Bathroom Temperature"
      filters:
        - sliding_window_moving_average:
            window_size: 15
            send_every: 15
            send_first_at: 15
    humidity:
      name: "Bathroom Humidity"
      filters:
        - sliding_window_moving_average:
            window_size: 15
            send_every: 15
            send_first_at: 15

These things are so cheap and easy to make you’ll put them everywhere. They are super reliable too. Add your case of choice and a 5V power supply and all up it should cost you less than $30.

2 Likes

Thanks Tom, those do look pretty neat and I especially like that they connect to WiFi. I’ve read through all your links and am having trouble understanding all the hardware pieces and DIY, but I guess that makes it a good weekend project!

You might also want to look at the Sonoff TH10, it is essentially what is described above but with a case and built in power supply all for $7.50. You can use the custom ewelink component or flash it to use the standard MQTT component.

Maybe the shelly t&h? It’s a wifi sensor for only 24 euro

+ $4.30 for the sensor.

Hey thanks for the help everyone! I haven’t had much time to look into this since my last post so I’m just getting back to it now.

@tom_l, thanks a lot for such a great post.

I came to the same hardware/software config for my bathroom extractor fan automation.
A few questions:

  1. Are you still using MQTT, I believe it’s much more interesting to use native mode?
  2. I’m mainly interested in humidity level and here is my sensor config (after brief reading of docs)
  - platform: dht
    pin: D1
    model: dht22
    update_interval: 10s
    temperature:
      name: "bathroom_shower_temperature"
    humidity:
      name: "bathroom_shower_humidity"
      filters:
        - filter_nan:
        - exponential_moving_average:
            alpha: 0.5
            send_every: 3

The downside of this approach is in HA I get one reading of humidity every 30 seconds and 3 temperature readings in the same time. So far couldn’t figure out how to get temperature and humidity once every 30 seconds…
I use exponential_moving_average to get rid of sudden peaks in values that might be interpreter as fast rise in humidity and false trigger my automation.
Is there a reason why you have choose sliding_window_moving_average?

  1. Yes, just because I haven’t had a chance to change over to the api yet.
  2. You need to have a filter for the temperature separate from the humidity (not just one filter for the DHT), like so:
  - platform: dht
    pin: D1
    model: dht22
    update_interval: 10s
    temperature:
      name: "bathroom_shower_temperature"
      filters:
        - filter_nan:
        - exponential_moving_average:
            alpha: 0.5
            send_every: 3
    humidity:
      name: "bathroom_shower_humidity"
      filters:
        - filter_nan:
        - exponential_moving_average:
            alpha: 0.5
            send_every: 3

The 15 sample moving average (sampled every 15 seconds) gives me an update every 3 min 45 sec which is more than fast enough for slow changing values like this. The moving average does a good job of smoothing the output:

I know that filters for temperature and humidity are separate. Actually, I only added filter to humidity to remove sudden changes in values, but it doesn’t matter in case of temperature so I left it unfiltered, absolutely legit :wink:

I tried to use your filters and reverted back to mine. Mostly because for my automation I need humidity readings frequently - it’s too late to switch an extractor fan if someone is taking a shower for 4 minutes, mine does it in about 30 seconds :wink:

Did you use the same filter on WiFi as it was in docs example or it really looks smooth in your case? I update WiFi sensor every 30s and it looks ok…