Skip to content

An asynchronous BLE Heart Monitor library with support for additional data from Polar monitors (ECG, accelerometers, etc)

License

Notifications You must be signed in to change notification settings

fsmeraldi/bleakheart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖤 BleakHeart

An asynchronous BLE Heart Monitor library that supports additional measurements (such as ECG and accelerometer data) available from Polar sensors through the Polar Measurement Data interface.

BleakHeart is written in Python using the asyncio framework; BLE communication is based on Bleak.

Installation

Place the bleakheart.py file in the same directory as your program, or in a directory in your PYTHONPATH. BleakHeart requires Bleak; the current version was tested with Bleak v0.20.2.

Features

  • 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;
  • Offers partial support for measurements available from other Polar devices through the Polar Measurement Data interface;
  • 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).

Usage

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 examples directory for detailed examples of some of the possible workflows, and use the help function on BleakHeart objects for more information.

Limitations

BleakHeart has only been tested on a Polar H10 chest strap (under Linux), since that is what I have available. Other Polar devices are only partly supported; measurements other than ECG and acceleration are returned as raw bytearrays. Offline recording to the internal Polar H10 memory is not supported.

Credits and contributing

This software was developed by Fabrizio Smeraldi. If you would like to contribute, please get in touch.

Academic use

If you use this software for academic research, please reference this repository and let me know. I will cite your paper! :)

Disclaimer and license

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.

Resources