Build Project

Healthcare

Build an Educational ECG Waveform Viewer

Build an educational ESP32 AD8232 waveform viewer with ADC sampling, leads-off checks, battery/isolation guidance, and no medical claims.

AdvancedAges 14+75-90 minUnder 30 USDParent Safe
Project Mission

Build an Educational ECG Waveform Viewer

The Story

ECG projects can easily sound medical. This page keeps the scope to waveform education and explicitly avoids diagnosis, heart-rate claims, or health decisions. The Golden version keeps the implementation narrow and testable: code constants, wiring, GPIO notes, expected output, limitations, and troubleshooting all describe the same educational prototype.

Explain Like I'm 12

The AD8232 makes a small body-signal waveform easier for the ESP32 to read. The ESP32 prints numbers so the Serial Plotter can draw the shape. The ESP32 reads a signal, checks it against a simple rule, and prints or changes an output so you can see what happened.

Learning Support

  • Recommended ageAges 14+
  • Adult supervisionAdult supervision required. Stop for discomfort, damaged leads, irritation, or uncertainty.
  • Classroom usePrefer simulated signal or demonstration module output; body-connected demos need medical isolation and consent.
  • Parent promptAsk why a visible waveform is not a diagnosis.
  • Screen-free activityDraw noise sources: motion, loose pads, USB power, and poor contact.
  • Next challengeAdd offline filtering to saved sample data rather than making health claims.
  • Skills practiced
    • ADC1 sampling
    • Leads-off detection
    • Medical safety limits
    • Serial Plotter
  • Learning outcomes
    • Read AD8232 OUT on GPIO34.
    • Use LO+ and LO- pins to avoid plotting disconnected leads.
    • Explain ADC noise and waveform artifacts.
    • State that the project is not a medical device.
  • Mini experiments
    • Plot a stable simulated or module output.
    • Move the lead cable gently and observe artifacts.
    • Disconnect a lead and confirm midscale output.

Safety Standards

  • Unplug USB before changing jumper wires. Recheck 3.3 V, 5 V, and GND before reconnecting power.
  • Do not power motors, pumps, LED strips, or servos from the ESP32 3.3 V pin. Use a suitable external supply and common ground.
  • Breadboards are for low-current prototypes. Move high-current or unattended builds to proper terminals, enclosure, strain relief, and fusing.

What You Will Build

An educational AD8232 waveform viewer that prints raw ADC samples to Serial Plotter at about 250 Hz.

Learning Objectives

  • Read AD8232 OUT on GPIO34.
  • Use LO+ and LO- pins to avoid plotting disconnected leads.
  • Explain ADC noise and waveform artifacts.
  • State that the project is not a medical device.

Components List

  • ESP32 DevKit boardUSB-programmable ESP32 board used for the low-voltage control side.
  • AD8232 ECG moduleEducational analog front-end; OUT to GPIO34, LO pins to GPIO32/GPIO33.
  • Disposable ECG electrode padsUse only clean intact pads; stop for skin irritation.
  • ECG lead cableUse only undamaged leads.
  • Battery power or medical isolationRequired safety boundary for body-connected demonstrations.

Bill of Materials

PartQtyEstimated CostNotes
ESP32 DevKit board1VariesUSB-programmable ESP32 board used for the low-voltage control side.
AD8232 ECG module1VariesEducational analog front-end; OUT to GPIO34, LO pins to GPIO32/GPIO33.
Disposable ECG electrode pads1VariesUse only clean intact pads; stop for skin irritation.
ECG lead cable1VariesUse only undamaged leads.
Battery power or medical isolation1VariesRequired safety boundary for body-connected demonstrations.

Wiring

AD8232 OUT goes to ADC1 GPIO34. LO+ and LO- go to GPIO32 and GPIO33. Power the module from 3.3 V and common ground.

Build an Educational ECG Waveform Viewer wiring diagram
  1. 1

    Unplug USB before wiring the AD8232.

  2. 2

    Connect AD8232 OUT to GPIO34.

  3. 3

    Connect LO+ to GPIO32 and LO- to GPIO33.

  4. 4

    Connect AD8232 3.3 V to ESP32 3V3 and GND to GND.

  5. 5

    Use battery power or proper medical isolation before any body-connected test.

  6. 6

    Attach electrodes only at a high-level educational placement with consent and stop for discomfort.

