If you are reading a raw digital value of 2048 from a 12-bit ADC analog to digital converter referenced to 3.3V, the exact input voltage is 1.65V. This direct conversion assumes a perfectly linear response and a stable reference voltage, which is the baseline for microcontrollers like the ESP32-WROOM-32. For a standard 5V Arduino Uno with a 10-bit ADC, that same physical 1.65V input would yield a raw reading of roughly 338 instead of 2048. The numeric answer always depends entirely on your specific bit-depth and reference voltage.
The Core Conversion Formula and Neighboring Values
Every microcontroller ADC maps an analog voltage window to a discrete range of digital integers. The universal formula to reverse this mapping is:
V_in = (Digital_Value / (2^n - 1)) * V_ref
Where n is the bit-depth of the ADC. For our 12-bit ESP32 example (where n=12, making the maximum digital value 4095) and a 3.3V reference, substituting the values looks like this:
V_in = (2048 / 4095) * 3.3V = 1.6503V
To give you a bench-ready reference, here is a table showing how the voltage shifts across a ±20% range of digital values around our 2048 baseline. This is particularly useful when debugging sensor noise or setting threshold triggers in your code.
| Raw Digital Value | Calculated Voltage (V) | Percentage of Full Scale |
|---|---|---|
| 1638 | 1.320V | 40% |
| 1843 | 1.485V | 45% |
| 2048 | 1.650V | 50% |
| 2253 | 1.815V | 55% |
| 2458 | 1.980V | 60% |
What Assumptions Fix the Answer (and When It Is Meaningless)
The raw math above only holds true if two critical assumptions are met: your Reference Voltage (V_ref) is perfectly stable, and the ADC response is linear.
On a USB-powered Arduino Nano, the 5V rail frequently sags to 4.7V under load. If your code assumes V_ref = 5.0V but the physical reality is 4.7V, every voltage calculation in your project will be skewed by 6%. To fix this, you must either measure the actual VCC pin with a multimeter and hardcode that exact value into your sketch, or use the microcontroller's internal bandgap reference to calculate the true VCC dynamically.
When the conversion is completely meaningless:
- Floating Pins: If the ADC pin is disconnected, capacitive coupling from nearby wires will cause the reading to drift wildly. The conversion yields garbage data.
- ESP32 Non-Linearity: The ESP32’s internal ADC is notoriously non-linear at the rails. Readings below 0.1V and above 3.1V are highly inaccurate. If your sensor operates in these zones, the standard linear formula fails. You must either use an external I2C ADC like the Texas Instruments ADS1115 or apply a polynomial correction curve in software.
- Raw AC Measurements: If you wire an AC signal directly to an ADC pin, the negative half of the sine wave will be clipped to 0 (or worse, damage the silicon). The conversion is meaningless unless you apply a DC bias offset to shift the entire AC waveform into the 0–3.3V positive window.
For deep architectural insights into how these internal SAR (Successive Approximation Register) ADCs handle sampling and reference voltages, the Analog Devices ADC architecture guide is the definitive industry reference.
Shifting the Conversion for 120V, 230V, and 3-Phase Mains
Microcontroller ADCs cannot read mains voltage directly; they require a step-down transformer (like the ZMPT101B module) or a high-impedance resistor voltage divider. The ADC itself still only calculates the 0–3.3V range, but the post-conversion scaling factor shifts dramatically depending on the mains topology.
120V vs 230V AC:
A 120V RMS sine wave peaks at roughly 170V. A 230V RMS sine wave peaks at 325V. To map these peaks safely into the ESP32’s 3.3V ADC window, your voltage divider ratio must change. For 120V, a ratio of roughly 100:1 scales the 170V peak down to 1.7V (leaving headroom for the DC bias). For 230V, you must shift to a 150:1 ratio to prevent the 325V peak from slamming into the 3.3V rail and clipping the waveform. If you use a 120V divider on a 230V grid, your ADC will read a flat 4095 during the peaks, making RMS calculation impossible.
3-Phase Systems:
Measuring 3-phase power requires three separate ADC channels. The conversion shifts from a simple scalar multiplication to a time-synchronized vector calculation. Because standard microcontrollers multiplex their ADCs (reading one pin, then the next), there is a microsecond delay between sampling Phase A, Phase B, and Phase C. At 60Hz, this delay introduces a phase-angle error. To get an accurate conversion, you must either use a simultaneous-sampling external ADC chip, or mathematically compensate for the sampling delay in your code before calculating the total 3-phase power.
For exact specifications on the ESP32's ADC attenuation and multiplexing behavior, consult the official Espressif ESP32 ADC API documentation.
Frequently Asked Questions
Why does my ESP32 ADC analog to digital converter read 4095 when the pin is disconnected?
A disconnected GPIO pin configured as an ADC input acts as a high-impedance antenna. It picks up electromagnetic interference (EMI) from nearby switching power supplies, WiFi antennas, and mains wiring. Because the internal sample-and-hold capacitor has no discharge path, it charges up to the positive rail, resulting in a maximum reading of 4095. Always use a 10kΩ pull-down resistor to ground on high-impedance analog sensor lines to provide a stable baseline when the sensor is disconnected.
How do I improve the resolution of a 10-bit Arduino ADC analog to digital converter?
You can achieve 12-bit equivalent resolution on a 10-bit ADC through a technique called oversampling. By taking 16 rapid sequential readings of a stable DC signal, summing them, and dividing by 4 (right-shifting by 2 bits), you gain one extra bit of resolution. To gain two extra bits (12-bit total), you must sample 64 times and divide by 16. This only works for slow-moving DC signals; for AC waveforms, you must instead use an external 16-bit I2C ADC like the ADS1115, which costs about $4 to $8 on a breakout board and provides true hardware-level precision.
Can an ADC analog to digital converter measure negative voltages directly?
No. The internal ESD protection diodes on microcontroller GPIO pins will forward-bias if the voltage drops below -0.3V relative to ground, shunting current into the substrate and potentially destroying the silicon. The ADC will simply read 0 for any negative input. To measure negative voltages (like a bipolar audio signal or a shunt resistor reading bidirectional motor current), you must use an operational amplifier circuit to level-shift and scale the negative voltage into the 0V to V_ref positive window before it reaches the ADC pin.






