Xiaomi BLE Temperature and Humidity sensor

Hello,
I updated from 0.95.4 to 0.96.5 and now my 2 BT xiaomi thermometers are now no longer recognized…

in the log I get:

Updating mitemp_bt sensor took longer than the scheduled update interval 0:00:30

anyone else experiencing this with the update???
Thanks

Me too… after update to 0.96.5 my xiaomi ble works some minutes since restart… then the same error (polling error… broken pipe… etc…)

This issue finally forced me to look into ESPhome. I just took spare ESP32 a made it esentially into bluetooth to wifi bridge. Now my thermometers are connected to ESP32 and ESP32 transmitts the values over wifi to Home Assistant. It looks more solid than using integrated BT in rPi.
Also I can now move rPi anywhere in my apartment as only the ESP32 has to be in range to receive signal from those thermometers.

1 Like

Please, write a short step by step tutorial on how to do this!

Main info here: https://esphome.io/guides/getting_started_hassio.html

How it works in a nutshell that took me some time to understand - you have addon in home assistant where you manage all your ESPhome devices. You write code for them and this addon compiles firmware for them. There are multiple ways how to upload the firmware to the target device - you either download .bin to your computer and use ESPHome-Flasher or you connect USB directly to your rPi.
Later updates to your code can be uploaded wirelessly to the device directly.

My summary - installed ESPhome addon to home assistant. Opened this addon and added new device. Filled in necessary details about my wifi etc.
Added following code, saved, uploaded

esp32_ble_tracker:

sensor:
  - platform: xiaomi_mijia
    mac_address: 4C:65:A8:D7:9E:1C
    temperature:
      name: "Xiaomi BT 1 Temperature "
    humidity:
      name: "Xiaomi BT 1 humidity"
    battery_level:
      name: "Xiaomi BT 1 Battery"
      
  - platform: xiaomi_mijia
    mac_address: 4C:65:A8:DD:40:27
    temperature:
      name: "Xiaomi BT 2 Temperature "
    humidity:
      name: "Xiaomi BT 2 humidity"
    battery_level:
      name: "Xiaomi BT 2 Battery"
      

Last thing to do was go (in home assistant) to configuration, integrations, add, find ESPhome, fill-in IP address of the ESP32 and save. And now simply those sensors appeared in home assistant

3 Likes

For those who have problems with the stability of the sensor reading, the information I found here may be very useful.

Briefly: Xiaomi BLE Temperature and Humidity sensor does not require a poll, it already sends readings about once a second. That is, even if in conditions of poor communication you successfully receive only 1 reading of 60, then this will give you an update once a minute! The user who published this information (via the provided link) has a solution for this kind integration (albeit for now a test, but working).
1 Like

in the configuration.yaml i need just write the following?

sensor:
  - platform: mitemp_bt

i ran the commands and put the custom component , but i cant see the entities?

Yes that’s all. The new name of the sensor looks like: sensor.mi_t_your device mac address.

1 Like

its updating instantly, works amazing, how about battery life?

Battery life not affected, because this sensor is designed so that it sends data once a second itself, without the need to poll it. The only problem this code can lead to - is the fast increase in database size, especially if you have a lot of these sensors… Sorry for bad English.

1 Like

Any one has an idea how to avoid the database to increase? its got large in no time

No you need custom files in your config/custom_componets/mitemp_bt folder from github.
then this will work.

Running ESPHome esp32_ble_tracker w/platform: xiaomi_mijia on ESP32 NodeMCU makes my router loose its 2.4GHz bands and requires a router restart.

Seems like the BLE is interfering with my Wi-Fi. Anyone having this issue / Any way to limit the BLE scan?

That looks like ultra shitty router :smiley: I can understand that is looses connection but requiring restart? That weird… Try changing wifi channel to different one.

This is an issue with the mitemp_bt_poller.py, namely the way the outhor parses the string. It assumes two digits without a sign. As soon as you get below 10C it will fail.

Hi!!! I have same issue since march / april! I’ve searched without success. What’s your router model?

ASUS Bluecave. I’ve tried both setting control channel to AUTO and to set it to a fixed channel. Result was the same in both.

Confirmed, i have a blue cave too. It’s a router issue. I’ve tried that too but same result, I’ve searched logs and I only found a thread with no solution, and I’ve reported to Asus but I have not received answer. You can connect esp32 without ble tracker?

@DendelX, yes, I’m able to connect esp32 w/o ble tracker to the bluecave, its stable for a long time.
issue. Btw: I’ve searched online and saw it happens w/other ASUS and Netgear models.

There should be a configuration switch, perhaps in the advance settings… checking

I have tried all settings that I can, but not all that I could because my home network is full of domotic devices and I can’t take some risks. If you found something would be fantastic, remember me please :wink: