When reading a precise 2.500V DC signal using a 12-bit analog to digital converter (ADC) with a 3.300V reference, the exact digital output integer is 3102. The governing formula for this conversion is Digital Value = (Vin ÷ Vref) × (2n - 1). Substituting our bench values: (2.500 ÷ 3.300) × (212 - 1) = 0.7575 × 4095 = 3102.27, which the microcontroller truncates to 3102. If you are mapping sensor voltages to microcontroller registers, this direct conversion is your baseline. Below is the ±20% neighborhood table for this exact 12-bit/3.3V setup, showing how the integer shifts with minor analog fluctuations.
| Analog Input (Vin) | Deviation | 12-Bit Digital Output | Hexadecimal Register |
|---|---|---|---|
| 2.000V | -20% | 2481 | 0x9B1 |
| 2.250V | -10% | 2792 | 0xAE8 |
| 2.500V | Baseline | 3102 | 0xC1E |
| 2.750V | +10% | 3412 | 0xD54 |
| 3.000V | +20% | 3722 | 0xE8A |
The Core Assumptions That Fix Your Conversion
The math above assumes two rigid hardware realities: a perfectly stable Voltage Reference (Vref) and a fixed Bit Resolution (n). In practice, the assumption that fixes your answer is the Vref stability. If your 3.3V LDO regulator is actually outputting 3.26V due to thermal drift or load regulation, your 2.500V input will no longer read 3102; it will read 3140. The digital integer is merely a ratio of the input to the reference, not an absolute measurement of voltage.
Different microcontrollers and external ADC ICs handle this reference differently. Below is a data-dense specification table of common ADC architectures you will encounter on the bench, highlighting how the Least Significant Bit (LSB) size—the voltage weight of a single integer step—shifts dramatically based on the hardware.
| Microcontroller / IC | Resolution (n) | Default Vref | Max Steps (2n-1) | LSB Size (Voltage/Step) |
|---|---|---|---|---|
| Arduino Uno (ATmega328P) | 10-bit | 5.0V (VCC) | 1023 | 4.88 mV |
| ESP32-WROOM-32 (SAR) | 12-bit | 3.3V (VDD_A) | 4095 | 0.80 mV (theoretical)* |
| Raspberry Pi Pico (RP2040) | 12-bit | 3.3V (VREF) | 4095 | 0.80 mV |
| TI ADS1115 (External I2C) | 16-bit | 4.096V (Internal) | 32767 (signed) | 0.125 mV |
| Microchip MCP3008 (SPI) | 10-bit | VDD (e.g., 3.3V) | 1023 | 3.22 mV |
adc_oneshot driver.
How the Math Shifts for 120V vs 230V vs 3-Phase Mains
When moving from low-voltage DC bench signals to measuring mains AC (120V vs 230V vs 3-phase), the ADC conversion shifts from a simple static ratio to a dynamic scaling and sampling problem. You cannot feed 120V AC directly into an ADC; you must step it down using a voltage divider or a Potential Transformer (PT) like the ZMPT101B module.
Here is how the conversion assumptions shift across different power systems:
- 120V AC (North America): The RMS voltage is 120V, but the peak voltage is ~170V. Your PT scaling must ensure the peak fits within the 0-3.3V ADC window, usually mapping 170V peak to 1.65V peak centered around a 1.65V DC bias. The ADC reads instantaneous DC snapshots, not RMS directly.
- 230V AC (Europe/UK): The peak voltage jumps to ~325V. If you use the exact same voltage divider ratio as your 120V setup, the 325V peaks will exceed the ADC's Vref, clipping the waveform and rendering the digital integers useless. You must increase the step-down ratio to keep the signal within the 0-3.3V bounds.
- 3-Phase Systems: Measuring 3-phase power requires three separate ADC channels sampled simultaneously (or at a high enough multiplexing speed to ignore phase drift). If your microcontroller reads Phase A, waits 5ms, reads Phase B, and waits 5ms to read Phase C, the resulting integers represent different points in time. The 120-degree phase relationship is destroyed, making vector calculations and total power computations entirely invalid.
When Voltage-to-Digital Conversion Becomes Meaningless
There are specific bench and field conditions where trusting your ADC integer conversion will lead to catastrophic design flaws or incorrect data logging.
1. When Power Factor (PF) is Unknown in AC Circuits
If you are using ADCs to measure both AC voltage and AC current to calculate Real Power (Watts), the conversion to Watts is strictly meaningless without knowing the Power Factor. The formula is P = Vrms × Irms × PF. An ADC only gives you the raw waveform data to calculate Vrms and Irms. If you are measuring an inductive load like an AC motor and assume a PF of 1.0 (purely resistive), your calculated wattage will be dangerously overstated.
2. When the Noise Floor Exceeds 1 LSB
Look at the Arduino Uno row in the table above: 1 LSB equals 4.88 mV. If your sensor circuit has 10 mV of high-frequency switching noise from a nearby buck converter, your 10-bit ADC will fluctuate by ±2 integers on every read. In this scenario, attempting to resolve 1 mV changes using the formula is mathematically possible but physically meaningless. You must either add an analog RC low-pass filter before the ADC pin or switch to a 16-bit ADC with oversampling.
3. When Nyquist Aliasing Occurs
If you are sampling a 1 kHz AC signal but your microcontroller's ADC sampling rate is only 1.5 kHz, you violate the Nyquist-Shannon sampling theorem. The ADC will output integers that reconstruct as a false 500 Hz low-frequency signal. The voltage-to-integer conversion is accurate for the exact microsecond of the sample, but the resulting dataset represents a phantom frequency.
Frequently Asked Questions
Why does my 16-bit ADS1115 max out at 32767 instead of 65535?
The TI ADS1115 outputs a signed 16-bit integer using two's complement. The range is -32768 to +32767. If you configure the internal PGA for a ±4.096V range, 0V reads as 0, +4.096V reads as 32767, and -4.096V reads as -32768.
Can I use the microcontroller's 5V VCC pin as my Vref?
You can, but it is poor practice for precision work. VCC rails are noisy and fluctuate with USB voltage drops or digital switching loads. If VCC drops from 5.00V to 4.85V, your Vref shifts, and every digital integer you log will be scaled incorrectly. Always use a dedicated voltage reference IC or the microcontroller's internal bandgap reference for critical measurements.
How do I handle negative voltages on a single-supply ADC?
Standard single-supply ADCs (like the ATmega328P or RP2040) cannot read negative voltages; doing so can damage the silicon or trigger the internal protection diodes. You must use an op-amp level-shifter to bias the AC or bipolar signal into the 0V to Vref window, or use a differential ADC like the ADS1115 which natively handles negative differential inputs.






