Xiaomi Mijia bluetooth temperature & humidity sensor compatibility

With the current firmware version it doesn’t use the same principle of sensor data broadcasting (service data) compared to its brothers.

And by the way not so easy to integrate as its brothers.
(Edit : now the lywsd03mmc is integrated into omg)

I have 6 new square Xiaomi LCD sensors. Using hcitool lescan I found their MACs and names (LYWSD03MMC), and by using gatttool interactive mode, after connecting to the sensors I start getting every few seconds this kind of info:

bogdan@server:~$ sudo hcitool -i hci1 lescan
[sudo] password for bogdan:
LE Scan ...
A4:C1:38:3C:66:EF (unknown)
A4:C1:38:3C:66:EF LYWSD03MMC
bogdan@server:~$ gatttool -i hci1 -I
[                 ][LE]> connect A4:C1:38:3C:66:EF
Attempting to connect to A4:C1:38:3C:66:EF
Connection successful
Notification handle = 0x0036 value: 06 09 1f 15 0c
Notification handle = 0x0036 value: 06 09 1f 15 0c
Notification handle = 0x0036 value: 06 09 1f 15 0c
[A4:C1:38:3C:66:EF][LE]>

I could determine that the first 2 bytes are the temperature in celsius (0x0906 = 2310 >> 23.1C), and the third byte is the humidity (0x1f = 31 >> 31%). I assume that the last 2 bytes contain info about the battery, but I can’t figure out the format. For the temperature and humidity values I confirmed this format on all 6 sensors (hex values correspond to the display values).
Can someone help with integrating this in HASS?

For those interested: here’s a discussion and search for a solution with passive receiving of LYWSD03MMC advertisements.

this is cool, thanks. i have to try this out.

for now, i created an automation to check my ble devices regarding their last update. If it has been longer than 30 minutes, i restarts hassio automatically. but yours seem a much better choice, i will give it a try.

But that discussion is just about passive receieving. And author said that options as mentioned by Lokkje are not acceptable. But anyway it might be interesting to have at least such option (untill they found passive solution).

Yes, I’m just tired of many times rejecting solutions with a connection to the sensor, since the Xiaomi passive BLE monitor component implements a different principle. Boiled a little…
In the situation with LYWSD03MMC, the best solution at the moment, as it seems to me, is to write a separate component. But now I just can’t do it… By the way, the link that I gave the post above has a link to the repository with a working python script for reading LYWSD03MMC sensor - MiTemperature2.
Maybe there is a person who can competently tie this to HA…

I’m considering switching to a Rpi 4. Has anyone compared the bluetooth range of a Rpi 3B+ vs the Rpi 4 ? I have quite a lot of Xiaomi bluetooth temperature sensors and I wouldn’t like to lose connection with some of them.

Hi everobody, you should consider adding mi_temp custom_component in HACS store…

Why? It is already there… :smiley: Look under integrations in HACS it is called “Xiaomi passive BLE monitor sensor platform”.

Btw the install instruction say the same…
The easiest way is to install it with HACS. First install HACS if you don’t have it yet. After installation you can find this custom component in the HACS store under integrations.

not working with the square version LYWSD03MMC

The custom component does support the LYWSD03MMC. You do need to add a key in the encryptions option (GitHub - custom-components/ble_monitor: BLE monitor for passive BLE sensors) however.

2 Likes

:star_struck: Thank’s Ernst, it’s working now ! :innocent:
I download the software on me Android and get the pairings.txt file containing the Bindkey.

software = https://ru.kapiba.ru/mihome/files/old/MiHome_5.6.65_63005_vevs.apk
more info = https://github.com/custom-components/sensor.mitemp_bt/issues/7

1 Like

ooops. New to the forum, not used to…

Has anyone compared the bluetooth range of a Rpi 3B+ vs the Rpi 4 ? I have quite a lot of Xiaomi bluetooth temperature sensors and I wouldn’t like to lose connection with some of them.

I have a LYWSD03MMC that I want to integrate with HA.
Do I have to sync bluetooth with hcitool before?
Thank you !

You need to install the custom component, you cannot use the build in component for LYWSD03MMC. Just follow the instructions here.

Already is OK.
Thanks :slight_smile:

hi rg123, https://ru.kapiba.ru needs username and password, is there any other link to get the apk?

I would never ever try an unknown russian source… And for all your android needs, there is always apkmirror. :slight_smile:

https://www.apkmirror.com/uploads/?q=mihome

1 Like

The username is not needed and the password is 54789512458 according to the blog.

I have successfully integrated 3 sensors with the custom component (all are the square model LYWSD03MMC), and they are working in other rooms without almost any issues with the bluetooth range of the RPi4.
image

1 Like