MyRoboPathOpen Robotics Lab
Arduino Uno #35 of 35
Est. 0.75 Hours
Budget: $4 - $7
Intermediate

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.

Arduino Uno R3PPG Pulse SensorBiomedical Signal DSPPeak DetectionLive BPM Telemetry
Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor Blueprint
Optical PPG Pulse Sensor & Live Heart Rate (BPM) MonitorCAD Blueprint

Key Learning Objectives & Robotics Concepts

By building and programming this project, you will master the following core engineering skills:

1Understand reflective photoplethysmography (PPG): each heartbeat briefly swells fingertip capillaries, modulating green light absorption.
2Isolate delicate biological signals from motion artifacts using gentle uniform finger pressure.
3Implement an adaptive threshold + 300ms refractory period (max 200 BPM) to eliminate double-counting dicrotic notches.
4Smooth Inter-Beat Intervals (IBI) across a 5-beat moving average to output stable physiological BPM.

Power Architecture & Voltage Staging

5V / 3.3V Regulated Power

The 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.

Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor Power Architecture Schematic
Figure: Regulated Arduino Uno supply rails, current budget, and component protection.Power Schematic

Bill of Materials (BOM) & Hardware Components

Bill of Materials for Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor
ComponentSpecifications & AlternativeQtyApprox Cost
Arduino Uno R3ATmega328P @ 16MHz1$8.00
Optical PPG Pulse Sensor Module515nm green LED + APDS-9008 ambient-filtered optical sensor1$4.00
5mm Red LED + 220Ω ResistorReal-time heartbeat indicator1$0.15
Clear Protective Vinyl Sticker / Velcro StrapInsulates rear PCB pads from fingertip sweat1$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!

Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor.
Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor.Wiring Schematic

Autonomous Behavior & Finite State Machine (FSM)

Deterministic Arduino loop handling Optical PPG Heart-Rate Pulse Sensor acquisition, filtering, and real-time output updates.

Figure: Firmware execution flow and state transitions for Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor.
Figure: Firmware execution flow and state transitions for Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor.Control Algorithm

Step-by-Step Physical Assembly & Wiring Tutorial

Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.

1

Insulate Rear PCB Electronics Before Touching

Duration: 5 Mins

Verify the back side of the round Pulse Sensor has protective vinyl/tape so skin conductance never shorts the op-amp.

Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor hardware layout diagram
Stage 1: Optical PPG Heart-Rate Pulse Sensor hardware inspection & pinout overview.Stage 1 Diagram
Step Action Checklist:
  • 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).
Engineering & Tuning Tip: Light, steady contact is the secret—pressing too hard squeezes blood out of your fingertip and flattens the pulse wave!
2

Wire Pulse Sensor to A0 & Heartbeat LED to D8

Duration: 5 Mins

Connect power, ground, analog PPG signal, and the pulse-synced red LED.

Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor breadboard wiring check diagram
Stage 2: Breadboard layout & Arduino Uno pin-to-pin wiring audit.Stage 2 Diagram
Step Action Checklist:
  • 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!).
Engineering & Tuning Tip: Rest your forearm comfortably flat on the desk so hand tremor stays zero during readings.
3

Visualize Your Live PPG Wave in Serial Plotter

Duration: 5 Mins

Run the waveform diagnostic and open Tools → Serial Plotter to see your real heartbeat curve!

Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor power rail protection diagram
Stage 3: Supply rail check (USB 5.0V Regulated Rail (≈4mA green LED)) and circuit protection verification.Stage 3 Diagram
Step Action Checklist:
  • 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!
Engineering & Tuning Tip: If the trace looks noisy or flat, lighten your finger pressure slightly or try your earlobe / thumb.
4

Upload Adaptive BPM Heart-Rate Firmware

Duration: 10 Mins

Flash the adaptive peak detector and observe live IBI (ms) and smoothed BPM in Serial Monitor.

Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor serial telemetry verification diagram
Stage 4: Firmware upload & 115200 baud Serial Monitor verification.Stage 4 Diagram
Step Action Checklist:
  • 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!
Engineering & Tuning Tip: Verify accuracy by counting your wrist pulse for 15 seconds × 4 and comparing against Arduino's BPM readout.
5

Test Resting vs. Post-Activity Heart Rate

Duration: 5 Mins

Observe how your Inter-Beat Interval shortens and BPM climbs after 15 quick jumping jacks.

Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor live operational logic diagram
Stage 5: Live operational logic flow & calibration verification.Stage 5 Diagram
Step Action Checklist:
  • 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.
Engineering & Tuning Tip: Combine with Project 4 (OLED Display) to draw a live heart icon and scrolling ECG-style waveform right on your desk!

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 Diagnostic

Minimal standalone sketch to verify pin wiring and signal response for Optical PPG Heart-Rate Pulse Sensor before running the full project firmware.

Arduino IDE Diagnostic ScriptC++ / Arduino
// Diagnostic: Live PPG Waveform Stream for Arduino Serial Plotter
void setup() { Serial.begin(115200); }
void loop() { Serial.println(analogRead(A0)); delay(20); }
Expected Output: Rhythmic heartbeat pulse wave visible cleanly in Arduino IDE Serial Plotter.

Complete Production Firmware

Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.

arduino_uno_optical_pulse_heart_rate_monitor.ino
arduino_uno_optical_pulse_heart_rate_monitor.inoArduino C++
/**
 * 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

1Double-check all 4 Arduino Uno pin connections against the wiring schematic before plugging in USB.
2Upload the Bench Diagnostic sketch first and confirm Serial Monitor at 115200 baud matches: Rhythmic heartbeat pulse wave visible cleanly in Arduino IDE Serial Plotter.
3Upload the complete production sketch and verify every condition in the operational truth table below.

Input Signal vs. System Output Truth Table:

Operational truth table for Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor
Input / StatePin / SignalDetected ConditionExpected Output
Systolic PeakA0 > ThresholdCapillary Blood SurgeD8 LED ON + Log BPM
Diastolic TroughA0 < Thresh - 15Between BeatsD8 LED OFF (Re-Arm)

Engineering Troubleshooting Matrix

Engineering troubleshooting matrix for Optical PPG Pulse Sensor & Live Heart Rate (BPM) Monitor
ProblemLikely CauseDiagnostic CheckEngineering Solution
BPM jumps wildly to 150+ or misses beatsPressing fingertip too hard or moving finger during captureInspect raw waveform in Serial PlotterRest fingertip very lightly and keep hand still on desk.
Waveform stays completely flatFinger placed on wrong side (back PCB) or rear pins shorted by skin sweatVerify finger rests on glowing green LED sideInsulate back PCB with vinyl sticker and center finger on green LED.
60Hz/50Hz AC ripple noise on laptop USBUngrounded switching laptop charger injecting mains humUnplug laptop AC brick briefly to compareRun laptop on battery during biomedical signal tests.

Engineering Challenges & Upgrades

Take your build to the next level with these progressive engineering upgrades:

Level 1OLED Live Heartbeat Monitor

Display large BPM digits and a pulsing heart graphic on Project 4 SSD1306 OLED.

Level 2Audible Hospital Monitor Beep

Add a soft 50ms 1kHz chirp on Project 5 piezo buzzer synced to each beat.

Level 3Exercise Zone RGB Indicator

Drive Project 11 RGB LED Blue (<70 Resting), Green (70–110 Light), or Red (>110 Cardio).