All Projects → satcar77 → Miband4

satcar77 / Miband4

Access Xiaomi MiBand 4 from Linux using Bluetooth LE

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Miband4

mijia-homie
A Homie MQTT bridge for the Xiaomi Mijia 2 hygrometer-thermometer. This repo also serves as the monorepo for a handful of helper crates related to Homie and Bluetooth.
Stars: ✭ 40 (-83.19%)
Mutual labels:  bluetooth-low-energy, xiaomi
Mi Flower mate plugin
A plugin for Domoticz, the open source home automation software, which allows it to easily connect to Xiaomi Mi Flower Mate devices
Stars: ✭ 13 (-94.54%)
Mutual labels:  bluetooth-low-energy, xiaomi
Homebridge Mi Hygrothermograph
Homebridge plugin for the Xiaomi Mi Bluetooth Temperature and Humidity Sensor
Stars: ✭ 179 (-24.79%)
Mutual labels:  xiaomi, bluetooth-low-energy
Xiaomi Flower Care Api
Xiaomi Flower Care (MiFlora) API wrapper.
Stars: ✭ 111 (-53.36%)
Mutual labels:  xiaomi, bluetooth-low-energy
Rxble
使用 RxJava 封装的低功耗蓝牙类库
Stars: ✭ 203 (-14.71%)
Mutual labels:  bluetooth-low-energy
Continuity
Apple Continuity Protocol Reverse Engineering and Dissector
Stars: ✭ 180 (-24.37%)
Mutual labels:  bluetooth-low-energy
Valetudo
Cloud-free control webinterface for vacuum robots
Stars: ✭ 2,738 (+1050.42%)
Mutual labels:  xiaomi
Androidbluetoothlibrary
A Library for easy implementation of Serial Bluetooth Classic and Low Energy on Android. 💙
Stars: ✭ 171 (-28.15%)
Mutual labels:  bluetooth-low-energy
Gatt Python
Bluetooth GATT SDK for Python
Stars: ✭ 233 (-2.1%)
Mutual labels:  bluetooth-low-energy
Python Bluezero
A simple Python interface to Bluez
Stars: ✭ 222 (-6.72%)
Mutual labels:  bluetooth-low-energy
Blessed Android
BLESSED, a Bluetooth Low Energy (BLE) library for Android
Stars: ✭ 195 (-18.07%)
Mutual labels:  bluetooth-low-energy
Xiaomiadbfastboottools
A simple tool for managing Xiaomi devices on desktop using ADB and Fastboot
Stars: ✭ 2,810 (+1080.67%)
Mutual labels:  xiaomi
Pandwarf
PandwaRF: RF analysis tool with a sub-1 GHz wireless transceiver controlled by a smartphone or
Stars: ✭ 206 (-13.45%)
Mutual labels:  bluetooth-low-energy
Kable
Kotlin Asynchronous Bluetooth Low-Energy
Stars: ✭ 194 (-18.49%)
Mutual labels:  bluetooth-low-energy
Opentracks
OpenTracks is a sport tracking application that completely respects your privacy.
Stars: ✭ 225 (-5.46%)
Mutual labels:  bluetooth-low-energy
Homebridge Dafang
Homebridge Plugin for Xiaomi Dafang / Wyze Cam IP Camera => Hey Siri, Start Video Recording
Stars: ✭ 176 (-26.05%)
Mutual labels:  xiaomi
Radareeye
A tool made for specially scanning nearby devices[BLE, Bluetooth & Wifi] and execute our given command on our system when the target device comes in-between range.
Stars: ✭ 218 (-8.4%)
Mutual labels:  bluetooth-low-energy
Xiaomi Pro Hackintosh
XiaoMi NoteBook Pro Hackintosh
Stars: ✭ 2,348 (+886.55%)
Mutual labels:  xiaomi
Xiaomi Kettle
Xiaomi Kettle BLE protocol reverse-engineered
Stars: ✭ 187 (-21.43%)
Mutual labels:  xiaomi
Xiaomirobotvacuumprotocol
Attempt to describe the Xiaomi Robot Vacuum Protocol
Stars: ✭ 200 (-15.97%)
Mutual labels:  xiaomi

Requirements Commit License

MIBAND 4 - Python Library

Library to interact with Xiaomi MiBand4. Only works on linux. demo

Updates(3/1/2021)

  • Alarm functionality.

Updates(10/27/2020)

  • (New Feature) Custom watchface files(.bin) support.
  • Firmware restore/update fixes.

Contributors

MiBand 4 provides superset of services provided by MiBand 2/3. For the services that were similar for both devices, the bluetooth characteristics, UUIDs and request/response byte sequence were the same. Therefore, I utilized some of the informations already uncovered by Freeyourgadget team and made use of the code by Andrey Nikishaev for MiBand2. I reverse engineered snooped ACL packets to fill in the pieces of the puzzle.

AuthKey

MiBand 4 with updated firmware requires server based pairing. This means, that you absolutely must use MiFit app to make the initial pairing, retrieve the pairing key and then use this key to pair with this library. Only some of the features of this library work without AuthKey of the band. Read Server based pairing for further details.

There are several ways to obtain the key.

Obtaining unique Authkey

On rooted phone you may grab the key from MiFit database which means that you must:

  • install MiFit
  • create an account
  • pair the band/watch
  • Then, execute the following command in a root shell terminal:
sqlite3 /data/data/com.xiaomi.hm.health/databases/origin_db_[YOURDBNAMEHERE] "select AUTHKEY from DEVICE"

On a non rooted phone you may consider using https://www.freemyband.com/

NOTICE: Every time you hard reset the band/watch, the Bluetooth MAC Address will be changed and you must grab a new key! Also, anytime you unpair your band/watch from MiFit, the pairing key will be invalidated and you must make new pairing in MiFit app.

Features that work without authkey

  • Sending Calls
  • Sending alerts
  • Sending Missed call notifications
  • Retrieving device info
  • Sending music title and music state(Playing/Paused)
  • Recieve music control events (Play/Pause/Forward/Backward/Volume Up/Volume Down/Enter Music app/ Exit Music app) through callbacks

Features that needs authkey

  • Updating watchface of the band
  • Retrieving heart rate (Realtime and Single time)
  • Firmware update/restore (This feature has the potential to brick your Mi Band 4. Do it at your own risk)
  • Retrieving steps count, calories count and fat burnt
  • Setting date and time
  • Fetching fitness data within certain past intervals.

Setup and demo

  • Clone this repo to your local machine using https://github.com/satcar77/miband4.git
  1. Install the dependencies. Libglib2 is required for bluepy.

    sudo apt-get install libglib2.0-dev
    pip3 install -r requirements.txt
    
  2. (Optional) Find AuthKey for your device and put it to auth_key.txt file in the current directory with the script.

  3. Turn off your Bluetooth on your mobile device paired with MIBand 4

  4. Find out your MiBand4 MAC address using hcitool

    sudo hcitool lescan
    // if you are having trouble
    sudo hciconfig hci0 reset 
    
  5. Run the miband4_console

    python3 miband4_console.py -m MAC_ADDRESS 
    

Contributing

Step 1

  • Option 1

    • 🍴 Fork this repo!
  • Option 2

    • 👯 Clone this repo to your local machine

Step 2

  • HACK AWAY! 🔨🔨🔨

Step 3

  • 🔃 Create a new pull request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].