Heart Rate Module (Part 1)

Today, we are going to look at a very simple heart rate sensor. Let's discover how it works and how we can measure the heart rate with it.

Heart Rate Sensor

In this tutorial, we are going to look at the KY-039 module. There are different variants of this module, but the basic working principle is always the same. All modules are quite simple and use only an LED and a photo diode or photo transistor for the measurements. The LED emits light into the skin and the photo diode or transistor measure the light intensity. The amount of light absorbed in the skin depends on the blood volume in the tissue. When the heart contracts blood is pumped from the heart through the arteries into the whole body. The blood volume in the tissue increases and more light is absorbed. This measured by the sensor and ultimately allows us to determine the heart rate.

The measurement method is also called photoplethysmology. Related, but different is the so-called pulse oximetry, where the oxygen saturation in the blood is measured. A pulse oximeter looks similar to a heart rate sensor and most devices also display the heart rate, however, for pulseoximetry multiple LEDs of different wavelengths would be required.

There are two different methods to conduct the measurements: by shining light through the skin and measuring the absorption or by measuring the amount of reflected light. Both variants of the KY-039 module exist. In the image below you can see the type which is using reflection on the left. To use this module just lay your finger on top of the green LED. For the module on the right side you have to lay your finger in between the IR-LED and the phototransistor, so that the LED shines through your finger onto the photo transistor. Don't be surprised, since the LED is an infrared LED you cannot see whether it is on or not.

Using the Heart Rate Sensor

Let's see how we can use these modules to measure our heart rate, shall we?

Both variants of the KY-039 can be wired in the same way. Connect + to 5V, - to GND and analog output signal S to one of the Arduino's analog inputs. I chose A0.

In this first part of this tutorial, we will use a very simple Arduino program that takes one measurement every 10 ms and sends it to the serial monitor. Here is how this program looks like:

void setup() {
Serial.begin(9600);
}

void loop() {
}
Once the program is uploaded to the Arduino, the measurement values are sent to the computer. They can be visualized in the serial plotter, which can be found under Tools. For good measurements you should avoid applying pressure on your finger. Lay it down gently and you should be able to see your heartbeats in the serial plotter.