UPDATE: See the next stage in this project here!

Introduction:

Like many out there, I enjoy a good exercise session, whether it be indoors or outdoors. As part of that I purchased a Polar branded heart rate monitor, which came with a "Wearlink" chest strap and RS300Xsd receiver watch.
The watch is able to do quite a bit of analysis on its own, in terms of recording heart rate averages, target zones and the like, but without the additional FlowLink device there is no practical way of moving this data to a PC for further manipulation (in any case, the FlowLink device can only synchronise to a website run by Polar).

Having recently started out with the Arduino platform and some simple programming (I can make an LED blink!), a solution seemed obvious, build my own receiver unit and do with the data whatever I please...

Possibilities and Requirements:

The obvious key requirements of the monitor are:

  • To be portable (exercise takes you places, and usually your heart is with you at the time!)
  • Must record data to non-volatile storage media for later review.

Ideally it should interface with my existing Polar strap, as I'm not really one for having wires hanging off my chest while exercising.

If possible, I'd also like to add a display of some form to show statistics/heart rate, or some other information, as well as some form of input to change settings on the device without having to reload the sketch.

Putting things together:

After a bit of research, it turns out an OEM module is available to interface directly with Polar branded heart rate straps, the RMCM01 module available from Sparkfun.

RMCM01-small.jpg

This module does all the hard work of reception and filtering of the signal (on 5.5kHz), and outputs a 1ms pulse at 3 volts for every heartbeat detected. The module is conveniently small and only requires a 32kHz crystal to provide a clock signal. If required, an additional antenna coil can also be added to the module to boost reception range.

As for the brains of the unit, I decided to work with an Arduino Uno due purely to the simplicity of using pre-existing hardware and code from libraries.

arduinoshields-extra-small.jpg

I had a spare Adafruit 2.8" TFT LCD touchscreen from previous experiments, which conveniently covered the storage, display and input options all in one neat package. This wasn't without a few drawbacks, as this particular shield uses almost all the available pins on the Uno. I also decided to drop the logger shield I originally planned to use for storage and timing, as it would likely misbehave with the LCD (or at least make me write a lot more code than I wanted to) and could be more profitably used elsewhere. As a result I decided to build a new shield for the RMCM01 module, even though this would leave me without the convenience of an RTC for accurate timing.

 

 

I also drew myself a rough block diagram of how things might work, as shown below:
Arduino-HRM-Overview-small.gif

Programming:

To ensure I got an accurate BPM reading, I connected the RMCM01 output pin to the Arduino's D2 to allow me to use one of the external interrupts. Using an interrupt meant that I would never miss a single pulse from the module, and I could avoid introducing any delay() lines, which might disrupt or distort time recordings.

The code fired by the interrupt simply measures time between the current pulse and previous pulse recorded in milliseconds, then uses that to calculate a BPM. To avoid too much random variation, the calculated values are kept in rolling buffer of the last five readings and averaged, as shown in the code segments below:

volatile int diff1 = 0;
volatile int diff2 = 0;
volatile int diff3 = 0;
volatile int diff4 = 0;
volatile int diff5 = 0;

void HRpulse()
{
  pulsetime = millis();
  rollBuffer();
  diff1 = pulsetime - lastpulsetime;
  if (diff5 != 0) {
    BPM = 60000 / ((diff1 + diff2 + diff3 + diff4 + diff5)/5);
  }
  lastpulsetime = pulsetime;
}

void rollBuffer()
{
  diff5 = diff4;
  diff4 = diff3;
  diff3 = diff2;
  diff2 = diff1;
  diff1 = 0;
}

