To convert a standard 230V RMS AC mains signal into a digital reading using a 16-bit analog to digital converter chip (like the Texas Instruments ADS1115) set to a ±4.096V programmable gain amplifier (PGA) range with a 100:1 resistive voltage divider, the peak digital output is 26,021 counts. The core conversion formula is: Digital Counts = (V_rms × 1.4142 / Divider_Ratio) × (2^15 / V_ref). Substituting our 230V values: (230 × 1.4142 / 100) × (32768 / 4.096) = 3.2527V × 8000 = 26,021.

The Assumptions That Fix Your ADC Counts

The numeric answer above is not a universal constant; it is locked in place by three specific hardware and physics assumptions. If any of these shift on your workbench, your counts will drift.

  • The PGA Reference Voltage: We assume the ADC's internal PGA is set to the ±4.096V full-scale range. This makes the least significant bit (LSB) equal to 0.125mV. If you drop to the ±2.048V range to gain resolution, your counts will double, but you risk clipping the peaks of a 230V signal.
  • The Divider Ratio: A strict 100:1 ratio (e.g., a 1MΩ high-side and 10kΩ low-side resistor) is assumed. In practice, you must use 1% tolerance metal film resistors; a 5% carbon film resistor can introduce a 10V error at the mains level.
  • The Pure Sine Wave: The multiplier 1.4142 (the square root of 2) assumes a perfect sinusoidal waveform. If you are measuring the output of a cheap modified-sine-wave inverter or a grid with high Total Harmonic Distortion (THD), the peak voltage will not be exactly 1.4142 times the RMS voltage, rendering peak-count calculations inaccurate without true-RMS sampling.

Voltage Scaling: 120V vs 230V vs 3-Phase Systems

The math shifts dramatically depending on your regional grid and phase configuration. A 120V North American split-phase system yields a peak ADC input of 1.697V, resulting in roughly 13,554 counts—leaving over half of the 16-bit resolution unused if your PGA is set to ±4.096V. For 120V systems, you should switch the PGA to ±2.048V to maximize resolution.

For 3-phase systems, the shift is more complex. Line-to-neutral remains 230V (26,021 counts), but line-to-line voltage is 400V. A 100:1 divider would push 5.65V into the ADC, frying the input or hard-clipping the reading. You must scale the divider to 150:1 for line-to-line 3-phase measurements.

Neighboring Values: 230V Nominal ±20% Range (100:1 Divider, ±4.096V PGA)
Mains Voltage (RMS) Peak Voltage (V) ADC Input (V) 16-Bit Digital Counts
184V (-20% Brownout) 260.2 2.602 20,816
207V (-10% Sag) 292.7 2.927 23,416
230V (Nominal) 325.3 3.253 26,021
253V (+10% Surge) 357.8 3.578 28,624
276V (+20% Fault) 390.3 3.903 31,224

When the Conversion Becomes Meaningless (The Power Factor Trap)

If your end goal is to measure Apparent Power (VA), multiplying your RMS voltage counts by your RMS current counts works perfectly. However, when calculating Real Power (Watts), the conversion is meaningless if the Power Factor (PF) is unknown.

Bench Warning: Real Power is calculated as P = V × I × cos(θ). If you use a basic single-channel ADC to measure voltage, then switch a multiplexer to measure current, you introduce a time delay. This phase shift destroys your cos(θ) calculation. To measure Watts, your analog to digital converter chip must sample voltage and current simultaneously.

Without simultaneous sampling and phase-angle tracking, you cannot determine if a 10A load is a resistive heater (PF=1.0, 2300W) or an inductive motor (PF=0.6, 1380W). The raw ADC counts for current will look identical, but the real-world energy consumption is vastly different.

Decision Tree: Picking the Right Analog to Digital Converter Chip

Do not default to the microcontroller's internal ADC. The ESP32's internal 12-bit ADC is notoriously non-linear and lacks the safety isolation required for mains monitoring. Use this decision path to select the correct external silicon.

Application Scenario Required Hardware Feature Concrete Part Pick
Measuring slow DC buses (solar/battery) or single AC voltage only I2C interface, 16-bit resolution, 860 SPS max Texas Instruments ADS1115
Measuring single-phase AC Real Power (Watts) and energy (kWh) Synchronous 2-channel sampling, SPI interface, hardware multiplier Microchip MCP3909
Measuring 3-phase AC power, harmonics, and power factor 3V/3I simultaneous pairs, dedicated DSP engine, zero-crossing detection Analog Devices ADE7953

Frequently Asked Questions

Do I need an anti-aliasing filter before the ADC?

Yes. According to the Nyquist-Shannon sampling theorem, any noise or high-frequency switching ripple above half your ADC's sampling rate will fold back into your measurement as false low-frequency data. For an ADS1115 sampling at 860 SPS, place a simple RC low-pass filter (e.g., 1kΩ resistor and 100nF capacitor) on the ADC input to create a cutoff frequency around 1.6kHz.

How do I protect the ADC from mains voltage spikes?

A resistive divider alone will not survive a lightning-induced transient or a 400V line-to-line fault. You must place a bidirectional TVS (Transient Voltage Suppression) diode, rated for 5V, directly across the ADC input pins to clamp any voltage exceeding the PGA's absolute maximum ratings. Additionally, use high-voltage rated resistors (or a series chain of three 333kΩ resistors instead of one 1MΩ) for the high-side divider to prevent internal arcing.

For exact register configurations and timing diagrams, always defer to the manufacturer's latest datasheets, such as the TI ADS1115 Datasheet or the Analog Devices ADE7953 Reference.