Heartbeat Sensor Module KY039

30.00 EGP

SKU: SE-7876 Categories: , , , Tags: , , ,

Description

Heartbeat Sensor Module KY039

  • The Heartbeat Sensor Module KY039 is designed to detect a pulse while a human finger is place between the infrared diode and the photo transistor.  The pulse will be represented on the signal output pin.
  • This sensor works by using a photo transistor to detect the presence of light, in this case how much light is passing through a finger.  When blood moves, the amount of light changes and that change can be detected as a pulse.
  • This project uses bright infrared (IR) LED and a phototransistor to detect the pulse of the finger, a red LED flashes with each pulse.
  • Pulse monitor works as follows: The LED is the light side of the finger, and phototransistor on the other side of the finger, phototransistor used to obtain the flux emitted, when the blood pressure pulse by the finger when the resistance of the phototransistor will be slight changed.
  • We chose a very high resistance resistor R1, because most of the light through the finger is absorbed, it is desirable phototransistor sensitive enough. Resistance can be selected by experiment to get the best results.
  • The most important is to keep the shield stray light into the phototransistor. For home lighting that is particularly important because the lights at home mostly based 50HZ or 60HZ fluctuate, so faint heartbeat will add considerable noise.
 DEVICE PINOUT & SCHEMATICS:
  • This module has three pins: GND, Vcc , and Signal.  The pinout is as follows:

 

  • The KY-039 heartbeat sensor schematic is as follows:

CODE EXAMPLES:
  • You’ll find below code examples of using the KY-039 heartbeat sensor with both Arduino 
  • KY-039 HEARTBEAT SENSOR CODE EXAMPLE FOR ARDUINO

    The following code example is for the Arduino. This code will read the Analog Output Sensor value and write it to the serial console, pause 500ms and repeat.

    ARDUINO WIRING:

    • KY-039 Sensor GND to Arduino GND 
    • KY-039 Sensor Signal to Arduino PIN A0
    • KY-039 Sensor Vcc  to Arduino 5V
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    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;
    }

    Pinout

    This module has 3 pins:

    • S: Analog output signal
    • VCC: Module power supply – 5V
    • GND: Ground

    You can see the pinout of this module here.

    KY-039 Heartbeat Sensor Pinout

     

    Required Materials

     

    Hardware Components

    Arduino UNO R3 × 1
    Module × 1
    Male to Female jumper wire × 1

     

    Software Apps

    Arduino IDE

     

    Interfacing with Arduino

     

    Step 1: Circuit

    The following circuit shows how you should connect Arduino to this module. Connect wires accordingly.

    KY-039 Module Arduino circuit

     

    Step 2: Code

    Upload the following code to Arduino. After that open the Serial Plotter.

        /*
    
      Made on Jan 16, 2021
    
      By MehranMaleki @ Electropeak
    
      Home
    
    */
    
    
    
    void setup() {
    
      pinMode(A0, INPUT);
    
      Serial.begin(9600);
    
    }
    
    
    
    void loop() {
    
      float pulse;
    
      int sum = 0;
    
      for (int i = 0; i < 20; i  )
    
        sum  = analogRead(A0);
    
      pulse = sum / 20.00;
    
      Serial.println(pulse);
    
      delay(100);
    
    }
    
    
    Arduino

    In this code, pin A0 of Arduino is used to receive the analog output data. In order to reduce the effect of noise on output, the average of last 20 output data is used. By placing your finger on the module, you can see how it works.

    The output is as follows.

Package includes:
  • 1 X Finger Measuring Heartbeat Sensor Module

 

Heartbeat Sensor Module KY039

Heartbeat Sensor Module KY039

Heartbeat Sensor Module KY039

Heartbeat Sensor Module KY039

Heartbeat Sensor Module KY039
Heartbeat Sensor Module KY039
Heartbeat Sensor Module KY039
Heartbeat Sensor Module KY039

Additional information

Dimensions 2 × 1.5 cm