When monitoring standard 120V AC mains with a 12-bit ADC (like the ESP32's internal converter) referenced to 3.3V and using a 100:1 step-down voltage divider, the peak AC waveform converts to exactly 2098 bits (out of a maximum 4095). The core formula used is Bits = (V_peak / V_ref) × (2^n - 1). Substituting the real-world values for a 120V RMS sine wave: (1.697V / 3.3V) × 4095 = 2098. This is your baseline digital value for nominal North American mains voltage before any software RMS averaging is applied.

The Core Formula and Fixed Assumptions

An Analog-to-Digital Converter (ADC) doesn't read "120V". It reads instantaneous voltage at a specific microsecond. To convert AC mains into digital bits, we must bridge the gap between AC RMS (Root Mean Square) and DC logic levels. The math relies on three fixed assumptions:

  1. Pure Sine Wave: We assume V_peak = V_rms × √2. For 120V RMS, the peak is 169.7V.
  2. Voltage Divider Ratio: A 100:1 resistor divider (e.g., 1MΩ series, 10kΩ shunt) steps 169.7V down to a safe 1.697V.
  3. ADC Resolution and Reference: A 12-bit ADC yields 4096 discrete steps (0 to 4095). We assume a strict 3.3V reference voltage (V_ref).
Bench Warning: The internal ADC on the ESP32 is notoriously non-linear near 0V and above 3.1V. If your calculated peak bits exceed 3800, your readings will compress and distort. Always design your voltage divider to keep the peak signal in the 1.5V–2.5V sweet spot.

Voltage Fluctuation Matrix (±20% Range)

Mains voltage is rarely exactly 120V. Utility tolerances and heavy neighborhood loads cause constant fluctuation. Here is how the bits converter math shifts across a ±20% range of nominal 120V, assuming the same 100:1 divider and 12-bit/3.3V architecture.

Mains RMS Variance Peak Voltage Scaled to ADC (100:1) Digital Bits (12-bit)
96V -20% 135.8V 1.358V 1681
108V -10% 152.7V 1.527V 1891
120V Nominal 169.7V 1.697V 2098
132V +10% 186.7V 1.867V 2311
144V +20% 203.6V 2.036V 2521

How the Conversion Shifts: 120V vs 230V vs 3-Phase

The 2098-bit answer is strictly bound to 120V single-phase systems. Change the geography or the phase count, and the hardware requirements shift dramatically.

230V Single-Phase (EU/UK/AU)

At 230V RMS, the peak voltage is 325.3V. If you reuse the 100:1 divider, the ADC sees 3.25V. This leaves only 0.05V of headroom before hitting the 3.3V rail. A minor utility transient will clip the waveform, flattening the peaks and causing your software to under-report the RMS voltage. The fix: Shift to a 150:1 divider (e.g., 1.5MΩ / 10kΩ), bringing the peak down to a safe 2.16V (approx. 2680 bits).

3-Phase Systems (208V / 480V)

In 3-phase monitoring, you aren't just measuring voltage magnitude; you are measuring the phase angle between Line A, Line B, and Line C to calculate real power. The ESP32's internal ADC uses a multiplexer—it switches between pins sequentially. This introduces a microsecond delay between phase readings, artificially skewing the phase angle and ruining Power Factor (PF) calculations. The fix: You must use an external ADC with simultaneous sampling or a dedicated energy monitoring IC.

When the Conversion is Meaningless

Converting voltage to bits becomes mathematically meaningless for power calculations if the Power Factor (PF) is unknown or if Total Harmonic Distortion (THD) is high. If you are measuring the output of a cheap modified-sine-wave inverter, the V_peak = V_rms × √2 assumption collapses. The waveform is square or stepped, not sinusoidal. In these cases, hardware true-RMS converters (like the LTC1966) are required before the signal ever hits your digital ADC.

Hardware Decision Tree: Which ADC to Buy

Stop guessing which breakout board to wire to your microcontroller. Follow this decision path to select the exact silicon for your AC monitoring project.

System Target Accuracy Need Hardware Pick Why?
120V Single Phase ±5% (Basic Logging) ESP32 Internal 12-bit ADC Free, built-in, sufficient for detecting brownouts or basic on/off states.
230V Single Phase ±1% (Energy Metering) Texas Instruments ADS1115 16-bit resolution, I2C interface, internal PGA, and highly linear across the full rail.
3-Phase (Any Voltage) ±0.1% (Revenue Grade) Microchip ATM90E32 or ADE7758 Dedicated energy ICs with built-in DSP, simultaneous 3-phase sampling, and hardware PF calculation.
The Concrete Pick: For 90% of advanced DIY AC mains monitors, solar inverters, and smart home energy dashboards, buy the ADS1115 breakout board. At roughly $4 to $6 per module, its 16-bit resolution (yielding up to 65,535 bits) provides the granular headroom needed to accurately capture 230V peaks and minor 120V sags without clipping.

Frequently Asked Questions

Do I need to account for the diode bridge voltage drop?

If you are using a simple AC-to-DC step-down transformer followed by a bridge rectifier to feed a DC ADC pin, yes. A standard silicon bridge drops about 1.4V (two diode junctions). If your scaled peak is 2.0V, the ADC will only see 0.6V, completely wrecking your math. Instead of a rectifier, use a differential op-amp circuit to shift the AC waveform into a 1.65V DC bias, allowing the ADC to read both the positive and negative halves of the AC sine wave.

Why does my software RMS calculation read 10% low?

If your peak bit values are correct but your software-derived RMS is low, check your sampling rate. To accurately reconstruct a 60Hz sine wave and calculate true RMS, Nyquist theorem dictates you need more than just 2 samples per cycle. Aim for a minimum of 1,000 samples per second (approx. 16 samples per 60Hz cycle) to ensure your microcontroller captures the exact peak before the waveform slopes back down.

Can I use a ZMPT101B voltage sensor module?

You can, but be aware of its flaws. The cheap ZMPT101B modules found on Amazon usually feature an outdated LM358 op-amp that struggles to slew fast enough for accurate 60Hz peak tracking, and the trimpot used for calibration is highly sensitive to temperature drift. For reliable, long-term bench or panel installations, build your own precision divider using 0.1% tolerance metal film resistors and feed it directly to an ADS1115.