Heart beat Sensor and “ECG” Display

Note : This page has been superseded, please use this new guide.

Heart beat sensors now seem to be cheap and plentiful (around 2 USD, a little less than 2 GBP and around 1.80 Euros). Here we’ll hook one up with an OLED display to show the results. Let’s Go…

The heart beat sensor I bought is shown below:

They should NOT be used as a medical device (XTroncial official disclaimer!), if you have any concerns about any part of your health – see a Doctor, not a web page about hooking up cheap heart rate sensors to cheap micro-controllers!  But…. having said that, for fun I’ve found it very accurate in its readings, combined with some sort of graphical plot on a display its a really neat easy project.

Video Guide
If you want something more visual a video guide is available here:

How they work
As can be seen there are only three wires to these devices. One is power, the other ground and the final one is the analogue signal.  So, these are not digital devices like the temperature sensor or the many other sensors available. This device outputs a voltage from 0V to VDD (supply voltage) depending on what they “sense”. They work by emitting an Infra-Red signal from an IR-Diode onto your skin. Just underneath your skin are capillaries carrying blood. Every time your heart pumps there is  an small increase in blood flow/pressure. This swells the capillaries slightly, this slightly more filled capillary reflects more infra-red than at times when the heart is not giving your blood a “push”. An Infra-detector on the device senses the different reflected IR levels. Some simple comparator circuitry converts this into a voltage signal which we can read with the Arduino’s analogue inputs.

Connecting it up
Any micro-controller with an analogue input should work as the device operates from 3 -6V range (maybe even higher). Just connect the signal line (labelled “S” on my device) to an analogue input pin. The value you read from the pin will be in the range of zero to whatever the top value is on your particular micro-controller. For the normal default Arduino the range is from 0-1023 (1024 values).  Here is the connection diagram showing just the Heart Beat connections.

This shows :

Pulse Sensor “+”  to  +5v on Arduino
Pulse Sensor “-” to Gnd on Arduino
Pulse Sensor “S” to A0 on Arduino

To show your heart beat graphically you can use the Arduino IDE in-built serial monitor plotter. Load up the code below into your IDE, then upload to your Arduino. Then select “Tools->Serial Plotter”

Here’s my screen shot showing you what to expect. The Arduino Serial Plotter plots a value sent to it on a graph against time.

Using your own display
The in built plotter is great for a quick play but it doesn’t show you your heart rate in BPM (Beats Per Minute) at the same time. So for this project we’re adding in our own OLED display. These are readily available and the set up has been discussed in this article before, so we’ll just add it in here without further discussion. Wiring diagram below:

Here’s the code that will run this display, showing your “ECG” trace and your BPM. It was quite quickly “knocked up”, so apologies for any inefficiency.

The output of this can be seen in the picture at the start of this article.

Use and limitations
As mentioned these are cheap but remarkable sensors but don’t expect to strap one to your finger and go jogging. They are very sensitive to movement and moving your hand about will cause massive swings of values – even if taped on. Also, tape them on too tightly and it reduces sensitivity dramatically. They can only be used if your hand is still, having said that you could still measure your Heart Beat at resting and just after exercise to compare. If you have any tips for monitoring with these devices whilst exercising please leave a comment.

Extending the project
A piezo sounder or speaker would be a nice addition, to give the “beep” sound effect, why not post your design if you implement this! New : See later after “Addendum”, this has now been added.

Addendum
A request was made for the BPM to be output as a raw value to the serial monitor (not plotter). Although not tested the code below should accomplish this:

Adding a Piezo Buzzer
To make this a little more “realistic” you could add a sound output. So the addition of a Piezo buzzer has been added. Simply connect it to pin D8 and GND, load up the code below and you’ll be good to go. This code beeps every heart-beat. it does not sound a “flat-line” single tone if limited activity. This is because it was not always very reliable due to the nature of the sensor which detects spurious pulses. In the real world a heart-beat monitor has several sensors monitoring actual heart activity. The photo shows my speaker addition.

A video is available showing this addition