If you are measuring a 2.50V analog signal using a standard 10-bit analog to digital converter (ADC) referenced to 3.3V, your digital output code is 775 (hex 0x307). The exact formula used is Code = floor((Vin / Vref) * (2^n - 1)). Substituting your values: floor((2.50 / 3.30) * 1023) = 775. This is the definitive translation for microcontrollers like the ESP32 or ATmega328P (when scaled) operating at this specific reference.

The Core Conversion Formula & Fixed Assumptions

The math behind analog to digital converters relies entirely on two fixed assumptions: the reference voltage (Vref) and the bit resolution (n). The ADC does not measure absolute voltage; it measures the ratio of the input voltage to the reference voltage, then slices that ratio into discrete steps.

Bench Reality Check: Never assume Vref is exactly the VCC pin. On an ESP32-WROOM-32, the internal Vref is nominally 1.1V but varies per chip due to silicon variance. If you use the raw analogRead() function, your 2.50V input might return 760 or 790. Always use calibrated library functions like analogReadMilliVolts() in the ESP-IDF/Arduino core, which applies factory-stored eFuse calibration data to fix the assumption.

The universal conversion formula is:

Digital Code = floor( (Vin / Vref) * (2^n - 1) )

  • Vin: The analog voltage at the pin (must be 0V to Vref).
  • Vref: The maximum voltage the ADC can resolve.
  • n: The bit-depth (e.g., 10, 12, 16).
  • 2^n - 1: The maximum digital code (e.g., 1023 for 10-bit).

Neighboring Values: 10-Bit ADC at 3.3V (±20% Range)

When debugging a sensor circuit, you rarely sit at exactly 2.50V. Below is the conversion table for a ±20% voltage swing around our 2.50V target, assuming a stable 3.3V Vref and 10-bit resolution. Notice that every ~3.22mV change in the analog domain results in a 1-step change in the digital domain (the Least Significant Bit, or LSB).

Analog Voltage (Vin) Digital Code (Decimal) Digital Code (Hex) Delta from 2.50V
2.00V6200x26C-155 steps
2.10V6510x28B-124 steps
2.20V6820x2AA-93 steps
2.30V7130x2C9-62 steps
2.40V7440x2E8-31 steps
2.50V7750x307Baseline
2.60V8060x326+31 steps
2.70V8370x345+62 steps
2.80V8680x364+93 steps
2.90V8990x383+124 steps
3.00V9300x3A2+155 steps

How the Math Shifts: 5V, 12-Bit, and 16-Bit Architectures

Presenting a single-voltage answer as universal is a common trap. If you move your 2.50V signal to a different microcontroller or external IC, the code shifts drastically based on the architecture.

  • 5.0V Reference (10-bit): If you feed 2.50V into an older Arduino Uno (ATmega328P) referenced to 5V, the math shifts to floor((2.50 / 5.00) * 1023) = 511. The LSB size doubles to 4.88mV, cutting your resolution in half.
  • 3.3V Reference (12-bit): If you use an STM32 microcontroller or an external Microchip MCP3008 (wait, MCP3008 is 10-bit, let's use MCP3208 for 12-bit conceptually, but I will just state 12-bit architecture like STM32 internal ADC), the max code is 4095. The formula yields floor((2.50 / 3.30) * 4095) = 3102. Your LSB shrinks to 0.80mV.
  • 4.096V Reference (16-bit): If you use a precision external ADC like the Texas Instruments ADS1115 set to its 4.096V internal reference, the max code is 65535 (unsigned). The calculation becomes floor((2.50 / 4.096) * 65535) = 39996. The LSB is now a microscopic 62.5µV.

When the Conversion Becomes Meaningless

Math assumes a perfect physical world. On the bench, the conversion yields garbage data under three specific conditions:

  1. Clipping (Vin > Vref): If your signal hits 3.4V on a 3.3V ADC, the internal sample-and-hold circuit saturates. The ADC will blindly output the maximum code (1023) regardless of how much higher the voltage goes. You lose all data above the rail.
  2. Noise Floor Exceeds LSB: A 16-bit ADC has an LSB of ~50µV at a 3.3V reference. If your breadboard has 10mV of switching noise from a nearby buck converter, your bottom 8 bits are pure random noise. Reading a 16-bit code in this environment gives you a false sense of precision; you are effectively running an 8-bit ADC.
  3. Source Impedance Mismatch: ADCs use an internal sampling capacitor (often 10pF to 50pF) that must charge to Vin during the acquisition window. If your sensor has a high output impedance (>10kΩ), the capacitor cannot charge fully before the conversion starts, resulting in a code that reads artificially low. Always buffer high-impedance sensors with an op-amp voltage follower.

Decision Tree: Picking the Right ADC IC for Your Bench

Stop guessing which analog to digital converter to add to your I2C or SPI bus. Use this decision matrix to lock in your part number.

If your project requires... Then you need... Concrete Part Pick
High-speed waveform capture (>1 MSPS) for audio or motor control Parallel or high-speed SPI SAR ADC Analog Devices AD9226 (12-bit, 65 MSPS)
Isolated high-voltage monitoring (e.g., solar strings, mains) Sigma-Delta ADC with digital isolation Texas Instruments AMC1301
Multi-channel DC sensor logging (thermocouples, strain gauges) Multi-channel I2C Sigma-Delta with PGA TI ADS1115 (16-bit, 4-ch, I2C)

The Default Bench Pick: For 90% of hobbyist and prototyping DC measurement tasks, terminate your search at the TI ADS1115. It solves the ESP32's internal ADC non-linearity issues, provides a programmable gain amplifier (PGA) to scale down higher voltages, and communicates over standard I2C. Wire the ADDR pin to GND for I2C address 0x48, and use the Adafruit_ADS1X15 library for immediate, calibrated results.

FAQ: Analog to Digital Converters Quick Answers

Can I read negative voltages with a standard microcontroller ADC?
No. Standard single-supply microcontroller ADCs will read 0 (or behave unpredictably/damage the pin) if Vin drops below GND. To read AC or bipolar signals, you must bias the signal to Vref/2 using a resistor divider, or use an external ADC with a dual-polarity reference like the ADS1115 in differential mode.

Why does my ADC reading fluctuate by ±5 counts when the multimeter is stable?
Multimeters use heavy hardware low-pass filtering and high-resolution internal ADCs. Microcontroller ADCs sample instantaneously and capture high-frequency thermal and EMI noise. Add a 100nF ceramic capacitor directly between the ADC input pin and GND to create a hardware low-pass filter and stabilize the code.