The Direct Conversion: If you are asking how an analogue to digital converter works in practical bench terms, the core function is a direct mathematical translation from continuous voltage to discrete integer codes. For a standard 10-bit ADC with a 5.0V reference voltage, an analog input of 2.5V converts to a digital value of 512.

The universal formula for this conversion is:

Digital Code = (V_in / V_ref) × (2^n - 1)

Substituting our benchmark values: (2.5V / 5.0V) × (2^10 - 1) = 0.5 × 1023 = 511.5, which the ADC rounds to 512. This assumes a unipolar, single-ended input where 0V yields a code of 0, and 5.0V yields the maximum code of 1023.

The Core Conversion: Volts to Digital Codes

Understanding how an analogue to digital converter works requires looking at the Least Significant Bit (LSB)—the smallest voltage change the ADC can detect. The assumption that fixes your conversion accuracy is your reference voltage (V_ref) and the bit-depth (n). If your V_ref drifts by even 1%, your entire digital output scales proportionally, introducing systemic gain error.

Below is the conversion table for neighboring values within a ±20% range of our 2.5V baseline, assuming a 10-bit resolution and a stable 5.0V V_ref:

Analog Input (V_in)Percentage of V_refDigital Code (10-bit)Voltage per Step (LSB)
2.00V40%4094.88 mV
2.25V45%4604.88 mV
2.50V50%5124.88 mV
2.75V55%5634.88 mV
3.00V60%6144.88 mV

When selecting an ADC for a project, the bit-depth dictates your resolution. Modern microcontrollers like the ESP32-S3 feature 12-bit ADCs, while precision external modules like the Texas Instruments ADS1115 offer 16-bit resolution. Here is how the LSB voltage shifts across common resolutions for standard 5V and 3.3V logic systems:

ADC ResolutionTotal Steps (2^n)LSB Size @ 5.0V V_refLSB Size @ 3.3V V_refTypical Use Case
8-bit25619.53 mV12.89 mVBasic potentiometer dials, simple thresholds
10-bit1,0244.88 mV3.22 mVStandard Arduino Uno (ATmega328P) analogRead()
12-bit4,0961.22 mV0.81 mVESP32 internal ADCs, battery voltage monitoring
16-bit65,53676.29 µV50.35 µVPrecision load cells, thermocouple amplifiers
24-bit16,777,2160.30 µV0.20 µVAudio interfaces, laboratory multimeters

As noted in Analog Devices' MT-001 tutorial on data converters, chasing higher bit-depths is useless if your analog front-end has more noise than the LSB size. A 16-bit ADC on a noisy breadboard will often only yield 12 bits of effective resolution (ENOB) due to thermal and switching noise.

Scaling for Mains: 120V, 230V, and 3-Phase ADC Measurements

SAFETY WARNING: Never connect 120V or 230V AC mains directly to an ADC pin. Mains voltage will instantly destroy the microcontroller and pose a lethal electrocution hazard. Always use an isolated step-down voltage transformer (like the ZMPT101B module) or a certified hall-effect voltage sensor.

An ADC only understands low-voltage DC (typically 0–3.3V or 0–5V). So how does the conversion math shift when you need to measure 120V or 230V AC mains? The answer shifts from a simple DC ratio to an AC scaling and RMS calculation.

120V vs 230V Shift:
A 120V RMS sine wave has a peak voltage of roughly 170V. A 230V RMS sine wave peaks at 325V. To use an ADC, you pass the mains through a voltage transformer with a specific turns ratio to scale the peak down to your V_ref.

  • For 120V (US): A transformer might scale 170V peak down to 3.3V peak. The ADC reads the 3.3V peak as its maximum code (e.g., 4095 on a 12-bit ADC). Your software must multiply the ADC reading by the transformer ratio (170/3.3 = 51.5) and then multiply by 0.707 to convert the peak back to RMS.
  • For 230V (EU): The physical transformer must have a higher step-down ratio to keep the 325V peak under the 3.3V ADC limit. The software multiplier shifts accordingly (e.g., 325/3.3 = 98.4). If you use a 120V-scaled ZMPT101B module on a 230V grid without changing the voltage divider resistors, the ADC will rail at the maximum code, clipping the waveform and rendering the RMS calculation entirely wrong.

The 3-Phase Shift:
Measuring 3-phase power requires three separate ADC channels sampling simultaneously. The conversion math shifts from a single scalar value to vector mathematics. You must calculate the true power by multiplying the instantaneous voltage and current ADC codes for each phase, integrating over a full cycle, and accounting for the 120-degree (2π/3 radian) phase shift between channels. If your ADC multiplexes rather than sampling simultaneously (like the internal ADC on older ESP8266 chips), the phase-shift math will introduce massive errors in power factor calculations.

When the Conversion Becomes Meaningless

Knowing how an analogue to digital converter works also means knowing when to trust its output. The voltage-to-bit conversion becomes mathematically meaningless under three specific conditions:

  1. Violating the Nyquist-Shannon Sampling Theorem: To accurately reconstruct an AC waveform, your ADC must sample at least twice as fast as the highest frequency component of the signal. If you are measuring 60Hz mains power, you need a minimum sampling rate of 120 Hz. In practice, you need at least 1 kHz to capture harmonics. If you sample a 60Hz wave at 50Hz, aliasing occurs, and the ADC will output a digital code representing a completely false, lower-frequency wave.
  2. Floating or Noisy V_ref: The formula V_in / V_ref assumes V_ref is an absolute constant. If you use the default USB 5V rail as your reference on an Arduino, and the PC's USB port sags from 5.0V to 4.8V under load, your digital codes will artificially inflate even if the actual analog input hasn't changed. For precision work, always use a dedicated voltage reference IC (like the LM4040) or the microcontroller's internal bandgap reference.
  3. Quantization Error Exceeds Signal Amplitude: If you try to measure a 5mV ripple on a power supply using an 8-bit ADC with a 5V reference, your LSB is 19.5mV. The signal is smaller than a single digital step. The ADC will output a flat line, completely missing the ripple. As detailed in Texas Instruments' SLAA013 application note on understanding data converters, you must match the ADC's dynamic range to the signal's amplitude, or use a programmable gain amplifier (PGA) front-end.

Frequently Asked Questions

Why does my ESP32 ADC read non-linear values at the top and bottom of the range?
The internal 12-bit ADC on the original ESP32 (ESP32-WROOM-32) is notorious for non-linearity near 0V and 3.3V due to internal transistor threshold voltages. The conversion math breaks down below 0.1V and above 3.1V. For accurate conversions across the full rail, use an external I2C ADC like the ADS1115.

What is the difference between unipolar and bipolar ADC conversion?
A unipolar ADC converts 0V to V_ref into positive integers (e.g., 0 to 1023). A bipolar ADC accepts negative voltages (e.g., -5V to +5V) and uses two's complement or offset binary coding, where 0V sits at the mid-scale code (512), negative voltages yield codes below 512, and positive voltages yield codes above 512.