Home / Learn Embedded C / Averaging and Filtering ADC Readings

Averaging and Filtering ADC Readings

Reducing noise in a sensor reading by combining several samples.

Quick summaryReducing noise in a sensor reading by combining several samples.

How to think about this

A simple moving-average filterTake a new ADCreadingAdd it to a smallhistory buffer,…Compute the meanof the bufferReport that meanas the "current"…
A simple moving-average filter

Definition

Averaging multiple ADC readings (or applying a simple digital filter) smooths out random electrical noise, producing a more stable value than any single raw reading alone.

Why you need this

Real-world ADC readings are rarely perfectly stable even for a constant input — small electrical noise causes the raw value to jitter slightly from sample to sample; averaging/filtering turns this noisy signal into a usable, stable one.

How it works

A simple moving average (keep the last N readings, report their mean) trades a little responsiveness (it lags behind true fast changes slightly) for a large reduction in noise — a common, practical trade-off.

Where you'll see this

  • Noisy sensor smoothing
  • Stable display values
  • Any ADC-based measurement

Try it

A simple 4-sample moving averageC: edit and run

A real moving average continuously updates as new samples arrive, dropping the oldest one each time — this shows one snapshot of that computation.

Try it: comparing a single noisy reading against the averaged value

Showing how much a single raw sample can jump around vs the averageC: edit and run

Trusting any one raw sample alone can be off by a noticeable amount; the averaged value is far more stable.

Test what you just read

1. What is the main trade-off of smoothing ADC readings with a moving average?