Library to work with Xiaomi MiBand HRX Edition Accelerometer Data. Intended for extraction of accelerometer data only, for experimentaions with ROS and gesture recognition. Check out the ROS interfacing example here.
I couldn't find a solution that worked with MiBand HRX edition. This repo is forked from creotiv/MiBand2 and modified to work with HRX bands.
The following commands were helpful in identification of services and characteristics specific to HRX bands. Xiaomi doesn't provide user descriptions for the services and characteristics, which makes it harder. There are plenty of reverse engineered solutions for MiBand2 & 3 which were extremely helpful.
gatttool -b <MAC-ADDRESS> -t random --primary
gatttool -b <MAC-ADDRESS> -t random --characteristics
-
Authentication is same as MiBand2
-
Services & Characteristics of interest
SERVICE_MIBAND1 : "0000fee1-0000-1000-8000-00805f9b34fb"
CHARACTERISTIC_SENSOR_CONTROL : "00000001-0000-3512-2118-0009af100700"
CHARACTERISTIC_SENSOR_MEASURE : "00000002-0000-3512-2118-0009af100700"
-
To receive accelerometer notification
- Write without response
0x010119
to service0000fee1-0000-1000-8000-00805f9b34fb
characeteristic00000001-0000-3512-2118-0009af100700
- Write without response
0x02
to service0000fee1-0000-1000-8000-00805f9b34fb
characeteristic00000001-0000-3512-2118-0009af100700
- Write
0x0100
to notification descriptor to enable notification
- Write without response
Data received in packets of byte size 20
, 14
or 8
.
Sample: 0x0100 0500 8200 0b00 0400 8000 0b00 0300 8100 0b00
0100 | 0500 | 8200 | 0b00 | 0400 | 8000 | 0b00 | 0300 | 8100 | 0b00 |
---|---|---|---|---|---|---|---|---|---|
- | signed x | signed y | signed z | signed x | signed y | signed z | signed x | signed y | signed z |
In the absence of linear acceleration, the accelerometer output is a measurement of the rotated gravitational field vector and can be used to determine the accelerometer pitch and roll orientation angles.
- Base lib provided by Leo Soares
- Volodymyr Shymanskyy
- Freeyourgadget Team
- ragcsalo's Comment
- Xiaomi band protocol analyze
- Tilt Sensing Using 3-Axis Accelerometer
- creotiv donate link
- Install dependencies
pip install -r requirements.txt
- Turn on your Bluetooth
- Unpair you MiBand from current mobile apps
- Find out you MiBand MAC address
sudo hcitool lescan
- Run this to auth device
python example.py --mac MAC_ADDRESS --init
- Run this to get live accel data from the device
python example.py --live --mac MAC_ADDRESS
python example.py --help
- If you having problems(BLE can glitch sometimes) try this and repeat from 4)
sudo hciconfig hci0 reset