ESP32 BLE Scale support XIAOMI / YUNMAI

Version of firmware is 1.0.0.12

Many types of BLE scales was already reversed:

Yunmai data decoding logic can be found here:

My Yunmai Scale Data

{
  "id": "D4:36:39:AC:F2:E2",
  "mac_type": 0,
  "name": "YUNMAI-ISM2-W",
  "rssi": -70,
  "txpower": 0,
  "servicedata": "31208d0100e2f2ac3936d409",
  "servicedatauuid": "0xfe95"
}

Hi @baliqci,

I’d be happy to work with you on getting the Yunmai Scale integrated.

Could you give some more sample as above, but with corresponding weight?

Also, which model is it out of the three available?

1 Like

Of course, I well be glad to provide you all necessary information.

I have now YUNMAI Mini 2.

Android openScale.apk has ability to save a debug information:

2023-02-09 12:15:10.563 Debug [2] BluetoothCommunication: Try to connect to BLE device D4:36:39:AC:F2:E2
2023-02-09 12:15:10.683 Info [2] BluetoothPeripheral: connect to 'YUNMAI-ISM2-W' (D4:36:39:AC:F2:E2) using transport LE
2023-02-09 12:15:10.707 Info [2] BluetoothPeripheral: peripheral 'D4:36:39:AC:F2:E2' is connecting
2023-02-09 12:15:11.172 Info [6206] BluetoothPeripheral: connected to 'YUNMAI-ISM2-W' (NONE) in 0.5s
2023-02-09 12:15:11.178 Debug [2] BluetoothPeripheral: discovering services of 'YUNMAI-ISM2-W' with delay of 0 ms
2023-02-09 12:15:11.440 Debug [6206] BluetoothPeripheral: connection parameters: interval=7.5ms latency=0 timeout=5s
2023-02-09 12:15:11.848 Info [6206] BluetoothPeripheral: discovered 5 services for 'YUNMAI-ISM2-W'
2023-02-09 12:15:11.858 Debug [2] BluetoothCommunication: connected to 'YUNMAI-ISM2-W'
2023-02-09 12:15:11.863 Debug [2] BluetoothCommunication: Successful Bluetooth services discovered
2023-02-09 12:15:11.865 Debug [2] BluetoothCommunication: Resume machine state
2023-02-09 12:15:11.868 Debug [2] BluetoothCommunication: Step Nr 0
2023-02-09 12:15:11.872 Debug [2] BluetoothCommunication: Invoke write bytes [0D 12 10 01 00 00 16 BF B4 01 14 55 5A 00 00 01 00 05] on 0xffe9
2023-02-09 12:15:11.875 Debug [2] BluetoothCommunication: Step Nr 1
2023-02-09 12:15:11.878 Debug [2] BluetoothCommunication: Invoke write bytes [0D 0D 11 63 E4 B9 9F 00 00 00 00 00 BD] on 0xffe9
2023-02-09 12:15:11.881 Debug [2] BluetoothCommunication: Step Nr 2
2023-02-09 12:15:11.883 Debug [2] BluetoothCommunication: Invoke set notification on 0xffe4
2023-02-09 12:15:11.885 Debug [2] BluetoothCommunication: Stop machine state
2023-02-09 12:15:11.904 Debug [2] MainActivity: Bluetooth connection successful established
2023-02-09 12:15:11.907 Debug [2] BluetoothPeripheral: writing <0d121001000016bfb40114555a0000010005> to characteristic <0000ffe9-0000-1000-8000-00805f9b34fb>
2023-02-09 12:15:11.917 Debug [6206] BluetoothPeripheral: connection parameters: interval=30.0ms latency=0 timeout=5s
2023-02-09 12:15:11.952 Debug [2] BluetoothCommunication: SUCCESS: Writing <0D 12 10 01 00 00 16 BF B4 01 14 55 5A 00 00 01 00 05> to <0000ffe9-0000-1000-8000-00805f9b34fb>
2023-02-09 12:15:11.959 Debug [2] BluetoothPeripheral: writing <0d0d1163e4b99f0000000000bd> to characteristic <0000ffe9-0000-1000-8000-00805f9b34fb>
2023-02-09 12:15:12.005 Debug [2] BluetoothCommunication: SUCCESS: Writing <0D 0D 11 63 E4 B9 9F 00 00 00 00 00 BD> to <0000ffe9-0000-1000-8000-00805f9b34fb>
2023-02-09 12:15:12.101 Debug [2] BluetoothCommunication: SUCCESS: Notify set for 0000ffe4-0000-1000-8000-00805f9b34fb
2023-02-09 12:15:12.105 Debug [2] BluetoothCommunication: Resume machine state
2023-02-09 12:15:12.108 Debug [2] BluetoothCommunication: Step Nr 3
2023-02-09 12:15:12.110 Debug [2] BluetoothCommunication: Invoke write bytes [0D 05 13 00 16] on 0xffe9
2023-02-09 12:15:12.113 Debug [2] BluetoothCommunication: Step Nr 4
2023-02-09 12:15:12.115 Debug [2] BluetoothCommunication: Invoke delayed disconnect in 60s
2023-02-09 12:15:12.119 Debug [2] BluetoothPeripheral: writing <0d05130016> to characteristic <0000ffe9-0000-1000-8000-00805f9b34fb>
2023-02-09 12:15:12.134 Debug [2] MainActivity: Bluetooth scale message: Please step barefoot on the scale
2023-02-09 12:15:12.196 Debug [2] BluetoothCommunication: SUCCESS: Writing <0D 05 13 00 16> to <0000ffe9-0000-1000-8000-00805f9b34fb>
2023-02-09 12:15:12.199 Debug [2] BluetoothCommunication: Step Nr 4
2023-02-09 12:15:12.201 Debug [2] BluetoothCommunication: Invoke delayed disconnect in 60s
2023-02-09 12:15:23.976 Debug [2] BluetoothYunmaiSE_Mini: Extract the fat value from received bytes
2023-02-09 12:15:23.984 Debug [2] BluetoothYunmaiSE_Mini: received bytes [0D 1F 14 02 00 63 E4 B9 AB 00 00 16 BF (20 EF 01 8A 08 31) 48]
2023-02-09 12:15:23.989 Debug [2] BluetoothYunmaiSE_Mini: received decrypted bytes [weight: 84.31, fat: 20.97, resistance: 394]

