DevTools Hub

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.

ResolutionMax value1 LSB at 3.3 V1 LSB at 5 VTypical use
8-bit25512.94 mV19.61 mVSimple MCUs
10-bit10233.23 mV4.89 mVArduino Uno (ATmega328P)
12-bit40950.81 mV1.22 mVSTM32, ESP32
16-bit655350.050 mV0.076 mVExternal 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.

Sources of error

ErrorDescriptionFix
QuantizationValues between steps cannot be represented; up to ±½ LSBHigher resolution
Offset0 V input does not read 0Zero calibration
GainSlope differs from idealTwo-point calibration
Nonlinearity (INL/DNL)Uneven step widths; the ESP32 ADC is notably nonlinear near both endsCorrection table, restrict the range used
NoiseFrom supply, digital circuits, wiringRC filter, averaging, separate grounds
Source impedanceA high-impedance source cannot charge the sampling capacitor in timeBuffer 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

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)