BLE Gateway and Xiaomi Sensor


#1

Hi,

I was hoping to be able to read data from Xiaomi Mi Flora and Xiaomi Temperature sensor but we need to poll data from the sensor through a BLE connection to do that .

Is it possible to install alternative firmware?

How can I do SSH on the current gateway?

Thanks in advance


#2

Is it possible to install alternative firmware?

The main micro controller is ESP32 and the BLE module is nRF52832. You can develop your own firmware for them if you’re family with these chips.

How can I do SSH on the current gateway?

You can’t ssh the gateway. It runs freeRTOS not Linux like system.


#3

BTW: which model xiaomi temperature sensor do you use? Does it need connection or just advertising?


#4

#5

Ok. We’ll buy one temperature sensor and check the advertising data today


#6

Great! Please kindly let me know


#7

Hi,

I checked a Xiaomi BLE temperature humidity sensor with LCD. I used a BLE sniffer to scan data. Some sample datas

37 1 4C65A8D0F380 02 01 06 13 16 95 FE 50 20 AA 01 8B 80 F3 D0 A8 65 4C 04 10 02 D5 00 -53
37 1 4C65A8D0F380 02 01 06 15 16 95 FE 50 20 AA 01 8C 80 F3 D0 A8 65 4C 0D 10 04 D4 00 CB 00 -53
37 1 4C65A8D0F380 02 01 06 15 16 95 FE 50 20 AA 01 8D 80 F3 D0 A8 65 4C 0D 10 04 D4 00 CC 00 -53
37 1 4C65A8D0F380 02 01 06 15 16 95 FE 50 20 AA 01 8E 80 F3 D0 A8 65 4C 0D 10 04 D6 00 CE 00 -53
37 1 4C65A8D0F380 02 01 06 12 16 95 FE 50 20 AA 01 8F 80 F3 D0 A8 65 4C 0A 10 01 12 -53
37 1 4C65A8D0F380 02 01 06 15 16 95 FE 50 20 AA 01 90 80 F3 D0 A8 65 4C 0D 10 04 D5 00 CD 00 -53
37 1 4C65A8D0F380 02 01 06 13 16 95 FE 50 20 AA 01 91 80 F3 D0 A8 65 4C 06 10 02 CC 00 -53
37 1 4C65A8D0F380 02 01 06 15 16 95 FE 50 20 AA 01 92 80 F3 D0 A8 65 4C 0D 10 04 D5 00 CC 00 -53
37 1 4C65A8D0F380 02 01 06 15 16 95 FE 50 20 AA 01 93 80 F3 D0 A8 65 4C 0D 10 04 D5 00 CA 00 -53
37 1 4C65A8D0F380 02 01 06 15 16 95 FE 50 20 AA 01 94 80 F3 D0 A8 65 4C 0D 10 04 D5 00 CD 00 -53

I can get data even the iOS Mijia.app reading temperature data. So it doesn’t need connection to get the data.

I also found a Python library to parsing the data from Xiaomi temperature sensor. Please check the repo


#8

Well I m receiving these data as well, but I don’t what it is. The API you are mentioning is doing :

def _parse_data(self):
    """Parses the byte array returned by the sensor.
    The sensor returns 14 bytes in total, a readable text with the
    temperature and humidity. e.g.:
    54 3d 32 35 2e 36 20 48 3d 32 33 2e 36 00 -> T=25.6 H=23.6
    """
    data = self._cache

    res = dict()
    res[MI_HUMIDITY] = float(data[9:13])
    res[MI_TEMPERATURE] = float(data[2:6])
    return res

But I receiving data similar to yours

020106151695FE5020AA01AC2D06DBA8654C0D100409010502

That’s are not readable.
Please not that if I run the python API from my pc with a bluetooth adaptor it works fine…

Any idea please?


#9

Let’s forget the python library mitemp. It need connect to the sensor.

Here’s another library node-xiaomi-gap-parser. It just parse the advertising data to get temperature and humidity data.

For your sample data:

020106151695FE5020AA01AC2D06DBA8654C0D100409010502
  • The last two bytes 05:02 is 0x0205, it’s a little endian 16-bit integer equal 517 as in 51.7% relative humidity.
  • 0901 is 0x0109 = 265 as in 26.5 celsius.

See more information in the section Technical Details


#10

This is perfect! I’m working on an integration on your BLE Gateway into Home Assistant


Will keep you posted if you wish…


#11

That’s great! Please keep update with me!