Skip to content

Sensors & Signal Processing

How oversampling adds resolution to an ADC

Oversampling reads a sensor many times and averages, and the average is finer than one count of the converter. Average N readings and random error shrinks by √N: 4 readings buy one extra bit, 16 buy two, 256 buy four, so a 10-bit converter behaves like a 14-bit one. It only works if a little noise, called dither, makes the readings scatter, and only for signals slow enough to wait for all those readings.

How an average sees fractions

A 10-bit converter only says whole counts: 499, 500, 501. Suppose the true value is 500.3 and the readings carry a count or two of random noise. Most readings come out 500, quite a few 501, the odd one 499. The average of many of them closes in on 500.3, a value no single reading could give.

It needs the noise

Take the noise away and every reading is the truth rounded: 500, 500, 500. The average of a thousand of them is still exactly 500. The noise is what carries the fraction, which is why some converters add noise on purpose before converting.

The square-root price

error ∝ 1 ÷ √N
Readings averagedAverage errorExtra bits
10.99 counts0
40.51 counts1
160.25 counts2
640.11 counts3
2560.058 counts4

Each halving of the error costs four times the readings, and four times the time.

Live experiment

Average your way past a count

A 10-bit converter reads a value creeping from 500.0 to 501.0 counts, with up to two counts of noise. Average 1, 4, 16, 64 or 256 readings: the error falls from 0.99 counts to 0.51, 0.25, 0.11 and 0.058. Then switch the noise off and watch averaging stop helping.

Try it yourself: free lesson

“Oversampling” is lesson 3 of 5 in Dither Delta, Sensors & Signal Processing World 2. Free with an account. Lessons unlock in order, so you’ll do the 9 before it first.

In code

long total = 0;
for (int i = 0; i < 64; i++) total += analogRead(A0);
float value = total / 64.0;   // keep the fraction

Limits

  • Slow signals only. 256 readings per answer divide the sample rate by 256: fine for a temperature or a weight, useless for audio.
  • Random errors only. An offset or gain error is the same in every reading, so averaging keeps it. That needs calibration.
  • Enough noise. With less than about a count of random noise, readings stick to one value and the average stops improving.

Kitchen scales that read to a gram, precision thermometers and the converter behind your phone's microphone all lean on oversampling. Audio converters push it furthest: delta-sigma converters sample millions of times a second at very low resolution and average their way to 24-bit sound.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Oversampling” is lesson 3 of 5 in Dither Delta, Sensors & Signal Processing World 2. Free with an account. Lessons unlock in order, so you’ll do the 9 before it first.

Or start from the very first lesson, no account needed

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3Averaging 64 readings instead of 1 makes the error about…
    Show the answer

    Answer: 8 times smaller: √64. Error shrinks with the square root of the number of readings: √64 = 8. The harness measured 0.99 → 0.11.

    • Why not “Twice as small”? Twice as small takes only four readings. Sixty-four gives √64 = 8 times smaller.
    • Why not “The same”? With noise to dither the readings, averaging does shrink the error, by √64.
    • Why not “64 times smaller”? Random errors only partly cancel, so the error falls with the square root of the count: √64 = 8, not 64.
  2. Question 2 of 3Each extra bit of resolution from oversampling costs…
    Show the answer

    Answer: Four times as many readings. One bit halves the smallest step. Halving the error takes four times the readings, because of the square root.

    • Why not “Nothing”? Every extra bit costs four times the conversions, and four times the time.
    • Why not “Twice as many”? Doubling the readings shrinks the error by √2, only half a bit. A whole bit needs four times.
    • Why not “One more reading”? One reading barely changes an average of many. Each bit needs the count multiplied by four.
  3. Question 3 of 3Why a long for the total?
    Show the answer

    Answer: 256 readings near 500 add up to 128,000, past what a 16-bit int holds. On a real Arduino an int stops at 32,767. Totals of many readings need a long.

    • Why not “longs are faster”? A long is usually slower on an 8-bit chip. It's chosen because the total needs the room.
    • Why not “floats can't add”? Floats can add perfectly well. The point is that a 16-bit int overflows past 32,767.
    • Why not “No reason”? There is one: 256 readings of about 500 total 128,000, far past an int's 32,767 on an Uno.
Keep practising: free lesson

“Oversampling” is lesson 3 of 5 in Dither Delta, Sensors & Signal Processing World 2. Free with an account. Lessons unlock in order, so you’ll do the 9 before it first.

Questions people ask

How many samples do I need for one extra bit of resolution?

Four. Averaging N readings shrinks random error by √N, and one extra bit halves the step size, so it takes four times the readings. Two extra bits take 16, four extra bits 256.

Why does oversampling need noise?

Without noise, a steady input reads the same whole count every time, and the average of identical numbers is that same number. A count or two of random noise makes the readings scatter around the true value, so their average can land between counts.

Can oversampling fix an inaccurate ADC?

No. It improves resolution against random noise only. An offset, a gain error or a reference that's off by 1 % is the same in every reading, so averaging keeps it. Those need calibration.

Every topic