Arduino pulse rate monitor

Configurare noua (How To)

Situatie

1. System Overview

A pulse rate monitor measures heartbeats using an optical sensing technique called photoplethysmography (PPG). The system works as follows:

  1. An LED emits light into the skin.

  2. A photodiode detects variations in reflected light.

  3. The signal is amplified and filtered.

  4. The microcontroller processes the signal.

  5. Beats per minute (BPM) are calculated.

  6. The result is displayed or transmitted.

The microcontroller used in this guide is the Arduino Uno, but other compatible boards such as the Arduino Nano can also be used.

2. Required Components

Core Components

  • Arduino Uno

  • Pulse Sensor Amped

  • Breadboard

  • Jumper wires

  • USB cable

Optional Components

  • 16×2 LCD display

  • OLED display (I2C)

  • 10kΩ potentiometer (for LCD contrast)

  • Buzzer (heartbeat indication)

  • External power supply (9V battery)

  • Enclosure case

3. Working Principle of the Pulse Sensor

The Pulse Sensor typically contains:

  • A green LED (light source)

  • A photodiode (light detector)

  • Amplifier circuitry

  • Noise filtering stage

Principle of Operation

When the heart pumps blood:

  • Blood volume in the capillaries increases.

  • Light absorption increases.

  • Reflected light decreases.

  • The photodiode output voltage changes.

This produces a waveform known as a PPG signal, which contains periodic peaks corresponding to heartbeats.

4. Circuit Connections

Pulse Sensor to Arduino

Pulse Sensor Pin Arduino Pin
VCC 5V
GND GND
SIGNAL A0

The signal pin connects to analog input A0.

Optional: 16×2 LCD (Parallel Mode)

LCD Pin Arduino Pin
RS 12
EN 11
D4 5
D5 4
D6 3
D7 2
VSS GND
VDD 5V

5. Signal Processing Logic

The sensor outputs an analog waveform that includes noise. The Arduino must:

  1. Continuously read analog values.

  2. Detect peaks above a defined threshold.

  3. Measure time between successive peaks.

  4. Calculate BPM.

BPM Calculation

If IBI is the inter-beat interval in milliseconds:

BPM = 60000 / IBI

Where:

  • 60000 = milliseconds per minute

  • IBI = time between two detected heartbeats

6. Arduino Code (Basic Version)

const int pulsePin = A0;
int signal;
int threshold = 550;
unsigned long lastBeatTime = 0;
unsigned long currentTime;
int BPM = 0;

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

void loop() {
signal = analogRead(pulsePin);
currentTime = millis();

if(signal > threshold) {
if(currentTime – lastBeatTime > 300) {
unsigned long IBI = currentTime – lastBeatTime;
lastBeatTime = currentTime;
BPM = 60000 / IBI;
Serial.print(“BPM: “);
Serial.println(BPM);
}
}
}

7. Code Explanation

Threshold

The threshold filters out noise. It must be adjusted depending on:

  • Finger placement

  • Ambient light conditions

  • Individual physiology

Debounce Interval (300 ms)

This prevents double counting. A 300 ms minimum interval limits detection to a maximum of approximately 200 BPM.

8. Adding LCD Display

Include the library:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

In setup():

lcd.begin(16, 2);

In loop():

lcd.setCursor(0, 0);
lcd.print("Heart Rate:");
lcd.setCursor(0, 1);
lcd.print(BPM);
lcd.print(" BPM ");

9. Improving Accuracy

1. Moving Average Filtering

BPM = (BPM + previousBPM) / 2;

This smooths fluctuations.

2. Use Interrupt-Based Sampling

Provides more precise timing than polling in the main loop.

3. Use Hardware Timers

Using Timer2 improves sampling stability and reduces jitter.

4. Reduce Ambient Light

Use a finger clip or dark enclosure to block external light interference.

10. Calibration Procedure

  1. Open Serial Monitor

  2. Observe raw analog values

  3. Identify:

    • Resting signal level

    • Peak signal level

  4. Set threshold midway between these values.

Example:

  • Resting value: 520

  • Peak value: 620

  • Threshold: 570

11. Expected Output

Normal adult resting heart rate:

  • 60–100 BPM

Athletes:

  • 40–60 BPM

If readings fluctuate significantly:

  • Check noise filtering

  • Recalibrate threshold

  • Improve finger positioning

12. Troubleshooting

Problem Possible Cause Solution
No reading Wiring issue Check connections
Unstable BPM Noise Improve filtering
Constant zero Threshold too high Lower threshold
Very high BPM Threshold too low Increase threshold

Solutie

Tip solutie

Permanent

Voteaza

(24 din 48 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?