Introduction: Heart Rate Monitor

I built a relatively simple heart rate monitor circuit that is monitored and controlled by an Arduino Uno. The theory of operation is based on the fact that infrared (IR) light is partially absorbed by blood. When your index finger is placed between the IR emitter and detector, the amount of IR light absorbed by the finger (and thus transmitted into the detector) varies in sync with your heart beat.

The Arduino monitors and filters the IR detector's signal, and turns a blue LED on and off in sync with your heart beat. The signal filtering library used by the Arduino code can be found here. The filtering is done mathematically and not with an external circuit.

I also modified some Processing code that monitors and plots the filtered signal from the serial monitor.

UPDATE: I replaced the previous Arduino code with a slightly "cleaner" version in which I made a few changes that I believe result in a more robust, less noisy signal. First, I amplify the signal before doing the filtering. Second, I use a band-pass filter with a passband of 1 hz - 3 hz. Also, with the rollout of Arduino 1.6.6 and the Serial Plotter tool, it's quite easy to see the heart rate signal without running the Processing code that I included. Of course, if you want more control over the display, you're going to need more than the Serial Plotter tool, but it's a good first start.

Step 1: Building the Circuit

Build the circuit shown. I used this emitter detector pair from SparkFun. The resistor in series with the emitter is 100 Ohm, and the resistor in series with the detector is 10 kOhm. I use a blue LED (right side of bread board) in series with a 100 Ohm resistor.

Step 2: Connections to the Arduino Uno

The 5 V pin on the Arduino powers both the IR emitter and detector. The Analog 0 input pin monitors the voltage after the 10 kOhm resistor, and the Analog 8 output pin controls the voltage on the blue LED.

Step 3: Output

First upload and run the Arduino code. Second, run the Processing code. The Processing code monitors the serial port output and plots it. The shape of the output pulses is very sensitive to how the index finger is placed between the emitter and detector (position, pressure, etc.), and you can see this in the video below as it's impossible to hold my index finger perfectly still for the duration of the video.

Update: On a whim, I removed the blue LED from the circuit and retested. The new video below shows a markedly improved heart rate signal. I'm not sure what kind of interference (optical? electrical?) was occurring with the Blue LED near the IR detector, but getting rid of it certainly improved the signal. I'll continue testing but I'm curious to see what others find.

Comments

author
tomatoskins made it!(author)2015-07-06

Love it! Thanks for sharing!

author
pureAmericanbrother made it!(author)2015-07-06

Thank you for the feedback!

author
Malmosely made it!(author)2017-05-10

great project - works perfectly. Would the revised processing code showing the BPM be available

MM

author
pureAmericanbrother made it!(author)2017-05-26

#include <FilterDerivative.h>

#include <FilterOnePole.h>

#include <Filters.h>

#include <FilterTwoPole.h>

#include <FloatDefine.h>

#include <RunningStatistics.h>

float amplifiedSignal; //amplified HR signal

float filteredSignal; //filtered HR signal

int threshold = 200; //FILL IN THIS LINE WITH THE THRESHOLD SIGNAL VALUE THAT YOU'RE GOING TO USE

int heartbeatCount = 0; //variable keeps track of number of heartbeats

int beatsPerMinute; //HR in units of bpm

int numOfHeartbeats = 5; //total number of heartbeats used to calculate heartrate

float startTime; //time in seconds when first heartbeat occurs

float stopTime; //time in seconds when the last heartbeat (numOfHeartbeats) occurs

bool possibleHeartbeat = false; //if the signal is above the threshold, we may have a peak

void setup() {

Serial.begin(9600);

}

// filter out frequencies below 1 Hz.

float highFilterFrequency = 1;

// create a highpass filter that only keeps frequencies above highFilterFrequency

FilterOnePole filterOneHighpass( HIGHPASS, highFilterFrequency );

// filters out frequenceies greater than 3 Hz.

float lowFilterFrequency = 3;

// create a lowpass filter that only keeps frequencies below lowFilterFrequency

FilterOnePole filterOneLowpass(LOWPASS, lowFilterFrequency);

