Home Assistant: Cheap Multi-Room Temperature & Humidity sensors

I have been using the Honeywell Evohome system in our house for multi-zone underfloor heating since it’s we’ve moved in. I’ve also been having issues with this system since that time and it’s cost me a lot of work to get it to do what it should do and I’m really fed up with it!

This video is the first step into replacing that system! In this video we’re going to set up an easy to configure and cheap multi-room temperature sensing system with Home Assistant at its heart.

Video about setup

This post is the text portion that accompanies the main part which is in the video, please watch it first, the video refers to this blog post where needed!

Shopping links

During the video I use certain hardware, here is a list of the hardware that I used. These are affiliate links and help me out! πŸ˜€

 

 

*The power bank charger combo used in the video isn’t for sale anymore it seems

ESPhome

ESPhome is the awesome software used to achieve the Bluetooth -> Home Assistant bridging of the temperature, humidity and battery level data.

It’s an easy way to create firmware that runs on an ESP8266 or ESP32.

Check it out on https://esphome.io !

Text bits

During the video I refer to the following bits:

Scanner configuration:

esphome:
  name: 'vidtemp'
  platform: ESP32
  board: mhetesp32devkit

wifi:
  ssid: 'WIFI SSID'
  password: 'WIFI PASSWORD'

api:

web_server:
  port: 80

logger:

ota:
  password: 'OTA PASSWORD'

# Enable Bluetooth scanning for this ESP32
esp32_ble_tracker:

Remember to change the name to the name you also used in ESPhome and change the WiFi SSID, WiFi PASSWORD and OTA PASSWORD to what you are using in your configuration!

Full configuration:

For the full configuration we only add to the above configuration. So paste the following below what was already there:

sensor:
  - platform: xiaomi_mijia
    mac_address: XX:XX:XX:XX:XX:XX
    temperature:
      name: "Sensor_1 Temperature"
    humidity:
      name: "Sensor_1 Humidity"
    battery_level:
      name: "Sensor_1 Battery Level"

  - platform: xiaomi_mijia
    mac_address: XX:XX:XX:XX:XX:XX
    temperature:
      name: "Sensor_2 Temperature"
    humidity:
      name: "Sensor_2 Humidity"
    battery_level:
      name: "Sensor_2 Battery Level"

Here you will need to replace the XX:XX:XX:XX:XX:XX with the actual MAC addresses of the Xiaomi Mijia meters. In the video I show how to do this using the scanner configuration.

Update: Auto daily reset

–2019-05-26

Since posting this article and video I’ve become aware that the ESP32 still isn’t 100% stable while using bluetooth yet. Although it can run fine for weeks, at some point it might stop receiving bluetooth information.

For this I have added some code to the above example which resets the ESP32 module every 24Hrs, doing this I haven’t had any issues anymore and I have always had my temperature and humidity information!

I’m hopeful these bugs in the ESP32 Bluetooth stack will be fixed in the future but for now this is a workable workaround.

You can add this to your configuration as follows:

time:
  - platform: homeassistant
    on_time:
      - seconds: 0
        minutes: 0
        hours: 4
        days_of_week: MON-SUN
        then:
           - switch.toggle: restart_switch

switch:
  - platform: restart
    name: "test_temperature Restart"
    id: restart_switch

–update 2019-06-08

Changed the name of the switch id because a newer version of ESPhome would error using the “restart”name.

Please follow and like us:

