How an ADC turns a voltage into a number
An N-bit ADC splits the range from 0 V to the reference voltage Vref into 2N steps and reports which step the input falls in, as a whole number from 0 to 2N − 1:
ADC value = Vin / Vref × 2N
Vin = ADC value × Vref / 2N
A 12-bit ADC with a 3.3 V reference has 4096 steps of 3.3 / 4096 = 0.806 mV. An input of 1.2 V reads 1.2 / 3.3 × 4096 ≈ 1489.
Divide by 4096 or 4095?
Both are in use. The ideal transfer function in most ADC datasheets uses 2N (4096 for 12 bits): each value stands for one step of Vref / 4096, and the top value 4095 is reached one step below Vref. Many application notes and code examples divide by 2N − 1 (4095) instead, so that a reading of 4095 converts back to exactly Vref.
The difference is one part in 4096, about 0.02% for a 12-bit ADC, which is smaller than the offset and gain error of most built-in ADCs. Pick the one your code or datasheet uses, so that numbers match when you compare them.
| Resolution | Values | Step at 3.3 V | Step at 5 V |
|---|---|---|---|
| 8-bit | 0–255 | 12.89 mV | 19.53 mV |
| 10-bit | 0–1023 | 3.223 mV | 4.883 mV |
| 12-bit | 0–4095 | 805.7 µV | 1.221 mV |
| 14-bit | 0–16383 | 201.4 µV | 305.2 µV |
| 16-bit | 0–65535 | 50.35 µV | 76.29 µV |
| 24-bit | 0–16777215 | 196.7 nV | 298 nV |
Turning ADC values into sensor readings
Most analog sensors give a voltage that changes in a straight line with what they measure. Two points from the datasheet are enough to convert: the second panel works out reading = slope × ADC value + offset, which you can put straight into firmware. It also works when the voltage falls as the reading rises, for example a current sensor that gives 2.5 V at 0 A and 0.5 V at 10 A; the slope is then negative.
Frequently asked questions
What happens above Vref?
The ADC reads its top value (4095 for 12 bits) for anything at or above full scale. Inputs above the supply voltage or below 0 V can damage the pin, so use a voltage divider to bring larger voltages into range.
Why does my reading jump by a few counts?
Noise on the input or the reference, and the ADC’s own error, typically move readings by a count or two. Averaging several samples, a small capacitor at the input and a stable reference all help.
What is the LSB?
The least significant bit, the voltage of one step: Vref / 2N. It is the smallest change the ADC can show.
Arduino Uno: what is analogRead() in volts?
The Uno has a 10-bit ADC with a 5 V reference by default, so V = value × 5 / 1024. A reading of 512 is 2.5 V. Choose 10-bit and enter 5 above.