Coder Social home page Coder Social logo

mi-scale-2's Introduction

mi-scale-2

Get Xiaomi Mi Smart Scale 2 weight and publishing to mqtt

Tested only on Raspberry Pi 3b + Mi Scale 2

Requirements

  • python3
  • python-dotenv
  • bluepy
  • paho-mqtt
  • root permission for bluepy.btle
sudo pip install -r requirements.txt

Usage

always run with sudo or from root:

cp .env.dist .env
vim .env
sudo ./main.py
# sudo ./main.py --help
# sudo ./main.py --loglevel=DEBUG

Autostart

sudo cp mi-scale-2.service /etc/systemd/system/
sudo systemctl enable mi-scale-2
sudo systemctl start mi-scale-2

Integrate with Home Assistant

qbbr-mi-scale-2-home-assistant-integration

# configuration.yaml:
mqtt:
    sensor:
      - name: "my_weight"
        state_topic: "miscale/qbbr/weight"
        force_update: true
        unit_of_measurement: "kg"
        state_class: "measurement"
        icon: mdi:scale

# customize.yaml:
sensor.my_weight:
    friendly_name: Мой вес

Help

get dev mac address:

sudo hcitool lescan

if u have troubleshoots, try restart u bluetooth/adapter

sudo hciconfig hci0 reset
sudo invoke-rc.d bluetooth restart

Reverse Engineering RAW Schema for Mi Scale 2

!!! slightly different than from openScale wiki !!!

byte 0:

  • 0 bit - unknown
  • 1 bit - unit kg
  • 2 bit - unit lbs
  • 3 bit - unknown
  • 4 bit - jin (chinese catty) unit
  • 5 bit - stabilized
  • 6 bit - unknown
  • 7 bit - weight removed

byte 1-2:

  • weight (little endian)

Links

mi-scale-2's People

Contributors

qbbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.