The Direct Conversion: 2.5V to Digital Counts
To convert an analog input of 2.5V using a standard 10-bit A/D converter with a 5.0V reference voltage, the digital output is exactly 512 counts (or 0x200 in hexadecimal). The governing formula is Digital Count = (Vin / Vref) × 2^N. Substituting our exact values: (2.5V / 5.0V) × 1024 = 512. This direct conversion assumes an ideal linear transfer function, a perfectly stable 5.0V reference, and ignores offset/gain errors inherent in physical silicon.
Vref / 2^N.
Neighboring Values: ±20% Voltage Range Chart
When debugging a sensor circuit, you rarely hit exactly 2.500V. Here is how the digital counts shift across a ±20% range (2.0V to 3.0V) for two common microcontroller environments: a 5V Arduino Uno (10-bit internal ADC) and a 3.3V ESP32 (12-bit internal ADC).
| Analog Input (Vin) | 10-Bit ADC (5.0V Ref) LSB = 4.88mV |
12-Bit ADC (3.3V Ref) LSB = 0.80mV |
Hex Output (10-Bit) |
|---|---|---|---|
| 2.00V | 409 | 2488 | 0x199 |
| 2.10V | 430 | 2612 | 0x1AE |
| 2.20V | 450 | 2737 | 0x1C2 |
| 2.30V | 471 | 2861 | 0x1D7 |
| 2.40V | 491 | 2986 | 0x1EB |
| 2.50V | 512 | 3106 (Clipped to 3.3V max) | 0x200 |
| 2.60V | 532 | Over-range | 0x214 |
| 2.80V | 573 | Over-range | 0x23D |
| 3.00V | 614 | Over-range | 0x266 |
What Fixes the Answer (and When It Shifts)
The numeric answer above is fixed entirely by two assumptions: the Reference Voltage (Vref) and the Resolution (N bits). If either of these shifts, your conversion multiplier changes entirely.
How the Answer Shifts Across System Voltages
- 3.3V Systems (ESP32, Raspberry Pi Pico): If you feed 2.5V into a 12-bit ADC referenced to 3.3V, the math shifts to
(2.5 / 3.3) × 4096 = 3106. Note that 2.6V would yield 3230, but 3.4V will hard-clip at the maximum code of 4095 and potentially damage the GPIO pin if it exceeds the absolute maximum rating. - 5.0V Systems (Arduino Uno, ATmega328P): The standard 10-bit calculation yields 512 for 2.5V. However, if you power the Arduino via USB, the 5V rail often sags to 4.7V. If your code assumes 5.0V but the physical Vref is 4.7V, your calculated voltage will be off by roughly 6%.
- 12V/24V Industrial Systems (PLCs): You cannot feed 12V directly into a microcontroller. You must use a resistor voltage divider (e.g., 10kΩ and 3.3kΩ) to scale 12V down to 3.0V, or use an isolated industrial A/D converter module with a built-in programmable gain amplifier (PGA).
When the Conversion Becomes Meaningless
The formula Vin = Count × LSB becomes mathematically valid but physically meaningless under two conditions:
- Noise Floor Exceeds LSB: A 16-bit ADS1115 running at a 5.0V reference has an LSB of 76µV. If your breadboard power supply has 10mV of switching ripple, that ripple spans 131 digital counts. The bottom 7 bits of your reading are just measuring power supply noise, rendering the 16-bit resolution useless.
- Nyquist Violation: If you are sampling a 1kHz AC waveform but your A/D converter is only executing the
analogRead()loop at 500Hz, your digital counts will suffer from aliasing, producing a completely fabricated low-frequency waveform that does not exist in reality.
A/D Converter Selection Decision Tree
Stop guessing which breakout board to buy. Use this decision matrix to terminate on a specific, proven part number based on your actual bench requirements.
| If Your Application Requires... | And Your Constraint Is... | Then Choose This Exact Part | Typical Cost (2026) |
|---|---|---|---|
| High-precision DC measurements (load cells, RTDs, thermocouples) | Low speed is acceptable (< 1k SPS), I2C interface preferred | Texas Instruments ADS1115 (16-bit, PGA included) | ~$3.50 |
| Reading multiple analog sensors (pots, joysticks, light sensors) | Need 8 channels, moderate speed, SPI interface | Microchip MCP3008 (10-bit, 200k SPS) | ~$2.20 |
| Audio capture, vibration analysis, or high-speed AC waveforms | Need > 100k SPS, parallel or high-speed SPI | Analog Devices AD9226 (12-bit, 65M SPS) or Teensy 4.1 internal ADCs | ~$15.00 |
| Basic battery voltage monitoring or simple threshold triggering | Zero extra BOM cost, low precision acceptable | Internal MCU ADC (ATmega328P 10-bit or ESP32 12-bit) | $0.00 (Built-in) |
Frequently Asked Questions
Why does my ESP32 ADC read 4095 when the pin is only at 2.8V?
The ESP32's internal 12-bit ADC is notoriously non-linear and suffers from a low saturation ceiling. On many ESP32-WROOM-32 modules, the ADC hard-clips at maximum count (4095) around 2.6V to 2.8V, well below the theoretical 3.3V Vref. To fix this, use the analogReadMilliVolts() function in the ESP32 Arduino core (which applies factory-stored eFuse calibration data), or bypass the internal ADC entirely and use an external I2C A/D converter.
How do I convert the digital count back to voltage in code?
Reverse the formula. Multiply the raw integer count by the LSB voltage. For a 10-bit ADC on a 5V system: float voltage = raw_count * (5.0 / 1024.0);. Always use floating-point math for the multiplier to avoid integer truncation errors in C/C++.
What is the difference between an A/D converter and a comparator?
An A/D converter quantifies how much voltage is present by outputting a multi-bit digital number (e.g., 512). A comparator simply outputs a single binary bit (1 or 0) indicating whether the input voltage is higher or lower than a fixed reference threshold. Use an ADC for measurement and logging; use a comparator for hardware-level over-voltage protection or zero-crossing detection.






