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

thick 50 Hz fuzz a wandering baseline random spikes

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

Quick answer

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.

SymptomFuzzy trace, drifting baseline, spikes
Likely causeMains pickup + charger path + noisy 3.3 V
FixBattery power, clean 3.3 V, fresh pads, 50 Hz filter
Show me the fix ↓ Run the 2-minute test 50 Hz filter code
Safety first Hobby ECG boards are not isolated and not medical devices. Never wear electrodes while your circuit is connected to anything plugged into mains, including a laptop on its charger or a USB phone charger. Run the laptop on battery, or build the whole project on batteries. This is also the single biggest noise fix.

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.

AD8232 ECG trace with laptop on charger and board 3.3V pin shows 50 Hz fuzz and wandering baseline; with laptop on battery and a clean LN-7A2033 3.3 V supply the P-QRS-T waves are clear
Figure 1. What changing the power setup can do. Illustration; real traces depend on electrodes, placement and the room.
Ranked ECG noise sources: 50 Hz mains pickup, charger and mains ground path, supply and ADC reference noise, electrodes and movement; battery power and a clean 3.3 V remove the first three
Figure 2. The four noise sources, roughly in order of how much trouble they cause in a typical hobby setup.

The 2-minute test: is it power or the electrodes?

Flowchart: unplug the laptop charger and power the AD8232 board from 2 AA cells; if the trace is much cleaner the cause is power and the mains path, otherwise check electrodes, placement and movement
Figure 3. Unplug the laptop charger, then power the AD8232 board from two AA cells (+ to 3.3V, − to GND, GND still joined to the Arduino). The AD8232 runs on 2.0–3.5 V, so use 2× AA only.

The fix in 3 steps

  1. 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.
  2. 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 call analogReference(EXTERNAL) first in setup(). 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.
  3. 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).
Wiring: Arduino 5V to LN-7A2033 VIN, VOUT clean 3.3 V to AD8232 3.3V and Arduino AREF, common ground, AD8232 OUTPUT to A0, LO+ to D10, LO- to D11, laptop on battery
Figure 4. Arduino Uno wiring. The same clean 3.3 V feeds the AD8232 and AREF. Pin numbers match the common SparkFun example (OUTPUT to A0, LO+ to D10, LO− to D11).

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 setupWhat to do
Arduino on laptop USBLaptop 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 build1-cell Li-ion or 3× AA into a low-noise 3.3 V regulator; AD8232 draws only about 170 µA
Raspberry PiNo 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

CauseWhat you seeFix
Old or dry electrode padsNoise and drift that slowly gets worseFresh gel pads; they lose conductivity with reuse
Hair or oily skinUnstable, high-noise traceClean the skin; pick a spot without hair
RA and LA swappedUpside-down QRSRA on the right, LA on the left
Moving, talking, deep breathingLarge slow swings and burstsSit still and relaxed; tape the cable down
Lead cable near power cordsExtra 50 Hz when the cable movesRoute the leads away from cords, chargers and extension boards
Flat line or max valueNo ECG at allAn electrode is off: check LO+ / LO− and the pads
That’s the practical answer.Engineers who want the mechanism, read on.

For engineers: why battery power helps more than any filter

1. The AD8232 already fights mains, but it has limits

AD8232 feature (Analog Devices)ValueWhat it does
Supply2.0–3.5 V, ≈170 µALow power: ideal for batteries
CMRR80 dB, dc to 60 HzRejects mains that appears equally on both electrodes
Right leg drive (RLD)IntegratedDrives the body’s common-mode voltage back towards the circuit’s reference
Instrumentation stageGain of 100, dc blockingBoosts the 1 mV ECG and tolerates electrode offset
Reference bufferVirtual ground at mid-supplyThe 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.

What a clean supply won’t fix It won’t fix bad electrodes, movement, or mains pickup when you’re tethered to a mains-powered laptop. It also won’t turn a hobby board into a medical device. Battery operation, fresh pads and sitting still matter as much as the regulator. The 2-minute test shows which problem you have.

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.

© Ramanu Systems · Precision electronics modules, Made in India · This article is for learning and hobby projects only and is not medical advice. AD8232 figures from Analog Devices. Pin numbers follow the SparkFun AD8232 hookup guide. Regulator figures from the Texas Instruments TPS7A20 datasheet. Found an error? Tell us and we will fix it and credit you.

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top