An asynchronous BLE Heart Monitor library that supports additional measurements available from Polar sensors through the Polar Measurement Data interface (currently, ECG and accelerometer data from the Polar H10, and PPG from the Polar Verity).
BleakHeart is written in Python using the asyncio framework; BLE communication is based on Bleak.
Install from PyPI using pip:
python3 -m pip install "bleakheart"
- Supports heart rate acquisition for devices supporting the standard BLE heart rate service, including RR intervals, instant heart rate, energy expenditure and (client-based) time stamps;
- Reads Accelerometer and ECG signals from the Polar H10 chest strap;
- Reads PPG data from the Polar Verity, including in SDK mode;
- Offers partial support for other measurements available through the Polar Measurement Data interface, possibly from other devices;
- Normalises Polar sensor timestamps to Epoch time;
- Reads the battery charge state through the standard BLE battery service (also available on other types of BLE devices);
- Compatible with Jupyter Notebooks (IPython version 7+, IPykernel version 5+).
BleakHeart supports a variety of software design choices. Specifically:
- A data producer/consumer model can be easily implemented by asking BleakHeart to push sensor data onto asynchronous queues;
- Alternatively, data can be sent to a callback. Simple tasks such as sensor logging can be accomplished with only a minimal understanding of
asyncio; - All data are tagged with their measurement type; thus the same queue or callback can be used to handle different types of measurements if desired.
Please see the getting_started notebook in the examples directory, or see this video introduction.
The examples directory also contains detailed stand-alone examples for some of the possible workflows. Use the help function on BleakHeart objects for more information.
BleakHeart has mainly been tested on a Polar H10 chest strap under Linux and on a Verity sensor under Windows. However, reports from Windows and MacOS users have been positive. Other Polar devices are only partly supported; measurements other than ECG and acceleration on the H10, and PPG on the Verity, are returned as raw bytearrays. Offline recording to the internal Polar H10 memory is not supported.
This software was originally developed and is maintained by Fabrizio Smeraldi. Many thanks to
- Alex Ong - alex-ong,
- Andy Scott - scott86,
- Chris Spooner - Chris-Spooner999,
- Fareza - farezae,
- Léo Flaventin Hauchecorne - hl037,
- Wesley Huff - HufflyCodes,
- Will Powell - WillPowellUK
for testing, suggestions and code. If you would like to contribute, please get in touch.
If you use this software for academic research, please reference this repository and let me know. I will cite your paper! :)
Polar is a trademark of Polar Electro Oy; Bleak is an open-source BLE library developed by Henrik Blidh. The author is not affiliated with either.
This software is provided subject to the terms of the Mozilla Public License version 2.0, in the hope that it will be useful; see the LICENSE file for details.
- The official Polar BLE SDK, contains software for Android and iOS and some interesting documentation, in particular:
- An explanation of ECG on the Polar H10
- An older but detailed specification of the proprietary Polar Measurement Data service
- More details on the PMD frame types
- Decoding examples for the Verity ACC delta frames: see here and here
- An explanation of the time system in Polar devices (BleakHeart transparently normalises this to Epoch time).
- The Heart Rate service specification, on the BLE SIG website.
- The Battery service specification, on the BLE SIG website.
