Guides › What Is an ADC? Resolution, Reference Voltage and Converting Raw Values to Volts
What Is an ADC? Resolution, Reference Voltage and Converting Raw Values to Volts
An ADC (analog-to-digital converter) turns a continuous voltage into an integer a microcontroller can process. Sensor outputs, battery voltage and 4-20mA receiver voltages almost always pass through one. The numbers returned by Arduino analogRead(), STM32 HAL_ADC or ESP32 adc1_get_raw() are raw ADC values.
Resolution
An n-bit ADC divides its input range into 2n steps. More bits resolve smaller voltage changes.
| Resolution | Max value | 1 LSB at 3.3 V | 1 LSB at 5 V | Typical use |
|---|---|---|---|---|
| 8-bit | 255 | 12.94 mV | 19.61 mV | Simple MCUs |
| 10-bit | 1023 | 3.23 mV | 4.89 mV | Arduino Uno (ATmega328P) |
| 12-bit | 4095 | 0.81 mV | 1.22 mV | STM32, ESP32 |
| 16-bit | 65535 | 0.050 mV | 0.076 mV | External ADCs (ADS1115, etc.) |
Raw value to voltage
Voltage = raw / (2ⁿ − 1) × Vref
Vref is the reference (full-scale) voltage. A 12-bit reading of 2048 with Vref = 3.3 V gives 2048 / 4095 × 3.3 = 1.650 V. A 10-bit reading of 512 at 5 V gives 512 / 1023 × 5 = 2.502 V.
Some datasheets divide by 2ⁿ (4096, etc.) instead of 2ⁿ − 1, depending on whether the top code equals Vref or one LSB below it. The difference is under 1 LSB. Follow your chip's datasheet when precision matters. This site's calculator uses 2ⁿ − 1.
To predict the raw value from a voltage: raw = voltage / Vref × (2ⁿ − 1).
The reference voltage sets the accuracy
An ADC measures the input as a ratio of Vref, so a 1% error in Vref is a 1% error in every reading.
- Using USB 5 V as Vref means it really varies between about 4.7 and 5.2 V, and readings wander with it.
- For accurate readings use an internal reference (for example 1.1 V or 2.048 V) or an external precision reference IC.
- Ratiometric sensors powered from the same supply (potentiometers, bridge sensors) cancel supply variation, which is an advantage.
Sources of error
| Error | Description | Fix |
|---|---|---|
| Quantization | Values between steps cannot be represented; up to ±½ LSB | Higher resolution |
| Offset | 0 V input does not read 0 | Zero calibration |
| Gain | Slope differs from ideal | Two-point calibration |
| Nonlinearity (INL/DNL) | Uneven step widths; the ESP32 ADC is notably nonlinear near both ends | Correction table, restrict the range used |
| Noise | From supply, digital circuits, wiring | RC filter, averaging, separate grounds |
| Source impedance | A high-impedance source cannot charge the sampling capacitor in time | Buffer amplifier, longer sampling time, input capacitor |
Sampling rate and averaging
To represent a signal you must sample faster than twice its highest frequency (the Nyquist theorem). For slow signals such as temperature, averaging several readings reduces noise. Oversampling by 4 and averaging can add one bit of effective resolution, provided there is enough noise to dither the input.
ADC types
- SAR (successive approximation): the ADC built into most MCUs; medium speed and resolution.
- Sigma-delta: slow but 16-24 bit resolution; load cells and precision measurement.
- Flash: very fast but low resolution and expensive; oscilloscopes.
Measuring above Vref: voltage dividers
The ADC input must not exceed Vref, so two resistors scale the voltage down.
Vadc = Vin × R2 / (R1 + R2) Example: 12 V battery on a 3.3 V ADC, R1 = 30 kΩ, R2 = 10 kΩ → Vadc = 3.0 V
Multiply the measured voltage by (R1 + R2) / R2 to recover the original. Very large resistor values cause source-impedance errors, so check the datasheet recommendation (often 10 kΩ or less).
Reading a 4-20mA signal with an ADC
Pass the current through a precision resistor. With 150 Ω on a 3.3 V ADC, 4 mA becomes 0.6 V and 20 mA becomes 3.0 V, which is roughly 745 to 3723 on a 12-bit ADC. To convert that back to engineering units, see the 4-20mA guide.
Try it now: ADC to Voltage Calculator (runs in your browser, no data is sent anywhere)