From KY-039 To Heart Rate

Get your heart rate, not just an IR sensor reading.

Apr 1, 2018

93499 views

28 respects

Components and supplies

1

Arduino UNO

1

Jumper wires (generic)

1

KY-039 heartbeat sensor

Project description

Code

Final version

c_cpp

The program reads the heartbeat and prints the rate in the serial window.

Downloadable files

Circuit

Circuit

Circuit

Circuit

Comments

Only logged in users can leave comments

emohseni

a year ago

Does anyone know how can I print the serial monitor result on the qapass lcd arduino i2c ?

Anonymous user

2 years ago

We are getting output without giving input. Kindly help us.

ryanisme69

2 years ago

I am pretty sure that is normal

Anonymous user

2 years ago

This is epic. Really love what you did.

Anonymous user

2 years ago

Hello, I want to ask what is the code for the smoothing part?

Anonymous user

2 years ago

Very nice explanation of how to low pass filter the data to get a reasonable reading. One side note: if your heart is beating 200/min, it is in fibrillation and getting a reading is the least of your worries ;^)

Anonymous user

2 years ago

Hello, I watched your study with great interest and I would like to use this example to perform signal processing with 16 year old students in a school in France. Do you still have the raw sensor data series? If yes could you put them in access Thank you and congratulations for this work. Pierre-Marie

Anonymous user

2 years ago

el mejor proyecto con ese sensor que he visto. gracias por el aporte. Y si tiene razon la gente espera 'demaciado' de ese pequeño sensor. pero sabiendolo usar puede tener una buen sample.

Anonymous user

2 years ago

Hi everyone. I have a problem. among all heart rate values ​​there are also very high numbers like 100. Can anyone tell me why? However nice code

Johan_Ha

2 years ago

If you're running my code and you get readings like 51, 53, 50, 49, 100, 97, 48, 51... ...it just means that the filter failed to filter out all noise. The value 100 just means the filtered curve didn't just fall between two heart beats. It made a tiny jump in the other direction and the program thought it was a heartbeat, but it was probably just your finger moving a little between the IR emitter and IR receiver. My program really needs some algorithm, which would take care of self calibrating.

Johan_Ha

2 years ago

Have a look at this curve: https://hackster.imgix.net/uploads/attachments/459527/finest_n6KNB7vgPJ.png?auto=compress%2Cformat&w=740&h=555&fit=max It's the filtered curve. After the first two peaks there's a notch in the curve when it goes down after the peak. The notch is somewhere at 1/3 of the way down. If the curve goes up at the notch, it might be recognised as a heart beat. A better filter would even out that notch. It's all about filtering the original signal, plotting the filtered signal, refining the filtering algorithm, doing a kind of a pattern recognition on the plotted signal and measuring the time between repeated patterns. How the signal looks like depends on your sensor, your finger tip, your nail lacquer, your electronics, ambient light and whatnot. The best of algorithms would be self adjusting. I guess professional heart rate monitors work like that. Usually one is interested in the mean value of the heart rate at a given time, say within 30 seconds. Finding out how much each beat deviates from the mean might also be interesting, as this paper proposes: https://www.ncbi.nlm.nih.gov/pubmed/8044922

Anonymous user

5 years ago

Hello, I watched your study with great interest and I would like to use this example to perform signal processing with 16 year old students in a school in France. Do you still have the raw sensor data series? If yes could you put them in access Thank you and congratulations for this work. Pierre-Marie

Anonymous user

5 years ago

We are getting output without giving input. Kindly help us.

Anonymous user

2 years ago

I am pretty sure that is normal

Anonymous user

5 years ago

Hello, I want to ask what is the code for the smoothing part?

crevatinfrancesco

5 years ago

Hi everyone. I have a problem. among all heart rate values ​​there are also very high numbers like 100. Can anyone tell me why? However nice code

Johan_Ha

2 years ago

If you're running my code and you get readings like 51, 53, 50, 49, 100, 97, 48, 51... ...it just means that the filter failed to filter out all noise. The value 100 just means the filtered curve didn't just fall between two heart beats. It made a tiny jump in the other direction and the program thought it was a heartbeat, but it was probably just your finger moving a little between the IR emitter and IR receiver. My program really needs some algorithm, which would take care of self calibrating.

Johan_Ha

2 years ago

Have a look at this curve: https://hackster.imgix.net/uploads/attachments/459527/finest_n6KNB7vgPJ.png?auto=compress%2Cformat&w=740&h=555&fit=max It's the filtered curve. After the first two peaks there's a notch in the curve when it goes down after the peak. The notch is somewhere at 1/3 of the way down. If the curve goes up at the notch, it might be recognised as a heart beat. A better filter would even out that notch. It's all about filtering the original signal, plotting the filtered signal, refining the filtering algorithm, doing a kind of a pattern recognition on the plotted signal and measuring the time between repeated patterns. How the signal looks like depends on your sensor, your finger tip, your nail lacquer, your electronics, ambient light and whatnot. The best of algorithms would be self adjusting. I guess professional heart rate monitors work like that. Usually one is interested in the mean value of the heart rate at a given time, say within 30 seconds. Finding out how much each beat deviates from the mean might also be interesting, as this paper proposes: https://www.ncbi.nlm.nih.gov/pubmed/8044922

Anonymous user

6 years ago

This is epic. Really love what you did.

Anonymous user

7 years ago

el mejor proyecto con ese sensor que he visto. gracias por el aporte. Y si tiene razon la gente espera 'demaciado' de ese pequeño sensor. pero sabiendolo usar puede tener una buen sample.

Anonymous user

7 years ago

Very nice explanation of how to low pass filter the data to get a reasonable reading. One side note: if your heart is beating 200/min, it is in fibrillation and getting a reading is the least of your worries ;^)

Anonymous user

7 years ago

Nicely explained smoothing out the actual sensor readings!