In today’s society, everyone wants more features and specifications at their fingertips. The Pulse sensor has just lately gained popularity as firms have begun to incorporate it into consumer products. It is currently employed in a variety of products, including smart bands, smartwatches, and medical equipment. Knowing the exact pulse rate/heart rate at the right time can save someone’s life.
We’ll go through how to utilize, programme, and interface the pulse sensor with Arduino step by step in this tutorial. In this tutorial, we’ll also include a circuit diagram and Arduino code. As a result, I hope you find this helpful. Our Online Store-Matha Electronics have previously published various Arduino tutorials and extensive project guides that will help you understand the fundamentals of Arduino programming.
Pulse Sensor is an Arduino-compatible heart-rate sensor with a well-designed plug-and-play interface. Students, artists, athletes, makers, and game and smartphone developers that wish to include live heart rate data in their work can use it.
What is a Pulse Sensor and How does it Work?
A pulse sensor also known as a Heartbeat sensor or heart rate sensor used to determine live heart rate data. Nowadays Heart rate data is widely used in most electronics projects. The sensor works on the principle of reflection of light. The working of this sensor is by simply connecting it from the fingertip or human ear to the Arduino board. The 24-inch colour code cable with standard male header connectors makes an easy connection to Arduino or a Breadboard. The Heart logo on the side is made in contact with the skin. A small round hole, which is where the LED shines through from the back, and there is also a little square just under the LED. This square consists of an ambient light sensor, used to adjust the screen brightness in different light conditions.
This sensor consists of two surfaces. Firstly, the light-emitting diode & ambient light sensor is connected. Next, on the second surface, the circuit is connected which is accountable for the noise cancellation or amplification. Pulse Sensor Amped adds this circuitry to the hardware, thus providing fast and easy to get reliable pulse readings.
The LED on the small round hole is placed above a vein in a human body like anear fingertip. Once the LED is fixed on the vein, then the LED starts emitting light. When the heart is pumping, then there will be a flow of blood within the veins. As a result, if we check the blood flow, then we can check the heart rates also. When the blood flow is sensed, the ambient light sensor will receive more light as it will be reproduced by the flow of blood. Hence this small change within obtained light is used to determine pulse rate. The sensor attaches to a fingertip or earlobe and connects to Arduino via jumper cables. It also comes with an open-source monitoring app that displays your pulse in real-time on a graph.
The pulse sensor has three pins which are as described below:
- Pin-1: GND: Black Colour Wire – Connected to the GND terminal
- Pin-2: VCC: Red Colour Wire – Connected to the supply voltage ( +5V otherwise +3.3V)
- Pin-3: Signal: Purple Colour Wire – Connected to the pulsating o/p signal.
Pulse sensor kit:
Basically, a Pulse Sensor Kit includes:
1) Soft braided-wire ribbon cable. Not kidding, that’s one nice cable!
2) An Ear Clip that’s perfectly sized to the sensor.
3) A Velcro Finger Strap, just like the pros.
4) Transparent Vinyl Dots, which make electrical insulation simple.
5) The Pulse Sensor also has 3 sewing holes, for you “Wearable’s People”.
- Arduino UNO
- Pulse Sensor
- Jumper Wires
- USB cable to connect Arduino UNO with computer
- Bread Board
Pulse Sensor Interfacing With Arduino Circuit Diagram
The D0 pin receives analogue data from the sensor. 5V and GND can be connected. The sensor only uses 4 milliamps of current. A separate LED is installed on top of our sensor to signal that it is operating.
- VCC of the sensor to 5V pin of Arduino UNO.
- GND of sensor to GND of Arduino UNO
- Signal out of sensor to A0 of Arduino UNO
- Negative’-‘ of LED to GND of Arduino UNO with 220-ohm Resistor in between
- Positive’+’ of LED to D11 of Arduino UNO
Finally, upload the below code, Explanation of the code is in the code itself.
|int sensor_pin = 0; |
int led_pin = 13;
volatile int heart_rate;
volatile int analog_data;
volatile int time_between_beats = 600;
volatile boolean pulse_signal = false;
volatile int beat; //heartbeat values will be sotred in this array
volatile int peak_value = 512;
volatile int trough_value = 512;
volatile int thresh = 525;
volatile int amplitude = 100;
volatile boolean first_heartpulse = true;
volatile boolean second_heartpulse = false;
volatile unsigned long samplecounter = 0; //This counter will tell us the pulse timing
volatile unsigned long lastBeatTime = 0;
delay(200); // take a break
TCCR2A = 0x02; // This will disable the PWM on pin 3 and 11
OCR2A = 0X7C; // This will set the top of count to 124 for the 500Hz sample rate
TCCR2B = 0x06; // DON’T FORCE COMPARE, 256 PRESCALER
TIMSK2 = 0x02; // This will enable interrupt on match between OCR2A and Timer
sei(); // This will make sure that the global interrupts are enable
analog_data = analogRead(sensor_pin);
samplecounter += 2;
int N = samplecounter – lastBeatTime;
if(analog_data < thresh && N > (time_between_beats/5)*3)
if (analog_data < trough_value)
trough_value = analog_data;
if(analog_data > thresh && analog_data > peak_value)
peak_value = analog_data;
if (N > 250)
if ( (analog_data > thresh) && (pulse_signal == false) && (N > (time_between_beats/5)*3) )
pulse_signal = true;
time_between_beats = samplecounter – lastBeatTime;
lastBeatTime = samplecounter;
second_heartpulse = false;
for(int i=0; i<=9; i++)
beat[i] = time_between_beats; //Filling the array with the heart beat values
first_heartpulse = false;
second_heartpulse = true;
word runningTotal = 0;
for(int i=0; i<=8; i++)
beat[i] = beat[i+1];
runningTotal += beat[i];
beat = time_between_beats;
runningTotal += beat;
runningTotal /= 10;
heart_rate = 60000/runningTotal;
if (analog_data < thresh && pulse_signal == true)
pulse_signal = false;
amplitude = peak_value – trough_value;
thresh = amplitude/2 + trough_value;
peak_value = thresh;
trough_value = thresh;
if (N > 2500)
thresh = 512;
peak_value = 512;
trough_value = 512;
lastBeatTime = samplecounter;
first_heartpulse = true;
second_heartpulse = false;
After uploading the code, the output LED attached to Arduino UNO pin 11 will flicker in time with the heartbeat. So we learned a few things about pulse sensors in this blog. It’s a combination of two LED sensors and an ambient light sensor. We witnessed how it may assist us in improving and tracking our health.
It can also be used to detect heart rate in medical applications. We used an Arduino Uno board to connect it to the computer. To see how the sensor worked in practice, we examined pinouts and then heart rates by writing the code.