ESP32 BLE Scale support XIAOMI / YUNMAI

Is it possible to read data (weight) from Bluetooth enabled scales like YUNMAI

I can see this only:

{“id”:“0c:1c:xx:xx:xx:xx”,“name”:“YUNMAI-SIGNAL-H1WS”,“manufacturerdata”:“dº¤W\f”,“rssi”:-65,“txpower”:0,“distance”:x.0xxxx}

If OMG doing only BLE beacon, what is the purpose then? Only tracking distance and presence of Bluetooth devices?

Sorry, it wasn’t clear to me at least.
Thanks.

Hello,

OMG supports indeed presence detection by scanning BLE devices and reading of devices dependent values from the following ones (temperature, moisture, humidity…):

Regarding the reading of value coming from BLE scales I’m interested, do you have a link to yours?

1 Like

Maybe we could try to reverse engineer their protocol, would you be interested in participating ?

I would like to, but I need to know what to do at least, to say yes.
This scale for some reason sometimes called as YUNMAI Scale from Xiaomi.
Maybe this is relabeled Xiaomi product. Here is the link for example:
https://us.gearbest.com/body-scale/pp_719052.html

Just flash an esp32 with :
default_envs = esp32dev-ble
and post here the different servicedata field you see in your mqtt broker corresponding to the scale, with the corresponding weight measured.

Any instructions on how to do this (links please)? This is my first time when I used ESP32.
I just loaded precompiled files into ESP32. Can’t find anything on Google. Played with ESP8266 a lot.

Oh I see this is for platformio, I need to try this, because I have used Arduino IDE env only.

Getting error: ‘class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>’ has no member named ‘setPort’

Any idea what is the problem?

OK, All errors are cleared, (learning with Platformio), and now Im getting even less information from the scale.
now:
{“id”:“0c:1c:xx:xx:xx:xx”,“manufacturerdata”:“dº¤W\f”,“rssi”:-64,“distance”:x.79xxxx}

before:
{“id”:“0c:1c:xx:xx:xx:xx”,“name”:“YUNMAI-SIGNAL-H1WS”,“manufacturerdata”:“dº¤W\f”,“rssi”:-65,“txpower”:0,“distance”:x.0xxxx}

I advise you to let it scan for at least 10 minutes with some weight on it and see if it publish some service data.

OK thanks, I will try this.

No change just this information {“id”:“0c:1c:xx:xx:xx:xx”,“manufacturerdata”:“dº¤W\f”,“rssi”:-64,“distance”:x.79xxxx}
Is it need to be authorized with a pin code? And how to?
Because when scale connected to the android app it uses a pin code.

Hello!
I want to add to your discusion. I was doing some research about how to connect OMG with the Xiaomi Scale and I found this thread. In mi case, it’s a Xiaomi Scale (First version).

I inspect the publications and I found the following lines, where apear the servicedata field:

btgateway/home_presence/OMG1 {“id”:“88:0f:10:87:88:xx”,“name”:“MI_SCALE”,“manufacturerdata”:“W����”,“rssi”:-56,“distance”:0.593417}
btgateway/OMG1/BTtoMQTT/880F108788B3 {“id”:“88:0f:10:87:88:xx”,“name”:“MI_SCALE”,“manufacturerdata”:“W����”,“rssi”:-56,“distance”:0.593417,“servicedata”:“a28039e3070602070e28”,“servicedatauuid”:“0000181d-0000-1000-8000-00805f9b34fb”}

Also I found and interesting post about “decrypting” the bluetooth traffic of this scale. In this post, the author explain that the connection isn’t open and the scale broadcasts the weight in the Bluetooth
POST: https://github.com/oliexdev/openScale/wiki/Xiaomi-Bluetooth-Mi-Scale

Thanks for this great job with OMG!

Okey! I have it!!!
The number of service data is in little endian format. Splitting the number in pairs, and choosing the 2 and 3 pair you can get the weight. It is wide explained in the post, but in summary the idea is:

  1. Get the service data and split in pairs:
    …“servicedata”:“a2ac2be307060207122b”… => a2 ac 2b e3 07 06 02 07 12 2b
    …“servicedata”:“a28039e3070602070e28”… => a2 80 39 e3 07 06 02 07 0e 28

  2. Choose the second and third pair and turn them (because are hex number in littel enndian)

ac 2b => 2bac
80 39 => 3980

  1. Convert to decimal and divide by 200. (Divide by 100 if you use lb)

2bac => 11180÷200 = 55,9kg
3980 => 14720÷200 = 73,6kg

Just to know, you think that can be integrated to OMG in the future? Or better I make a script that does the calculations and conversions and re-publish the results.

Thanks again!

1 Like

Hello,

Thanks for the reverse engineering work, that’s perfect !
I will integrate it to OMG. Maybe I will need further details or tests if possible.

1 Like

Great! I’m totally available to do the needed tests, or further work.
You can contact me at pavon87 at Gmail dot com
Thanks Florian!

Hello,

Here is a first proof of concept on a dedicated branch for testing:
https://github.com/1technophile/OpenMQTTGateway/tree/ble-scale

Used the latest Xiaomi Miscale

No changes for the YUNMAI scale, still basic information.

Hello,
I just tested it and it does what I was expect! Exact result and fast refresh.
Thanks again for your work.

If ever I buy the Xiaomi Mi Scale 2 (or YUNMAI scale- it’s the same) I hope that I can contribute again!
Bye!