Skip to content

Conversation

@JPFrancoia
Copy link

@JPFrancoia JPFrancoia commented Jan 29, 2026

Hi,

Thank you for maintaining openScale. I just bought the Xiaomi Body Composition Scale S400 and I noticed openScale didn't support it, so here we are.

I didn't reverse the bluetooth protocol myself, I leveraged the work done in this repo, so that sped things up.

This scale uses encryption in its bluetooth protocol, so the BLE key must be extracted. Here is how:


1. Initial Scale Setup (if not done)

  1. Install the Xiaomi Home app on your phone
  2. Add your S400 scale as a new device
  3. Complete at least one weighing to ensure the scale is registered with Xiaomi Cloud

2. Extract Tokens Using Xiaomi Cloud Tokens Extractor

# Clone the repository
git clone https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor.git
cd Xiaomi-cloud-tokens-extractor

# Install dependencies
pip install -r requirements.txt

# Run the extractor
python token_extractor.py

When prompted:

  1. Enter your Xiaomi account email/username
  2. Enter your password
  3. Select your region (e.g., de for Germany, us for USA, cn for China)

3. Find Your Scale's Information

The extractor will output a list of all your Xiaomi devices. Look for your scale:

Device: Xiaomi Body Composition Scale S400
Model: xmtzc14hm (or similar)
MAC: AA:BB:CC:DD:EE:FF
BLE KEY: 0123456789abcdef0123456789abcdef

Save these two values:

  • MAC: The Bluetooth address (format XX:XX:XX:XX:XX:XX)
  • BLE KEY: A 32-character hexadecimal string

4. Kill the Xiaomi Home App

Kill the app or uninstall it.


Once you have the key, this is pretty straightforward.

This is a measurement done with the Xiaomi Home App:

Screenshot_20260129-075926 Xiaomi Home

This is a measurement done with openScale (there is a difference because I did the measurement in the Xiaomi Home app the day after, while making this PR, to prove that it works):
Screenshot_20260129-074517 openScale

Here are a few other screenshots:

Screenshot_20260129-074325 openScale Screenshot_20260129-074334 openScale Screenshot_20260129-074420 openScale

To be clear: I built the app locally in debug mode, sideloaded it onto my phone and performed a real measurement.

I had to add a little bit of UI to add the BLE bind key in the setting. I couldn't find an existing example in openScale where this was done already, please let me know if I missed it.

Disclaimer: I did use AI to write most of the code. However I reviewed the code to the best of my abilities and I carefully tested the app. I compared all the metrics one by one with the official app to make sure that the values make sense in openScale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant