Xiaomi Mijia bluetooth temperature & humidity sensor compatibility

the easiest way is to use the bluetooth on your homeassistant device and read the values with the component

i used OpenMQTTGateway to read values from mine and for some presence detection over BLE

the range is dependent on your dongle and 2.4Ghz congestion in your house. my esp32 is about 3 meters from the temp sensor

Been running mine for several months and the single AA battery is 75%. No gateway and I used the home assistant component to set it up.
Really easy and fuss free.

Only issue I have been having is not range etc like some others (depends on wall thickness and materials, placement etc) but it won’t read below 10 degrees © in home assistant.
The device on its screen shows lower. Think it’s a software issue and hopefully will be sorted in the future.

Anyone tried to connect direct power ?

Thanks for the fix below 10°C. I am new at Home assistant so even implementing this fix was not easy for me because if I understand correctly when the Home assistant is installed on Raspberrry pi it runs in some virtual enviroment so I couldn’t find and edit those files directly.
So I did following:

  1. Downloaded original mitemp_bt_poller.py and mitemp_bt.py files
  2. Implemented the fix into mitemp_bt_poller.py and placed the file into \config\custom_components
  3. placed file mitemp_bt.py into \config\custom_components\sensor
  4. opened mitemp_bt.py and modified line 61:

original:

   from mitemp_bt import mitemp_bt_poller 

modified:

   from custom_components import mitemp_bt_poller

By doing this it loads the modified mitemp_bt_poller file from custom_components folder
5) saved and rebooted…and BAM! It works. Hope somebody filds this helpful :slight_smile:

1 Like

I don’t understand why the code creates a connection to the sensor. This sensor sends BLE packet with temperature/humidity every second. Even if packet loss would be 99%, you still will get a value every 2 minutes which is awesome, as for me.
I’m using my own C++ code for parsing those BLE packages and python code that handles the values and pass them into Home Assitant. That’s a bit overhead but as I understand, this plugin uses a BT connection and can poll only 1 sensor at the same time.
I would share my Python code in the nearest time, that would probably help for people with range issues. C++ code for Raspberry Pi (compilation instructions are on the top) is here.

4 Likes

Here is the sample BLE Gateway.

https://educ8s.tv/esp32-xiaomi-hack/

I’m planning to use this code with adding MQTT protocol. (if I can :slight_smile: )

Great work @randomdisco! Works for me and fixed my 2 outdoor Xioami temperature sensors.

Hi

Does anyone know how far away the Xiomi bluetooth sensor can be. I have wooden house, but I would need to go though the full house for a few rooms.

Martin

Which outdoor sensors do you use?

Hi @Atlantis I had your same problem. I installed Hassio so I could not find the files to edit. With your solution I am easily able to work the sensor on Hassio under 10 °! Thanks a lot !!

destroyer76
I am glad it helped:)

btw I just discovered another problem with the code - it does not display values between -0.1°C to -0.9°C. It reports these values as positive 0,1°C to 0.9°C. At lower temperature it works again fine. But of course it shows strange oscillations when going thru 0°C…you look at the graph it is like 0.5°C 0.3°C 0.1°C 0.5°C 0.9°C and than it jumps to -1°C.

Has anyone managed to use a bluetooth dongle with HASSIO to extend the range to the embedded bluetooth module ? I have read that it’s not possible yet with HASSIO.
Thanks !

@Atlantis
:thinking::roll_eyes: until today the temperatures were greater than 0, so I could not check. Of course it is very strange

Hi, do you have any progress with your project? Can you share the code? I would love to make the same. I have some thermometers but some of them are not in the bluetooth range to be directly read by rPi.

how di you set up the second RPI3, i have a pi zero w and want to set it up to send data via MQTT to my hass.io (im runing it on an older HP laptop, to improve speed :slight_smile: )

You can use mqtt statestream to publishes state changes.

Hi,
Any idea on how to use a Bluetooth dongle with Hassio to extend the range of these Xiaomi sensors?
Thanks !

If replace bt module with zigbee module, Hygrothermograph connect to HA ?

this is a topic for a BLUETOOTH mijia sensor so no, it doesnt work with zigbee, zwave, wifi or any other protocol

Interesting