20 EF - 84.31 kg // weight
01 8A - 394 // resistance
08 31 - 20.97 // fat

AFAIK all models of Yunmai Scales work with one protocol.

It’s mine

Hi @baliqci thanks for your offer to help with getting the Yunmai scales included.

Unfortunately your above links and log are all about having to conenct to the scale and reading service data or registering for notifications. This is out of the scope of Theengs Decoder and therefore OpenMQTTGateway.

We can only decoder information which is freely broadcast by devices in their advertisement data, in the scales’ case the servicedata you saw in your undecoded message

While I don’t immediately see any relating data in this servicedata, compared to your later connection data

this could also be because it was taken at different times/weighing.

Also it includes the MAC address reversed, so it could only be encoded in the remaining data.

“31208d0100e2f2ac3936d409”

Possibly:
3120 - little endian - 2031 - 82.41 kg
8d01 - little endian - 018d - 397 resistance
and the fat percentage is calculated with these two values, so not broadcast in the advertisement data. But the above is just conjecture and only close to your other connection reading, so would need to be verified with more readings.

What we would need is one or a few more current OMG undecoded readings, along with the relevant weight, resistance and fat information.

Could it also be that you receive different kinds of undecoded scale messages, possibly with a different "servicedatauuid"?

Unfortunately, YUNMAI Scales broadcast always the same servicedata with reversed MAC, and the same servicedatauuid.

It looks like it is not possible to implement this scale reading in the current realisation of OMG.

If it is always the same servicedata, unfortuantely yes, it won’t be possible to include the Yunmai scales :frowning:

You could try the OpenMQTTGateway direct READ command with your controller, but it won’t support any registration for notifications.

1 Like