Drawing the graph was a bit more complex, as the TFT LCD module is not really designed as a graphing device. After trying with a line graph, bar chart and scatter plot, I chose the bar chart, as it gave the most visible display of heart rate without drawing crazy averages or being difficult to see due to overlaps. For starters the device draws a single column per pixel width, and has no actual axes (I'm planning to add these in a bit later!).

For convenience of use I also added a simple text display of beats per minute in the top right corner. Each time a column is drawn, the same value displayed is recorded as a line in a CSV file on the microSD card.

To take a peek at the full sketch (this is prone to being updated), please click Here

Trial, field testing and ongoing modifications:

After building and doing some basic tests on the monitor, I decided to take it for a spin on an actual exercise session. Pretty quickly some obvious flaws became apparent:

HRM-Operation-small.jpg

  • The device with a Ni-MH battery is just too bulky, it can't be readily strapped to the body, wrist or leg (I ended up working with it strapped on my hip)
  • Fragility - Shields stuck together work just fine in a lab, but can be pretty easily knocked or jarred while exercising. I ended up half dislodging the upper shields half way through the session and had to rebuild and restart it.
  • Not having an RTC is really, really annoying! There is no easy way to figure out what day I did what exercise (particularly if the device is restarted during a session), and the internal clock is prone to a bit of drift which can slightly throw out measurements.
  • Further work needs to be done on the BPM calculations, to remove unusual readings caused by poor reception or interference. (This might also be fixable by adding an external antenna loop)
  • User interface modifications would really help usability, such as adding definable options via the touchscreen, a Y axis measure and/or grid, and a few more statistics display elements

My next step is to work out a more practical power supply, most likely a set of suitable of LiPo cells, which would be smaller, flatter and lighter. In any case I already have a good balance charger available!

Additionally, I will need to sort out a way to make the whole set of shields more durable to external shocks and stresses. At this stage a simple enclosure box might work, although a custom enclosure would be more useful for adding straps.

I left spare space on the RMCM01 shield deliberately in case I decided to add an RTC of some form further down the line. Most likely I'll look at adding a suitable 1wire RTC to an available pin when I get around to it, and rework the sketch to support it. At the same time I'll probably also add an antenna loop and variable resistor for the RMCM01 module to improve and tweak reception.

The user interface really does still need a lot of work, all it does is draw a rough graph based on BPM as sampled per second. As user input is currently non-existant, this can't be changed without uploading the sketch with new values defined (inconvenient!) In the future I'm planning to store these values on the SD card, as that will make them readily accessible both through the device and on a PC while copying recorded files.

Suggestions and modifications are welcome! As changes are made I will update this page with my progress...

Comments:

Posted by regiscruzbr on
Good Job!!!
Posted by James Hardiman on
Great stuff!

I am expecting two pulse sensors http://pulsesensor.com/category/the-long-blurb/ any day now. Note that their code, including their Processing code (do you know about www.Processing.org ?) is available for download from that site. Some of the Processing code may well be usable on the Arduino.

I am interested in calculating and displaying Heart Rate Variability, and also Coherence. I currently have an emWave2 machine, but want something I can use with eyes closed, and emWave uses visual coaching and visual feedback.

We are also developing the "Baby Duino" ... as small and light as possible, and under £5, $8, which will be easier than lugging around a whole Arduino!

I'll be interested to see your code; hadn't thought of using a touch screen, but that might be very useful.

Also, I'm expecting to FINALLY get my hands on our 3D printer soon, so will be able to make a case!
Posted by Webmaster on
Hi James, I had a good read through the pulsesensor site and also hit Google for some more info on the emWave2 device, which I hadn't heard of before (looks like a neat gadget!)

My code is linked above the Trial, field testing and final notes section if you would like to take a look too.

As for heart rate variability, I was thinking that may well be the next bit for me to implement in the monitor (in terms of software), I do suspect I need an additional bit of code for the rolling buffer that will stop error values sneaking in, currently the average will smooth things out, but if contact is lost with the sensor strap or I have a slight arrythmia (pretty sure I don't, but its not uncommon!) it can mess up the readings.
Maybe a sanity check on the period between heartbeats based in part on the current BPM and expected minimum and maximum BPM would be the answer here... Definitely food for thought for me!
Posted by Rich on
Thanks for your post on Hackaday. With two RMCM01s, two polar sets, the emmWave system and HID IR device, two pulsesensors on the way, a pulse oximeter, and several other devices that track pulse, pressure, and HRV, sonification has proven to be the most valuable feedback mechanism for me.

Simply connecting ordinary headphones to the RMCM01 signal source provides a background click that delivers a surprising amount of information for mental processing along with the watch display and the averages available, Google "hrv sonification" and you'll get a flavor of where you can go. The most beautiful rendition is HRV of mother and fetus. (http://www.michaelfalkner.de/herzmusik/heartmusicexamples.html) Not real-time so you'll run across software to do the sonification possible by recording the heart beat signal and then processing using Audacities beat finder. Complete the system using Kubios, open source HRV software from the Unniversity of Findland.

Your code gave me some clues to use with my Arduinos to enable a hardy real-time upgrade to monitoring the click of the 3v 1ms audio pulse. Previously emWave, SuperCollider, now Chuck made a netbook necessary to handle the audio signal plugged into the sound card. Capturing actual blood flow dynamics with the IR pulsesensors soon to arrive will give yet another dimension to the data available to the speedy processor I try to always have on.

Thanks!
Posted by phillips321 on
Great job. How about fixing the entire unit in a small backpack (camelback sized). You could also hook yourself up further by reading things like temp, perspiration, etc...

Power, most people run in the day.... solar on the outside of the backpack would be great!
Posted by Tina on
Hello,
I am a first year masters student of Art and Technology at the California Institute for the Arts. I have two projects where I want to use the data from the heart rate of participants in my installations to communicate with Processing via arduino and produce associated sounds and visuals. I am just beginning to get my head around programing and electronics. There is a kickstarter device that has been prototyped for exactly what I would like to do but it is out of stock.

http://www.kickstarter.com/projects/1342192419/pulse-sensor-an-open-source-heart-rate-sensor-that?ref=live#

I am researching other avenues. I have come in contact with the polar wrist band product and heart rate interface. I am not sure how to extract the data from the polar products in a way that I can then manipulate it into Processing. Also I am more interested in a small profile device that can read a pulse from the palm or the fingertip when somone simply lays their hands on a sensor area. What can you suggest for an on the shelf device that I can interface with an arduino? Your experience and guidance would be greatly appreciated. Thank you so much,
Tina Notaro
Posted by Webmaster on
Hi Tina,
There should be quite a few options open to you, looking at the kickstarter project that looks very similar to the product mentioned above at http://pulsesensor.com/category/the-long-blurb/
Another alternative is to follow the same path I did, the Polar transmitter could instead be attached to some palm contacts (tin cans) which could be held in each hand by the user, then interfaced in the same way through the RMCM01 module...
Posted by hiit on
Do you have a Facebook fan page for your site?
Ron
Posted by Peter on
Hello!
Great Job!
Please, help me, I'm looking for an RMCM01 module, where can I get one? Everywhere the modul is out of stock, I can't buy one. Do you have a tip where can I get one?
Thank You!
Peter
Posted by Webmaster on
Hi Peter,
It seems the RMCM01 module has been discontinued by Sparkfun, which was where many suppliers online seemed to be getting their stock in turn. I've had no success finding a supplier since I got my modules from Proto-Pic.co.uk. They have since run out of stock too. It might be worth contacting Polar themselves and seeing if they supply to anyone out there who might be able to sell small quantities of the module.
Posted by Augusto Carmo on
I found this on: http://www.canakit.com/polar-heart-rate-module-rmcm01-sen-08660.html
Posted by Miguel on
Great project ... I Will reply and I Will make my own contribution for a customized application ... Thanks
Leave a Reply



(Your email will not be publicly displayed.)