how to interface (KY-039) heart beat sensor with Arduino

What are light blocking sensors, and how heartbeat sensor works? & how to use heartbeat sensor KY 039 with Arduino are some questions that may arise in your mind while programming Arduino.

Hello guy! Welcome back to my blog today we are going to see about heartbeat sensors so let’s begin.

What is a heartbeat sensor??

A heartbeat sensor detects the heartbeat or pulse rate of a human being. Heartbeat monitoring means how many times a heart beats per minute or the number of times the heart is contracting or expanding in a minute. We can monitor the using heartbeat sensors or manually by placing two fingers at two different locations such as the wrist and neck for 30 seconds and multiplying that number by 2 to get the heartbeat rate. Some Heartbeat sensors are designed in such a way that it gives digital as well as analog output when a finger is placed on them. Sensors come in different shapes, sizes, and working principles which allows an instant way to measure the heartbeat. You can see heartbeat sensors everywhere in day-to-day life in your smartwatches, smartphones, etc. The heartbeat sensor consists of IR Led and a phototransistor. The heartbeat sensor consists of an IR transmitter and a phototransistor receiver. Phototransistor works similarly to normal transistor except it uses light-sensitive material at their base. The light which is emitted by the IR transmitter is not visible to us as it is infrared light.

Arduino heart rate monitor

How do heartbeat sensors work??

Ky-039 is a Low-cost Heartbeat Sensing Module. It consists of an IR transmitter & IR receiver. IR Led transmits an invisible light signal to the photo-transistor located at the receiving end. When light hits the base of the transistor it generates voltage until and unless there is no obstacle. 

heart beat sensor working

When an obstacle is introduced between the IR transmitter and photo receiver then no light reaches the receiver. Hence no voltage is generated. When the human finger is placed between IR led and phototransistor. IR light which is invisible light passes through blood vessels and reaches the phototransistor at receiving end. When the heart pumps a pulse of blood through blood vessels it causes a variation in the flow of blood and most of the light is absorbed by the blood and the remaining light which is not absorbed by blood is received at the phototransistor. This variation of the received light signal is converted into an electrical signal which is then fed to our Arduino board. This sensor is not very accurate, its performance may get affected due to surrounding light. External lighting may affect the output it may generate some noise signal.

Parts Required

  • KY-039 (heartbeat sensor module)
  • Arduino
  • Jumper wires
  • LED
  • Breadboard

 Heartbeat sensor (KY-039) Specification

  • Output: ANALOG
  • Frequency (Hz): 50/60 Hz
  • Temperature (deg. Celsius) :  0 to 55 Degree Celsius
  • Size : 1.9x1.5cm
  • Working Voltage: DC 3.3-5V

Schematic Diagram

Arduino heart rate monitor

Connect the ground pin of the KY-039 heart rate sensor to the ground pin of Arduino, the VCC pin to 5v, and the Signal pin to 8.

Code -

int heart_pin = A0;
int heart_value;
void setup() 
{
  pinMode(heart_pin,INPUT);     
  Serial.begin(115200);
}
void loop()
{
 heart_value = analogRead(heart_pin);
 Serial.println(heart_value);
 delay(200);
}

First, initialize pins of sensors & LED and variables. We have declared a variable name heart_value to read values from heartbeat sensors. In void setup, we configure pins as INPUT or OUTPUT. We want to read values from the sensor pin so we will declare it as INPUT. Also, we configure the baud rate to 115200.

In a void loop, we continuously read values from the heartbeat sensor and store values in variables and display them in the Serial plotter.

OUTPUT - 

heart rate finger monitor

 Conclusion - 

Today we learn about what is KY 039 heartbeat sensor is, how to use a heartbeat sensor with Arduino,  & working principles of the heartbeat sensor. ky-039 heartbeat sensor is good for hobbyist purposes as the sensors do not show accurate data. this sensor is useful in domestic applications. the ky-039 sensor is a small, inexpensive, and easy-to-use sensor.


"I hope you find this IoT blog very helpful to you. In the upcoming lesson, we will see more about IoT sensors till then bye. See you all in my next blog."

Close Menu