Troubleshooting · Biomedical · AD8232 · Arduino · ESP32
AD8232 ECG Signal Noisy? Fix 50 Hz Hum and Power Noise
AD8232 noisy signal? You expected a heartbeat on the Serial Plotter, and got
The AD8232 is fine. The problem is usually how it is powered and what it is connected to.
Ramanu Systems · Pune, India · 3-minute answer, 12-minute deep dive
Your heart’s signal is about 1 millivolt. Mains wiring in the room is 230 V at 50 Hz, and your body picks it up like an antenna. A laptop on its charger connects your circuit to mains too, and a shared, noisy 3.3 V adds its own ripple and spikes.
Fix: run on battery (laptop charger unplugged), give the AD8232 its own clean 3.3 V, use fresh electrodes, and average out the 50 Hz in code.
Is this your problem?
If two or more of these sound familiar, power and mains coupling are your prime suspects:
- The trace looks thick or fuzzy, even when you sit still
- It gets much cleaner when the laptop charger is unplugged
- The baseline drifts slowly up and down
- Random spikes appear when Wi-Fi or a motor is active
- It’s worse near a fan, tube light or extension board
- The QRS peaks are there, but P and T waves are lost
Why it happens, in one picture
The AD8232 amplifies a 1 mV signal about a thousand times. Anything that sneaks in before or alongside that signal is amplified or added too. Four things usually do it, and the biggest isn’t the board at all.
The 2-minute test: is it power or the electrodes?
The fix in 3 steps
- Cut the link to mainsRun the laptop on battery while you record, or build the project on batteries (for example 3× AA or a 1-cell Li-ion pack feeding the regulator). Safer, and it removes the biggest noise path.
- Give the AD8232 its own clean 3.3 VFeed a dedicated low-noise 3.3 V regulator and use it only for the AD8232, and on an Arduino also for
AREF. Then callanalogReference(EXTERNAL)first insetup(). The ECG output sits around the middle of 0–3.3 V, so a 3.3 V reference also gives you more resolution than 5 V. - Fresh electrodes, still body, 50 Hz filterUse new gel pads on clean skin, keep the lead cable still and away from power cords, and remove leftover 50 Hz in code (below).
Remove 50 Hz in code (works on any Arduino)
Sample at exactly 500 times per second and average the last 10 samples. That’s 20 ms, exactly one 50 Hz cycle, so the hum averages to zero (and so does 100 Hz).
const int N = 10; // 10 samples x 2 ms = 20 ms = one 50 Hz cycle
int buf[N]; int idx = 0; long sum = 0;
unsigned long next = 0;
void setup() {
analogReference(EXTERNAL); // clean 3.3 V on AREF: FIRST line
Serial.begin(115200);
pinMode(10, INPUT); // LO+
pinMode(11, INPUT); // LO-
}
void loop() {
if ((long)(micros() - next) < 0) return;
next += 2000; // 500 samples per second
if (digitalRead(10) || digitalRead(11)) { // an electrode is off
Serial.println(0);
return;
}
int v = analogRead(A0);
sum += v - buf[idx]; buf[idx] = v; idx = (idx + 1) % N;
Serial.println(sum / N); // 50 Hz and 100 Hz removed
}
In a 60 Hz country, sample at 600 per second (next += 1667) with the same N = 10. This filter also softens the sharp QRS peak a little: fine for heart rate, not for detailed waveform analysis.
Which setup are you using?
| Your setup | What to do |
|---|---|
| Arduino on laptop USB | Laptop on battery while recording. Clean 3.3 V for the AD8232 and AREF, as in Figure 4 |
| ESP32 (Wi-Fi / BLE) | Battery-powered. AD8232 on its own clean 3.3 V, not the ESP32’s 3V3 pin. Use an ADC1 pin (GPIO34/36) and see our ADC noise guide |
| Wearable / portable build | 1-cell Li-ion or 3× AA into a low-noise 3.3 V regulator; AD8232 draws only about 170 µA |
| Raspberry Pi | No analog input: add an ADS1115 on the same clean 3.3 V, and run the Pi from a power bank rather than a mains adapter while recording |
The clean supply we designed for this
TrueVolt LN-7A2033 · Clean power for sensors, radios & audio
Between your battery or 5 V and the AD8232. Three pins, no code.
- 7 µVrms noise, 95 dB ripple rejection at 1 kHz (genuine TI TPS7A2033)
- Works from 3× AA or a 1-cell Li-ion: only 140 mV dropout at full load
- Battery mode: open the LED jumper and the module itself draws only a few µA
- Reverse-polarity protection: safe if a battery goes in backwards
- Designed & made in Pune, India
Still noisy? The other common causes
| Cause | What you see | Fix |
|---|---|---|
| Old or dry electrode pads | Noise and drift that slowly gets worse | Fresh gel pads; they lose conductivity with reuse |
| Hair or oily skin | Unstable, high-noise trace | Clean the skin; pick a spot without hair |
| RA and LA swapped | Upside-down QRS | RA on the right, LA on the left |
| Moving, talking, deep breathing | Large slow swings and bursts | Sit still and relaxed; tape the cable down |
| Lead cable near power cords | Extra 50 Hz when the cable moves | Route the leads away from cords, chargers and extension boards |
| Flat line or max value | No ECG at all | An electrode is off: check LO+ / LO− and the pads |
For engineers: why battery power helps more than any filter
1. The AD8232 already fights mains, but it has limits
| AD8232 feature (Analog Devices) | Value | What it does |
|---|---|---|
| Supply | 2.0–3.5 V, ≈170 µA | Low power: ideal for batteries |
| CMRR | 80 dB, dc to 60 Hz | Rejects mains that appears equally on both electrodes |
| Right leg drive (RLD) | Integrated | Drives the body’s common-mode voltage back towards the circuit’s reference |
| Instrumentation stage | Gain of 100, dc blocking | Boosts the 1 mV ECG and tolerates electrode offset |
| Reference buffer | Virtual ground at mid-supply | The output swings around half the supply voltage |
CMRR only works on mains that is truly common to both electrodes. Electrodes never match perfectly, so part of the common-mode mains turns into a differential signal and gets amplified with the ECG. The more common-mode voltage the body carries, the more leaks through. A laptop on its charger gives that mains a low-impedance path through the circuit’s ground, which raises it. On battery power, the circuit floats with the body and the right-leg drive can hold it down.
2. Where the supply comes in
The AD8232’s output is referenced to its own mid-supply, and on an Arduino the ADC measures it against the 5 V USB rail. Ripple on either one adds directly to the reading, and Wi-Fi bursts on an ESP32’s shared 3V3 pin show up as sharp spikes. A dedicated low-noise 3.3 V feeding both the AD8232 and AREF removes this source entirely, and costs only a few hundred microamps of battery.
3. The moving-average trick, in numbers
A 10-sample average at 500 Hz is a 20 ms boxcar filter. Its response has zeros at 50, 100, 150 Hz and so on, so mains hum and its harmonics cancel. Its −3 dB point is around 22 Hz, which keeps the P and T waves but rounds off part of the QRS. For waveform-quality work, use a proper digital notch or a band-pass filter.
Frequently asked questions
Why is my AD8232 ECG signal so noisy?
Mostly because of 50 Hz mains pickup through your body and the leads, made worse when the circuit is connected to a laptop on its charger. A noisy shared 3.3 V supply, old electrodes and movement add more. Run on battery, give the AD8232 its own clean 3.3 V, use fresh pads and sit still.
How do I remove 50 Hz noise from the AD8232?
First reduce it at the source: unplug the laptop charger or run on batteries, and keep the leads away from power cords. Then filter what’s left: sampling at 500 Hz and averaging 10 samples (one 20 ms mains cycle) cancels 50 Hz and 100 Hz.
Is it safe to use the AD8232 connected to a laptop?
Only with the laptop running on battery, charger unplugged. Hobby ECG boards are not isolated and are not medical devices, so never wear electrodes while the circuit is connected to anything plugged into mains.
What voltage does the AD8232 need?
The AD8232 chip runs from 2.0 to 3.5 V, and the common breakout boards are made for 3.3 V. Never connect 5 V to the board’s 3.3V pin.
Why does my AD8232 show a flat line or random values?
Usually an electrode is off or making poor contact. The LO+ and LO− pins go high when a lead is off; check them in code, replace the pads and check the cable. A floating OUTPUT connection also gives random values.
Can I use the AD8232 with an ESP32?
Yes. Power it from its own clean 3.3 V instead of the ESP32’s 3V3 pin, connect OUTPUT to an ADC1 pin such as GPIO34 or GPIO36, run on battery, and expect some spikes from Wi-Fi bursts unless the supply is separate.
What is the best power supply for an AD8232 ECG project?
Batteries feeding a dedicated low-noise 3.3 V linear regulator that powers only the AD8232 (and the ADC reference). For example, the Ramanu TrueVolt LN-7A2033 (TI TPS7A2033, 7 µVrms, 95 dB PSRR at 1 kHz) runs from 3× AA or a 1-cell Li-ion and gives the AD8232 a quiet, stable supply.
Fix it today
See every P, QRS and T wave
One small module between your battery and the AD8232: quiet 3.3 V, genuine TI, made in India. Cheaper than one failed demo.