void loop() {

//The next line applies a band pass filter to the signal

amplifiedSignal = 100*analogRead(A0);

filteredSignal = filterOneHighpass.input(filterOneLowpass.input(amplifiedSignal));

//Serial.println(filteredSignal);

//check to see if we have a heart beat

if (filteredSignal > threshold)

possibleHeartbeat = true;

else if (possibleHeartbeat == true && filteredSignal < threshold){

heartbeatCount+=1;

possibleHeartbeat = false;

Serial.println("heartbeat, ba-bum");

//start timing if we have the first heartbeat

if (heartbeatCount == 1)

startTime = millis()/1000.0; //starting time in seconds

//if we count "numOfHeartbeats" heartbeats, calculate a heartrate

else if (heartbeatCount == numOfHeartbeats){

stopTime = millis()/1000.0; //stopping time in seconds

beatsPerMinute = 60*(numOfHeartbeats-1)/(stopTime-startTime);

Serial.print("Your HR is : ");

Serial.print(beatsPerMinute);

Serial.println(" bpm");

heartbeatCount = 0;

}

}

author
DanielF214 made it!(author)2016-05-02

Hey, nice work! Is the receiver a phototransistor or some other kind of magic?

author
pureAmericanbrother made it!(author)2017-01-22

I've replaced the separate led and sensor with this combination.

https://www.adafruit.com/product/2349

It works even better. If you have any questions, let me know.

author
ShubhJ2 made it!(author)2017-04-22

Can you share the updated schematic?

author
pureAmericanbrother made it!(author)2017-05-26

Does this help?

IR_Combo_Schem.GIF
author
ShubhJ2 made it!(author)2017-04-22

With the led sensor combo

author
Abdul+KarimK1 made it!(author)2017-03-19

do u have source code for pulse counter in aruino?

author
vaibhavn15 made it!(author)2016-09-12

please can u upload your exact ckt diagram plz.and is the ir pair used is diode pair or diode phototransistor pair .i tried but i recieved a constant high signal when index finger was placed.

author
Anandas7 made it!(author)2016-07-06

hello friends, good project ..i tried it but if run processing software there will be error like this 'please update your code'...how to solve it? i am using processing 3.1.1

author
%D8%B9%D9%84%D9%8A%D8%A78 made it!(author)2016-02-08

Hi

how are you frind please help how do find the compiler source code for this project please reply

author
purgoufr made it!(author)2015-11-29

Hi thanks for sharing, I have a question. Where is the Analog 0 input on your arduino code? How to sense arduino the A0 on your code?

author
pureAmericanbrother made it!(author)2015-11-29

Look in the loop!

filterOneLowpass.input(filterOneHighpass.input(analogRead(A0)));

author
purgoufr made it!(author)2015-11-29

Ooh I saw , thank you so much :)

author
Shiva+PrasanthA made it!(author)2015-10-28

Arduino code error :'(

author
akshay.d21 made it!(author)2015-10-02

hey i tried implementing on an arduino nano but to no avail. the ino file is uploaded correctly but nothing shows out on processing. What should i do ? connections are proper as well.

author
vaithi made it!(author)2015-09-09

Hi thanks for the project , but i have some problems . when i tried to open the .ino project file using arduino ide it says error . can u please send me the codes for the same to the email id pls

author
akshay.d21 made it!(author)2015-07-10

Hi,

Thanks for sharing such an easy and useful instructable ! :)

Can you tell me a way yo display the count on an lcd or a screen ? i am new to embedded systems.

Would be helpful for me if you can guide me.

author
pureAmericanbrother made it!(author)2015-07-10

Hi,

I'm glad you found this project useful.

I don't have experience connecting to an LCD but a quick search of this site revealed many resources that could be adapted to this project.

author
akshay.d21 made it!(author)2015-08-18

Actually i was looking to implement it. Can this work on Arduino Nano ?

Also, if i want to count the pulses that you are displaying there on screen .....can i do it ? and then print them on serial monitor ? As in beats / pulses per min ?

So i can then print the same serial data on an LCD. I know LCD interfacing but i dont know how to convert that pulse data to Pulses / min !

Please help me. I am a newbie and would be glad if you helped. :)) Thanks.

author
akshay.d21 made it!(author)2015-08-17

Thank you so much brother ! :) Sorry for the late reply. Had my exams on.

author
AdrielC made it!(author)2015-07-07

Brilhante, muito inteligente ! :)

author
pureAmericanbrother made it!(author)2015-07-07

Muito obrigado!

About This Instructable

28,446views

302favorites

License:

More by pureAmericanbrother:Heart Rate Monitor
Add instructable to: