Giter VIP home page Giter VIP logo

bleheartratelogger's Introduction

BLEHeartRateLogger.py

BLEHeartRateLogger.py is a Bluetooth Low-Energy (BLE) Heart Rate Monitor (HRM) data logger written in Python for Linux. With this tool you can log your heart rate and heart rate variability (RR) during exercise, sleep or whatever comes to mind.

Communication with the BLE HRM is established using hcitool and gatttool. The output of those tools is then parsed and saved to a sqlite database.

The code was used successfully with the following devices:

  • Polar H7
  • Zephyr HxM
  • Wahoo TICKR

Installation

On Debian/Ubuntu:

$ apt-get install bluetooth python-pexpect
$ git clone https://github.com/fg1/BLEHeartRateLogger.git

Run the script as root user or correctly specify the rights on hcitool and gatttool.

Usage

To start the tool (as root or with correct rights):

# ./BLEHeartRateLogger.py
2015-01-10 13:40:59,326  Trying to find a BLE device
2015-01-10 13:41:00,856  Establishing connection to 00:11:22:33:44:55
2015-01-10 13:41:01,115  Connected to 00:11:22:33:44:55
2015-01-10 13:41:03,412  Heart rate: 65
2015-01-10 13:41:04,357  Heart rate: 65

To quit the tool, simply Ctrl-C.

Command line options:

usage: BLEHeartRateLogger.py [-h] [-m MAC] [-b] [-g PATH] [-o FILE] [-v]

Bluetooth heart rate monitor data logger

optional arguments:
  -h, --help  show this help message and exit
  -m MAC      MAC address of BLE device (default: auto-discovery)
  -b          Check battery level
  -g PATH     gatttool path (default: system available)
  -o FILE     Output filename of the database (default: none)
  -v          Verbose output

Using the tool as non-root user

The setcap command can be used to give hcitool permission to be used by users other than root:

sudo setcap cap_net_raw+eip $(eval readlink -f `which hcitool`)
sudo setcap cap_net_admin+eip $(eval readlink -f `which hciconfig`)

Troubleshooting

In case the tool is not able to connect to your BLE HRM, first check manually that your computer and BLE HRM device are able to talk to eachother using the following steps (as root).

# hcitool lescan

This should list the BLE devices around you with their MAC address with something which looks like this: 00:11:22:33:44:55. You can safely Ctrl-C when the device has been found. We will the connect to the device:

# gatttool -b 00:11:22:33:44:55 -I

This should open a prompt. Type the following commands:

> connect
> characteristics
> exit

In case one of the steps mentionned above fails, check your Linux installation and eventually bluez version (>= v.5 recommended).

Contributing

Contributions are welcome.

  1. Fork the repository
  2. Create your feature branch (git checkout -b my-feature)
  3. Commit your changes (git commit -am 'Commit message')
  4. Push to the branch (git push origin my-feature)
  5. Create a pull request

bleheartratelogger's People

Contributors

fg1 avatar paulfertser avatar anirudha152 avatar martingranados avatar gloomy-ghost 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.