If you are converting a 2.5V analog signal using a standard 12-bit analogue to digital converter with a 3.3V reference (like the internal ADC on an ESP32-WROOM-32), the exact digital output value is 3102. The formula used with values substituted is: Digital Value = (2.5V / 3.3V) × (2^12 - 1), which calculates to 0.7575 × 4095 = 3102.27, rounded down to the nearest integer 3102. This conversion assumes a stable 3.3V reference and a perfectly linear ADC response.

The Core ADC Conversion Formula & Neighboring Values

Every analogue to digital converter (ADC) maps a continuous physical voltage into a discrete digital number. The universal formula for this conversion is:

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

Where D is the digital output value, V_in is the measured input voltage, V_ref is the reference voltage, and n is the bit resolution. The assumption that fixes this answer is the reference voltage (V_ref) combined with the bit resolution (n). Without knowing both, any digital number is just a meaningless ratio.

Below is a lookup table for neighboring values within a ±20% range of our 2.5V target (2.0V to 3.0V), assuming a 12-bit resolution and a 3.3V reference. This is highly useful when calibrating sensors like the MQ-135 gas sensor or a standard 10k potentiometer voltage divider.

Analog Input (V_in)12-Bit Digital Value (3.3V Ref)Percentage of Max Scale
2.00V248160.6%
2.10V260563.6%
2.20V272966.6%
2.30V285369.6%
2.40V297772.7%
2.50V (Target)310275.7%
2.60V322678.7%
2.70V335081.8%
2.80V347484.8%
2.90V359887.8%
3.00V372290.9%

How Resolution, Reference Voltage, and Mains Shift the Output

A digital value of 3102 is not a universal constant for 2.5V. The answer shifts dramatically depending on the silicon you are using. An Arduino Uno R3 uses the ATmega328P microcontroller, which features a 10-bit ADC typically referenced to 5.0V. Conversely, precision external ADCs like the Texas Instruments ADS1115 offer 16-bit resolution with configurable internal references.

ADC Hardware / ICResolution (n)Default V_refDigital Value for 2.5VMax Measurable Voltage
Arduino Uno (ATmega328P)10-bit5.0V5115.0V
ESP32-WROOM-32 (Internal)12-bit3.3V31023.3V (approx 2.5V linear)
ADS1115 (External I2C)16-bit4.096V200004.096V
MCP3008 (External SPI)10-bit3.3V7753.3V

How the answer shifts for 120V vs 230V vs 3-phase AC

An ADC microcontroller pin cannot measure mains voltage directly—applying 120V or 230V to an ESP32 or Arduino will instantly destroy the silicon and pose a lethal shock hazard. To measure AC mains, you must use an isolation module like the ZMPT101B voltage transformer, which scales mains RMS down to a safe 0-3.3V AC waveform. The ADC reads the instantaneous scaled voltage, not the RMS value. For 120V nominal (peaking at ~170V), the sensor outputs a different peak voltage than 230V nominal (peaking at ~325V), requiring distinct scaling multipliers in your code. For 3-phase systems, a single ADC channel is meaningless; you need three separate ADC channels sampling simultaneously to capture the 120-degree phase shifts between L1, L2, and L3.

When ADC Conversion Becomes Meaningless (Edge Cases)

Blindly applying the (V_in / V_ref) × (2^n - 1) formula will lead to critical errors in real-world circuits if you ignore hardware limitations. The conversion becomes entirely meaningless under the following conditions:

  • The ESP32 Non-Linearity Trap: The internal ADC on the ESP32 is notoriously non-linear near the rails. According to the Espressif ESP32 ADC API Reference, readings above ~2.5V (digital value ~3100) and below ~0.1V suffer from severe attenuation and saturation. If your 2.5V signal fluctuates to 2.8V, the ESP32 might still report 3100. For precision 2.5V measurements, you must bypass the internal ADC and use an external I2C module like the TI ADS1115.
  • Clipping (V_in > V_ref): If your reference voltage is 3.3V and you feed 4.0V into the pin, the ADC will simply output the maximum possible integer (e.g., 4095 for 12-bit). You lose all data about how far above the reference the voltage actually is, and you risk damaging the microcontroller's internal clamping diodes if the current isn't limited.
  • Floating or Noisy V_ref: If you are using the microcontroller's VCC as your ADC reference (common on cheap Arduino clones powered via USB), a noisy USB power supply dropping from 5.0V to 4.7V will artificially inflate your digital readings. The math assumes a fixed V_ref; if V_ref fluctuates, your digital output fluctuates even if the actual sensor voltage is perfectly stable.

Analogue to Digital Converter Troubleshooting FAQ

Q: Why does my 12-bit ADC output 4095 when I measure exactly 3.3V?
A: This is saturation. Most 12-bit ADCs max out slightly before the true reference voltage due to internal voltage drops. Furthermore, if you are using an ESP32, the ADC saturates around 2.5V to 2.7V depending on the specific attenuation settings (e.g., ADC_ATTEN_DB_11). You are likely hitting the hardware ceiling, not a math error.

Q: How do I convert the digital value back to voltage in Arduino/ESP32 code?
A: Invert the formula. Use Voltage = (Digital_Value × V_ref) / (2^n - 1). For a 10-bit Arduino reading 511 on a 5V reference: (511 × 5.0) / 1023 = 2.497V. Always use floating-point variables (float) in your code to prevent integer division truncation from destroying your decimal precision.

Q: Does a higher bit resolution always mean better accuracy?
A: No. Resolution is just the size of the slice; accuracy is how close the slice is to reality. A 16-bit ADC (65,535 steps) is useless if your reference voltage has 50mV of noise, as the lowest 4 or 5 bits will just be reading random electrical noise. For high-resolution ADCs, you must use star grounding, decoupling capacitors (100nF ceramic + 10µF tantalum) directly at the V_ref pin, and shielded analog traces.