30 thoughts on “Home Assistant: Cheap Multi-Room Temperature & Humidity sensors”

  1. great video I flashed my frist esp32 with this video i have many esp8266 flashed but always struggled with 32 i used the esphomeflasher first time thanks

    1. That’s great to hear! πŸ˜€

      ESPhome flasher makes it easy to do that first flash and after that you can use OTA so don’t need it anymore, it’s an awesome system like that!

  2. Thanks for the video. I hope to order to some these for my place.
    Is there a reason you used ESP home flasher instead of uploading from esphome via the usb port?

    1. Yes, my ESPhome install runs in a docker container in a VM on my Proxmox server, wayyyy to much hassle to get a USB port passed through. My server is also located very inconveniently to access it’s USB ports. ESPhome flaser solves that issue and you can just do it conveniently at your desk! πŸ™‚

  3. Hi,

    amazing project, thanks for sharing!
    I will definitely try that as I have already one of those sensors.

    Can I use any esp 32 based micro controller or it works specifically with those two you mention in the description.

    Regards

    1. It should work with all since in theory all ESP32 modules have bluetooth on board.

  4. Good video! What is the distance from ESP32 to sensors? Can I put the ESP32 on the ground floor and the sensors on the second ?
    Marius

    1. That really depends on the amount of insulation that is in there. For me that’s a no-go but if you have wooden floors that might work just fine.

  5. Great video, just set 2 of these Xiaomi Mijia sensors up using your informative setup procedure. Thanks, One question I see a 300s scan interval in the logs – is this the bluetooth scan interval of the esp32 or the scan interval of the discovered sensors in the esphome bin file. I want to update home assistant more regularly.
    Many thanks.

    1. The 300s is the scan interval for new devices. The devices you configured in the ESPhome configuration will pass an update when the temperature changes (they don’t send anything if the values don’t change). I’ve seen multiple updates per minute so should be fast enough for most purposes.

  6. I’m curious about the minimum battery voltage these devices need to keep working, and if they would work fine with a rechargeable NiMh AAA cell at 1.2 volts. With the discharge slope of an alkaline cell, it spends much of its life below the 1.5 volts that it starts out with, and the cut-off voltage for many devices is supposedly 1 volt. Replacing an alkaline battery once a year isn’t a major financial outlay (well maybe for 18+ of them, it would be), but why create more waste.

    Another thing I’ve been wondering about is firmware updates. Being a simple device, it may never need updating, but right now it looks like it would need the Xiaomi bridge and their phone app.

    1. I did a short test with some Eneloops in there and that seemed to work ok. But that test wasn’t longer then a month and the drop off in my graphs was a bit more then with normal Alkaline batteries which is logical because as you said, they start at a lower voltage. So I don’t really know the run-time for that kind of time period yet. The one’s I had duracell’s in for a month ended up between 85% and 95%. I think it mostly depends on how many temperature swings there are since it delivers more messages with changing temperatures then stable. A more thorough analysis will follow later when I’ve been using it for a while. πŸ™‚

  7. Thaks! Great video, it helps me to set up my WeMosESp32 with HA. I wonder if you can provide link for second part of the video. Thanks!

  8. Thanks for the video – really helped to get my way through.
    Would recommend to save before the original Firmware with a FlashRead (check esptool.py).

  9. Tonight I programmed my first NodeMCU32! :smiley: with ESPHome!
    Got them working as BLE Beacons in combination with Owntracks for quick and reliable presence detection.
    Now I really like the Xiaomi Mija Temperature and Humidy sensors which are being used in some recent videos. Do you guys think a combination of BLE xmit and receive will work on 1 NodeMCU ESP32 module.
    This would be perfect since I scattered three modules in the house. Good theoretical coverage for the xiaomi Bluetooth temperature sensors.
    I just have to put :
    esp32_ble_beacon & esp32_ble_tracker
    in the ESPhome config, correct?

    1. Hi @Braim1nat0r, I think this can work but I haven’t tried it myself, what have your results been?

  10. Thank you for your inspiring videos which have greatly helped me in taming my Xiaomi sensors. I use them to monitor my 3D printer filaments dryboxes and it is working great, muchg better than the dodgy original App. I have also noticed that from time to time I would loose the temp/hygro reporting while the ESP is still alive. The reboot trick will surely help. I have one question though. How would you enfore such a reboot on an ESP32 which is in deep sleep mode and which resumes 10s every 10 min ? What would be the best way to specify a “non equal time” condition for reboot such as “once you have past this time of the day” do a reboot, but only once a day ?

    1. Poeh, that’s a good question! I don’t know if there is a trigger or a counter you could build within ESPhome to do the reboot. But I also wonder if the reboot is necessary if the ESP32 module goes into deep sleep. The problem while having an active ESP32 is that the bluetooth stack crashes in the backend code of the ESP32, it’s not really fixable in ESPhome because it’s a problem in the backend drivers. But if you module goes into deep sleep, I wonder if this stack wouldn’t be restarted anyway.

  11. Thanks for introducing me to these sensors. Like you, I’ve ended up here due to an unreliable heating system and a desire to automate it without relying on external systems. I’ll end up with 11 sensors which will drive my home’s underfloor heating and I’m in the early stages of developing the automation.

    I’m currently testing 2 of the Xiaomi sensors talking to a LOLIN D32 board. As you’ve found, the readings can stop being taken from one or more of the sensors after a certain amount of time. I used your script that triggered a daily reset, but I was still occasionally seeing the readings stop.

    I’ve now set up a watchdog in Node-RED that calls the reset service if no temperature readings have been received for 60 minutes. I’ll see how this works…

    I notice that the latest release of ESPHome (1.13.5) has a workaround for ESP32 BLE issue #626 – https://github.com/esphome/esphome/pull/626
    I’m not sure if this applies to the problems we’ve seen, but I’ll keep my fingers crossed.

    I look forward to the next update on your project.

    1. Hi, thnx for your awesome comment! I hope to be able to continue with this project soon, but lots of stuff going on so it might take a little bit. I also noticed the ESPhome issue where they implemented a workaround if the BLE scan never finishes, if that works correctly that would be even better then the “once a day” I implemented. I’ll be testing it and will probably talk about it when I get a chance to do a new video about this topic! πŸ˜€

      1. Mine has been running now for over a week without getting stuck, so I guess the fix in the recent release can be considered successful.

        1. I spoke too soon, mine lost contact and had to be reset to communicate with the devices. It’s certainly better than before, though.

    2. chrismox how do you do the watchdog in node-red. I was hoping to sense if my car was in the garage by having a Xiaomi Temp sensor in the car. I’m new to Node-red, but have some basic automations.

      1. Oh that can work I think, it will start updating again once it’s in range and if you link an action to that, that could work?

  12. i add under the wifi settings:

    wifi:
    ssid: ‘ESP32’
    password: ‘*******’
    power_save_mode: none

    This seems to work for me.
    had a lot of trouble that I had no connection

  13. Really like your projects and viedos, thanks for sharing!!!

    Recently I have built this Bluetooth sensor solution because it is the ideal solution for a requirement I have.
    It all works perfectly as long as the sensor and ESP32 module are close to each other. A wall or even a simple window breaks the connection. Even a few meters distance without any obstacle interrupts the connection…
    Now I guess I have a lazy ESP32 module or is the Xioami sensor just so weak?
    Has anyone experienced Bluetooth ranges from different ESP32 modules? I guess very much it is due to the ESP module…

    Any help is welcome!

    By the way, greetings to the Netherlands!

Leave a Reply

Your email address will not be published. Required fields are marked *