GPIO Mapping

SignalESP32 PinDirectionNotes
AD8232 OUTGPIO34InputADC1 input-only analog waveform.
AD8232 LO+GPIO32InputLeads-off positive.
AD8232 LO-GPIO33InputLeads-off negative.

Circuit Explanation

The AD8232 conditions a small biopotential waveform into an ESP32-readable analog signal. Leads-off pins help detect disconnected electrodes.

Engineering Explanation

ESP32 ADC readings are raw counts and may include noise, baseline drift, motion artifacts, and contact problems. The sketch does not compute clinical units or heart-rate accuracy.

Libraries

  • Arduino ESP32 coreNo external libraries required.

Code

Copy into Arduino IDE. Install any libraries noted in the component guides first.

esp32-ecg-monitor.ino
// ESP32 Educational ECG Waveform Viewer
// Not a medical device. Use battery power and medical isolation for any body-connected demo.
const int ECG_PIN = 34;
const int LO_PLUS = 32;
const int LO_MINUS = 33;

void setup() {
  Serial.begin(115200);
  pinMode(LO_PLUS, INPUT);
  pinMode(LO_MINUS, INPUT);
  analogReadResolution(12);
  analogSetPinAttenuation(ECG_PIN, ADC_11db);
  Serial.println("Educational waveform viewer only - not for diagnosis.");
}

void loop() {
  if (digitalRead(LO_PLUS) == HIGH || digitalRead(LO_MINUS) == HIGH) {
    Serial.println(2048);
    delayMicroseconds(4000);
    return;
  }
  int sample = analogRead(ECG_PIN);
  Serial.println(sample);
  delayMicroseconds(4000);
}

Code Explanation

GPIO34 is sampled about every 4 ms. If LO+ or LO- is HIGH, the sketch prints midscale instead of plotting disconnected-lead noise.

Expected Output

Serial Plotter shows raw ADC counts. A body-connected waveform may be noisy or distorted and must not be interpreted medically.

Troubleshooting

  • Flat line Check LO+ and LO- status and electrode contact.
  • Very noisy waveform Reduce movement, improve contact, and use battery/isolated power.
  • Signal clips Check module power and electrode connection; do not force clinical conclusions.

Common Mistakes

  • Using the project for diagnosis.
  • Connecting a body-connected circuit to unsafe mains-powered equipment.
  • Claiming heart-rate accuracy.
  • Ignoring lead-off or skin discomfort.

Testing Checklist

  • Run the sketch before attaching electrodes.
  • Check leads-off behavior.
  • Use a simulated or safe educational signal when possible.
  • Record only raw counts and safety observations.

Engineering Tips

  • Prefer battery power.
  • Keep cables still.
  • Treat every waveform as educational only.

Upgrade Ideas

  • Save raw samples to CSV.
  • Add offline smoothing for visualization.
  • Add a clear on-screen safety banner.

Real-World Applications

  • Biopotential waveform lesson
  • ADC sampling demo
  • Medical-device safety discussion

FAQs

Is this a medical ECG monitor?

No. It is only an educational waveform viewer.

Can I use this for health decisions?

No. Do not use it for diagnosis or health decisions.

Why print midscale when leads are off?

It keeps the plotter stable and avoids treating disconnected noise as a waveform.

Review, Testing, and References

Author: Abdul Mubeen and the ESP32 Engine editorial team. Last updated: 2026-06-27. Reviewed: wiring logic, Arduino code structure, beginner safety, and learning sequence.

Educational level: Advanced. Estimated completion time: 75-90 min. This project is for learning and prototyping; production or unattended hardware needs additional engineering review.

Project Complete!

You completed Build an Educational ECG Waveform Viewer as a safe, bounded ESP32 learning build with matching wiring, code, tests, and limitations.

  • ADC1 sampling
  • Leads-off detection
  • Medical safety limits