Thursday, November 26, 2020
Home Arduino Strarter Kit KY-039 | ARDUINO HEARTBEAT SENSOR

KY-039 | ARDUINO HEARTBEAT SENSOR

The KY-039 Heartbeat sensor is one of the cheapest sensors to get a start on Arduino like the Sound sensor. It cost less than a dollar, which can help in a lot of heat beat related projects. It usually comes with a starter sensor kit for Arduino.
USA purchase link
UK purchase link
Germany purchase link

Arduino Heartbeat Sensor KY-039
Arduino Heartbeat Sensor

KY-039 Specifications:

  • Working voltage: 5V DC
  • On-board RT9161
  • Size: 24 x 22 x 8mm

How does KY-039 work :

The KY-039 gives an “analog” value from 0 to 1023, depending on the amount of infrared light the light sensor has received. The higher the value, the less infrared light. When you place your finger between the IR led and the light transistor of the sensor your heartbeat dilates the blood vessels in your finger, which will filter the IR and creates a signal. This signal is converted into a heartbeat rate like 66 BPM (beats per minute).

graph
Graph generated after plotting the values from the KY-039

 

graph2
Graph of average values

 Pin Configuration :

Arduino Heartbeat Sensor KY-039
Pin Configuration

The KY-039 has three pins

  • The Vcc or the 5V
  • The GND
  • The Signal

 Arduino Wiring:

Firstly, Connect the Sensor GND to Arduino GND.

Then, Connect Sensor Signal to Arduino PIN A0.

Lastly, Connect  Sensor Vcc+ to Arduino +5.

Arduino Code :

int ledPin=13;
int analogPin=0;
 
void setup()
{
  // The included LED of the Arduino (Digital 13), will be used as output here.
  pinMode(ledPin,OUTPUT);
   
  // Serial output initialization
  Serial.begin(9600);
  Serial.println("Heartbeat detection example code");
}
 
const int delayMsec = 60; // 100msec per sample
 
// The main program has two tasks:
// - The LED will light up after detecting a heart beat
// - Calculating of the pulse and outputting of it at the serial out.
 
void loop()
{
  static int beatMsec = 0;
  int heartRateBPM = 0;
      Serial.println(rawValue);
  if (heartbeatDetected(analogPin, delayMsec)) {
    heartRateBPM = 60000 / beatMsec;
    // LED-output for the heart beat heart beat
    digitalWrite(ledPin,1);
 
    // Output of the serial data
    Serial.print(rawValue);
    Serial.print(", ");
    Serial.println(heartRateBPM);
     
    beatMsec = 0;
  } else {
    digitalWrite(ledPin,0);
  }
  delay(delayMsec);
  beatMsec += delayMsec;
}

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

KY-032 | OBSTACLE AVOIDANCE SENSOR

The KY-032 obstacle avoidance sensor is an infrared obstacle avoidance sensor. It comes with the 37 in 1 starter kit for Arduino. It helps...

HIH-4000 | Humidity Sensors

The HIH-4000  sensors are one of the highly efficient humidity sensors you can buy. The HIH-4000 is an analog humidity sensor. It is useful...

KY-026 | ARDUINO FLAME IR SENSOR

The KY-026 Arduino Flame Sensor is a low-cost starter sensor. It normally comes in the starter kit of Arduino like the ky-039. It can...

KY-039 | ARDUINO HEARTBEAT SENSOR

The KY-039 Heartbeat sensor is one of the cheapest sensors to get a start on Arduino like the Sound sensor. It cost less than...

Recent Comments