Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor
Measure real-time fingertip blood-volume pulse waves (photoplethysmography) to calculate smooth Beats Per Minute (BPM).
Cap off your 35-project Arduino Uno journey with biomedical optoelectronics! Interface the optical green-LED Pulse Sensor to analog pin A0, visualize live PPG heartbeat waveforms in Arduino Serial Plotter, detect systolic peaks with adaptive thresholding and refractory gating, and compute smoothed live BPM.
Key Learning Objectives & Robotics Concepts
By building and programming this project, you will master the following core engineering skills:
Power Architecture & Voltage Staging
5V / 3.3V Regulated PowerThe optical Pulse Sensor draws ~4mA from Arduino Uno 5V (3.3V compatible too) to drive its 515nm green LED and ambient-light-canceling photo-amplifier. Cover the back PCB pins of the Pulse Sensor with the included clear vinyl sticker/hot glue before touching with a fingertip so skin moisture does not short the amplifier! Educational prototype—not a medical diagnostic device.
Bill of Materials (BOM) & Hardware Components
| Component | Specifications & Alternative | Qty | Approx Cost |
|---|---|---|---|
| Arduino Uno R3 | ATmega328P @ 16MHz | 1 | $8.00 |
| Optical PPG Pulse Sensor Module | 515nm green LED + APDS-9008 ambient-filtered optical sensor | 1 | $4.00 |
| 5mm Red LED + 220Ω Resistor | Real-time heartbeat indicator | 1 | $0.15 |
| Clear Protective Vinyl Sticker / Velcro Strap | Insulates rear PCB pads from fingertip sweat | 1 | $0.25 |
Electrical & System Architecture
Connect Pulse Sensor Red (+) to 5V, Black (-) to GND, and Purple/Yellow Signal (S) to Arduino A0. Wire a Heartbeat Sync LED (+220Ω resistor) to D8 so it blinks in unison with every pulse!
Autonomous Behavior & Finite State Machine (FSM)
Deterministic Arduino loop handling Optical PPG Heart-Rate Pulse Sensor acquisition, filtering, and real-time output updates.
Step-by-Step Physical Assembly & Wiring Tutorial
Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.
Insulate Rear PCB Electronics Before Touching
Verify the back side of the round Pulse Sensor has protective vinyl/tape so skin conductance never shorts the op-amp.
- Check that the flat heart-icon side faces UP toward your fingertip.
- Cover the exposed SMD components on the back side with the clear protective sticker or electrical tape.
- Confirm wire color code: Red = 5V, Black = GND, Purple (or Yellow/Green) = Signal (S).
Wire Pulse Sensor to A0 & Heartbeat LED to D8
Connect power, ground, analog PPG signal, and the pulse-synced red LED.
- Connect Pulse Sensor Red → 5V, Black → GND, and Signal → A0.
- Wire Red LED (+220Ω) to D8 and cathode to GND.
- Power Arduino Uno via USB (on laptops, running on battery reduces 50/60Hz AC mains hum in PPG plots!).
Visualize Your Live PPG Wave in Serial Plotter
Run the waveform diagnostic and open Tools → Serial Plotter to see your real heartbeat curve!
- Upload the diagnostic snippet below and open Arduino IDE Serial Plotter (115200 baud).
- Rest your index fingertip gently over the glowing green LED.
- Within 3 seconds, watch crisp rhythmic systolic heartbeats scroll across the live graph!
Upload Adaptive BPM Heart-Rate Firmware
Flash the adaptive peak detector and observe live IBI (ms) and smoothed BPM in Serial Monitor.
- Upload the production sketch below and open Serial Monitor at 115200 baud.
- Rest your fingertip gently for 6 seconds while the 5-beat rolling average locks in.
- Watch D8 Red LED blink in exact harmony with your real pulse as live BPM prints!
Test Resting vs. Post-Activity Heart Rate
Observe how your Inter-Beat Interval shortens and BPM climbs after 15 quick jumping jacks.
- Record your calm resting BPM (typically 60–90 BPM).
- Perform brief light activity, rest finger back on sensor, and watch BPM climb smoothly.
- Remember: this educational DIY sensor is for STEM learning only—not for medical diagnosis.
Subsystem Benchtop Verification Scripts
Test each hardware subsystem independently before deploying the full autonomous firmware.
1Bench Diagnostic: Optical PPG Heart-Rate Pulse Sensor Hardware Check
Subsystem DiagnosticMinimal standalone sketch to verify pin wiring and signal response for Optical PPG Heart-Rate Pulse Sensor before running the full project firmware.
// Diagnostic: Live PPG Waveform Stream for Arduino Serial Plotter
void setup() { Serial.begin(115200); }
void loop() { Serial.println(analogRead(A0)); delay(20); }Complete Production Firmware
Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.
/**
* Project 35: Optical PPG Heart-Rate (BPM) Monitor with Adaptive Peak Detection
* Board: Arduino Uno R3 | Pins: A0 (Pulse Sensor S), D8 (Heartbeat LED)
*/
const uint8_t PULSE_AO = A0;
const uint8_t BEAT_LED = 8;
const unsigned long SAMPLE_INTERVAL_MS = 10; // 100Hz PPG sampling
const unsigned long REFRACTORY_MS = 320; // Max ~187 BPM guard
int sigMin = 1023, sigMax = 0, threshold = 530;
bool pulseHigh = false;
unsigned long lastSampleMs = 0;
unsigned long lastBeatMs = 0;
unsigned long lastWindowMs = 0;
int bpmHistory[5] = {72, 72, 72, 72, 72};
uint8_t histIdx = 0;
void setup() {
Serial.begin(115200);
pinMode(BEAT_LED, OUTPUT);
Serial.println(F("Optical PPG Heart-Rate Monitor Ready. Rest fingertip gently..."));
}
void loop() {
unsigned long now = millis();
if (now - lastSampleMs < SAMPLE_INTERVAL_MS) return;
lastSampleMs = now;
int sig = analogRead(PULSE_AO);
if (sig < sigMin) sigMin = sig;
if (sig > sigMax) sigMax = sig;
// Refresh adaptive threshold every 1.2s from recent peak-to-trough
if (now - lastWindowMs >= 1200) {
lastWindowMs = now;
int amp = sigMax - sigMin;
if (amp > 35) {
threshold = sigMin + (amp * 6) / 10; // 60% rising edge threshold
}
sigMin = 1023;
sigMax = 0;
}
if (sig > threshold && !pulseHigh && (now - lastBeatMs >= REFRACTORY_MS)) {
pulseHigh = true;
unsigned long ibi = now - lastBeatMs;
lastBeatMs = now;
digitalWrite(BEAT_LED, HIGH);
if (ibi >= 350 && ibi <= 1500) { // Valid 40..171 BPM physiological range
int instBpm = 60000UL / ibi;
bpmHistory[histIdx] = instBpm;
histIdx = (histIdx + 1) % 5;
int avgBpm = 0;
for (uint8_t i = 0; i < 5; i++) avgBpm += bpmHistory[i];
avgBpm /= 5;
Serial.print(F("BEAT! IBI: ")); Serial.print(ibi);
Serial.print(F(" ms | Instant: ")); Serial.print(instBpm);
Serial.print(F(" BPM | Smoothed: ")); Serial.print(avgBpm);
Serial.println(F(" BPM"));
}
} else if (sig < threshold - 15) {
pulseHigh = false;
digitalWrite(BEAT_LED, LOW);
}
}Firmware Architecture Explanation:
- Samples optical PPG at a deterministic 100Hz (10ms) cadence without blocking delay() calls.
- Recomputes an adaptive 60% rising-edge threshold every 1.2 seconds to track varying skin tones and finger pressure.
- Enforces a 320ms refractory guard plus a 5-beat moving average to deliver rock-steady physiological BPM.
Operational Verification & Pin State Matrix
Input Signal vs. System Output Truth Table:
| Input / State | Pin / Signal | Detected Condition | Expected Output |
|---|---|---|---|
| Systolic Peak | A0 > Threshold | Capillary Blood Surge | D8 LED ON + Log BPM |
| Diastolic Trough | A0 < Thresh - 15 | Between Beats | D8 LED OFF (Re-Arm) |
Engineering Troubleshooting Matrix
| Problem | Likely Cause | Diagnostic Check | Engineering Solution |
|---|---|---|---|
| BPM jumps wildly to 150+ or misses beats | Pressing fingertip too hard or moving finger during capture | Inspect raw waveform in Serial Plotter | Rest fingertip very lightly and keep hand still on desk. |
| Waveform stays completely flat | Finger placed on wrong side (back PCB) or rear pins shorted by skin sweat | Verify finger rests on glowing green LED side | Insulate back PCB with vinyl sticker and center finger on green LED. |
| 60Hz/50Hz AC ripple noise on laptop USB | Ungrounded switching laptop charger injecting mains hum | Unplug laptop AC brick briefly to compare | Run laptop on battery during biomedical signal tests. |
Engineering Challenges & Upgrades
Take your build to the next level with these progressive engineering upgrades:
Display large BPM digits and a pulsing heart graphic on Project 4 SSD1306 OLED.
Add a soft 50ms 1kHz chirp on Project 5 piezo buzzer synced to each beat.
Drive Project 11 RGB LED Blue (<70 Resting), Green (70–110 Light), or Red (>110 Cardio).