Heart Rate Sensor Module Features
This module is designed for educational and entertainment purposes and is used to detect Cardiovascular pulse wave with finger. It uses a PPG (HRM-2511E) probe for data transmission. This sensor uses infrared light technology. If the amount of blood changes, the intensity of infrared light will change as well.
This heart rate sensor has two analog and digital outputs and one LED for the digital output. You can see the heartbeat more accurately by the analog output.
Features:
- Potentiometer included to control the gain for analog output
- Bandwidth control for digital output
- Interfacing capability at 3.3V and 5V
Heart Rate Sensor Module Pinout
This module has 6 pins:
- VCC: Module power supply
- GND: Ground
- EN: Enable pin – connect this pin to VCC to enable
- D0: Digital output
- A0: Analog output
- PROBE: Probe input
You can see the pinout of this module here.
Required Materials
Hardware Components
Software Apps
Interfacing Heart Rate Sensor Module with Arduino
Step 1: Circuit
The following circuit shows how you should connect Arduino to this module. Connect wires accordingly.
Step 2: Code
Upload the following code to your Arduino.
/*
Heart-rate-Sensor
made on 02 Feb 2021
by Amir Mohammad Shojaee @ Electropeak
Home
*/
int pulse = 2;
int current_ms = 0;
int inter_num = 0;
int last_ms;
int x;
int heart_per_min;
int arr[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
void setup()
{
Serial.begin(9600);
pinMode(pulse, INPUT);
attachInterrupt(0, pulse_num, RISING );
last_ms = millis();
}
void loop()
{
if (arr[0] != 0) {
Serial.print("heart_per_min: ");
Serial.println(heart_per_min);
heart_per_min=0;
}
Serial.println("wait ");
delay(10000);
}
void pulse_num()
{
inter_num++;
if (inter_num == 9) {
inter_num = 0;
}
float sum = 0.00;
current_ms = millis();
x = current_ms - last_ms;
last_ms = millis();
for (int i = 0; i < 9; i++) {
arr[i] = arr[i + 1];
}
arr[9] = x;
for (int i = 0; i < 10; i++) {
sum += arr[i];
}
sum = sum / 10.00;
heart_per_min = (60000.00)/sum;
}
In this program, we want to calculate the heart rate per minute using the digital output pulses. First, we record the time the pulse has been High by using interrupt. Then we measure the time interval between two consecutive pulses. To increase the accuracy of measurement, we take samples in 10 seconds and your heart rate is estimated in 60 seconds.
The output is as follows: