HXM-T: display heart rate from Zephyr’s HXM

Zephyr HXM is heart rate monitor that transmits data over Bluetooth and is ordinarily used with fitness applications running on smartphones.

Here’s idea, during indoor cycling workouts, it would be cool to see my heart rate on big PC screen instead of the phone’s small one. Since data is transmitted over Bluetooth, and the protocol is not that difficult to decode, I was able to get something running in few evenings.

The interesting part here was the bizarre mix of technology: BT data is read by Python script, the UI is GTK window with WebKit view inside. The WebKit widget displays SVG graphic, which is animated by Javascript embedded in it…

Code’s on bitbucket. Right now, it’s just a hack, no proper error handling, missing several useful features like logging HR to file, or showing battery level in separate gauge.

===========================================
HXM-T: display heart rate from Zephyr's HXM
===========================================

HXM-T reads heart rate from Zephyr's HXM over Bluetooth
and either prints it to console or displays it in a
SVG graphic that looks like car's speedometer.

Tested on Ubuntu 9.10 and Ubuntu 10.10

Requirements:

 * Zephyr HXM BT heart rate monitor
 * PC with Bluetooth
 * Python along with some libraries:
   * python-bluez
   * python-gtk2
   * python-webkit
   
To print HR to console, put on the chest strap and run:   

    python hxm.py
    
To display HR in GTK/WebKit/SVG, run:

    python ui.py
   
HXM BT message decoding logic adapted from HXM Tracker by Jari Multisilta,
http://www.my-maemo.com/software/applications.php?name=HXM_Tracker&faq=38&fldAuto=1293

7 thoughts on “HXM-T: display heart rate from Zephyr’s HXM

  1. Thank you so much for the code. Is there a way you can include R-R interval measurement in this code. Thanks!

  2. The code also works on Windows 7. You will have to install pybluez (bluetooth) and pygtk. I tested it on python 2.6 32 bit version on windows 7 and the corresponding pybluez. It gave problems on 64 bit version of python. If pygtk is giving problem then you can just comment out the gtk import statement (import gtk) in the script and the code( which displays the HR value on console) still works.

  3. Hi. I wanted to adapt the dial display code, but I’m new to coding and I’ve never dealt with Javascript or SVG. What I essentially want is to feed a value of my own, and have the needle point to that in the dial. Can you tell me how to do that?

    This is what I’ve understood so far:
    I can change the initial position of the needle in the SVG file code.
    ‘hr’ in hxm.py & ui.py refer to the heart beat rate. I’ve commented out the hxm part, and tried to put in my own values of hr. That doesn’t do anything. The dial shows the needle at the initial position as set by me, then falls down to 0.

    Please help!

  4. I’m getting the following error when I run python ui.py
    Any ideas? Thx pete

    pete@ubuntu-hp-laptop:~/Desktop/hxm-t$ python ui.py
    Traceback (most recent call last):
    File “ui.py”, line 7, in
    import hxm
    ImportError: No module named hxm

Comments are closed.