If you are reading 2.5V DC on a standard 12-bit A D converter with a 3.3V reference, your digital output count is 3118. This assumes an unsigned, single-ended conversion where 0V maps to 0 and 3.3V maps to 4095. The formula used to arrive at this is: Digital Count = (Vin / Vref) × (2^n - 1). Substituting the values: (2.5 / 3.3) × 4095 = 3118.18, which truncates to 3118. This baseline math is the foundation of all microcontroller sensor reading, but the exact integer shifts dramatically based on your reference voltage, bit depth, and whether you are measuring DC or scaled AC mains.

The Core Conversion Formula and Neighboring Values

Every A D converter translates a continuous analog voltage into discrete digital steps. The size of each step is called the Least Significant Bit (LSB) weight. For a 12-bit ADC on a 3.3V rail, the LSB weight is 3.3V / 4095 = 0.805 mV per step. If your input voltage fluctuates by less than 0.8 mV, the digital count will not change.

Baseline Assumption: The answer 3118 is fixed strictly by a 3.3V reference and a 12-bit resolution (4095 steps). Change either variable, and the count changes.

Here is how the digital count shifts for voltages within a ±20% range of our 2.5V baseline, assuming the same 12-bit/3.3V hardware:

Analog Input (Vin)12-Bit Count (3.3V Ref)10-Bit Count (5.0V Ref)16-Bit Count (4.096V Ref)
2.0V (-20%)248240932031
2.1V260643033630
2.2V272945035229
2.3V285347136828
2.4V297749138428
2.5V (Baseline)311851240039
2.6V322253241638
2.7V334655243237
2.8V347057344836
2.9V359459346435
3.0V (+20%)372361448035

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

An A D converter cannot measure 120V or 230V directly; doing so will instantly destroy the silicon. To measure AC mains, you must step the voltage down using a transformer (like the ZMPT101B module) or a high-impedance resistor divider, and add a DC bias (usually half of Vref) so the AC wave swings above and below a center point rather than dipping into negative voltages.

Here is how the conversion math shifts when measuring AC mains:

  • 120V AC (North America): The peak voltage is 169.7V. If your voltage divider scales this down to a 1.65V peak (centered on a 1.65V DC bias for a 3.3V ADC), your scaling multiplier is 102.8. You cannot use the simple DC formula; you must sample continuously, subtract the 1.65V bias, square the results, average them, and take the square root (RMS calculation).
  • 230V AC (EU/UK/AU): The peak voltage is 325.2V. Scaled to the same 1.65V peak limit, your hardware scaling multiplier shifts to 197.1. The ADC count math remains identical, but the software multiplier applied to the final RMS calculation nearly doubles.
  • 3-Phase Systems: The per-phase ADC voltage-to-count conversion does not change. However, the sampling architecture shifts. To accurately capture 3-phase power, your A D converter must either have simultaneous sampling (like the Analog Devices ADE9000) or sample fast enough that the phase shift between sequential reads is negligible. If using a single-channel ADC multiplexed across three phases, a 50Hz wave requires a minimum 10kHz sampling rate to maintain less than 1 degree of phase error between readings.

Decision Path: Picking the Right A D Converter

Do not default to your microcontroller's internal ADC without verifying its noise floor. Use this decision tree to select the exact hardware for your bench or jobsite project.

If your application requires...Then choose this architecture...Concrete Part Pick
Basic DC sensors (potentiometers, basic light levels) where ±5mV error is acceptable.Internal Microcontroller ADC (10-bit to 12-bit)Internal ATmega328P (Arduino Uno) or ESP32
High-speed audio capture or fast AC waveform sampling (>100 kSPS).External SPI ADC (10-bit to 12-bit)Microchip MCP3008 (10-bit, 200kSPS)
Precision DC measurement (load cells, RTDs, 4-20mA loops) where sub-millivolt resolution is mandatory.External I2C Sigma-Delta ADC (16-bit to 24-bit) with PGATexas Instruments ADS1115 (16-bit, 860SPS)
Default Recommendation: If you are unsure, buy the ADS1115. At roughly $4 to $6 for a breakout board, its internal Programmable Gain Amplifier (PGA) and 16-bit resolution will rescue almost any noisy sensor project, completely bypassing the mediocre internal ADCs found on most hobbyist microcontrollers.

When the Voltage-to-Count Conversion Becomes Meaningless

The formula (Vin / Vref) × Max_Count assumes a perfectly linear transfer function. In reality, there are three common scenarios where this math breaks down and yields garbage data:

  1. ESP32 Internal ADC Non-Linearity: The internal 12-bit ADC on the original ESP32 (and ESP32-S2) is notoriously non-linear at the extremes. According to Espressif's official documentation, readings below 0.1V often read as 0, and readings above 3.1V saturate and read as 4095 regardless of actual input. If your 2.5V signal has noise spikes pushing it to 3.2V, your conversion math will falsely cap at 3.3V.
  2. Floating Inputs and Missing Grounds: If the ground of your sensor circuit is not bonded to the ground of your microcontroller (equipotential bonding), the ADC is measuring the potential difference against a floating reference. The counts will drift randomly.
  3. Unknown PGA Settings: Chips like the ADS1115 feature a Programmable Gain Amplifier. If your code sets the PGA to ±2.048V full-scale, but you feed it 2.5V, the ADC will rail out at the maximum positive count (32767 for signed 16-bit), rendering the exact voltage mathematically unknowable.

FAQ: A D Converter Conversion Edge Cases

Why does my 16-bit ADC output negative numbers?

Many precision A D converters (like the ADS1115) output signed integers using two's complement. A 16-bit signed ADC ranges from -32768 to +32767, not 0 to 65535. If you are measuring a 0-3.3V single-ended signal, you must ensure the chip is configured for single-ended mode, or map the negative binary values to positive in your code.

Does a higher bit depth always mean better accuracy?

No. Bit depth dictates resolution (how small a step you can see), but not accuracy (how close that step is to reality). A cheap 16-bit ADC with a noisy 5V USB power supply acting as its Vref will yield highly resolved, but entirely inaccurate, numbers. For true accuracy, you must feed the ADC's Vref pin from a dedicated precision voltage reference IC, like the LM4040.

How do I handle 5V sensors on a 3.3V microcontroller ADC?

Never connect a 5V output directly to a 3.3V ADC pin; you will back-feed the microcontroller's protection diodes and eventually fry the GPIO. Use a simple voltage divider (e.g., a 10kΩ and 20kΩ resistor pair) to scale the 5V signal down to 3.33V, then apply a 0.66 multiplier in your software conversion math.