Component guide · Intermediate · 3 min read
ZMPT101B AC voltage sensor

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The ZMPT101B module measures AC mains voltage through a small isolating transformer and outputs a safe AC signal centred on half the supply voltage. Your code samples that signal, removes the offset and calculates RMS volts. Calibrate it against a multimeter using the trimmer. The mains side must be fully enclosed and wired by someone qualified.
Key specs at a glance
- Input
- AC up to about 250 V (mains)
- Isolation
- ZMPT101B precision voltage transformer, 4 kV isolation
- Output
- AC signal centred on VCC/2
- Supply
- 5 V (3.3 V on some boards with reduced range)
- Adjustment
- Trimmer for output gain
- Frequency
- 50 or 60 Hz
This part is often wired to 230 V mains. Do all wiring with the plug pulled out, keep mains wires inside a closed box with strain relief, add a fuse, and never touch the board while it is plugged in. If you are new to mains wiring, have an electrician check it before you switch on.
What the ZMPT101B AC voltage sensor is
The ZMPT101B is a tiny precision transformer. On the module, mains voltage drives it through a resistor, and an op-amp turns its output into a scaled AC waveform sitting on a DC offset so the ADC can read both halves.
With an ACS712 or a split-core CT for current, it forms the basis of a DIY energy monitor. For a ready-made, safer option, see PZEM energy meters.
ZMPT101B AC voltage sensor pinout
The pins on the ZMPT101B AC voltage sensor and what each one does.
| Pin | Function |
|---|---|
| VCC | 5 V |
| GND | Ground |
| OUT | Analog output (AC around VCC/2) |
| L / N terminals | Mains input (live and neutral), high voltage |
- VCC
- 5 V
- GND
- Ground
- OUT
- Analog output (AC around VCC/2)
- L / N terminals
- Mains input (live and neutral), high voltage
Wiring the ZMPT101B AC voltage sensor
Disconnect mains before touching any wire. Fuse the live input, use an enclosure and keep low-voltage wiring away from the screw terminals. Scale OUT for a 3.3 V ADC.
| ZMPT101B AC voltage sensor pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5V | 5V (VIN) |
| GND | GND | GND |
| OUT | A0 | GPIO 34 via 10k/20k divider |
| L / N | Mains (enclosed, fused) | Mains (enclosed, fused) |
- VCC
- Arduino Uno:
- 5V
- ESP32:
- 5V (VIN)
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- OUT
- Arduino Uno:
- A0
- ESP32:
- GPIO 34 via 10k/20k divider
- L / N
- Arduino Uno:
- Mains (enclosed, fused)
- ESP32:
- Mains (enclosed, fused)
Example code
The calibration factor depends on your trimmer setting. The EmonLib library offers a ready-made voltage and power calculation.
const int PIN = A0;
const float CAL = 0.75; // adjust until the result matches a multimeter
void setup() { Serial.begin(115200); }
void loop() {
const int N = 1000; // about 0.12 s, or 6 cycles at 50 Hz, on an Uno
long sum = 0; static float offset = 512;
double sq = 0;
for (int i = 0; i < N; i++) {
int v = analogRead(PIN);
sum += v;
double d = v - offset;
sq += d * d;
}
offset = sum / (float)N; // track the DC centre
float vrms = sqrt(sq / N) * CAL;
Serial.print(vrms, 1); Serial.println(" V AC");
delay(500);
}Setup and tuning
set the trimmer so the waveform does not clip (check with Serial Plotter), then change CAL until the reading matches a true-RMS multimeter.
cover whole cycles (20 ms per cycle at 50 Hz).
the transformer isolates the output, but the input side and terminals are at mains voltage.
combine with a current sensor sampled at the same time to calculate real power.
What you need
Shop this list5 of 5 found in our store · ₹804
ZMPT101B AC voltage sensor module: the sensor this guide coversZMPT101B AC Voltage Sensor Module₹120
ACS712 Hall-effect current sensor module: to add current measurementACS712 Hall-Effect Current Sensor Module₹69
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
Digital multimeter: to calibrate againstDigital Multimeter₹177
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- PZEM energy meters: calibrated voltage, current, power and energy in one module.
- Voltage sensor modules: for DC voltages.
- ACS712: AC or DC current.
Try it: Ac power factor calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Working on the module while mains is connected.
- No fuse or enclosure on the mains side.
- Feeding the 5 V output straight into an ESP32 pin.
- Sampling less than a full cycle and getting unstable RMS.
Frequently asked questions
Is the ZMPT101B safe?
The output is isolated, but the input terminals carry mains voltage. Enclose it, fuse it and have mains wiring done by a qualified person.
Can it measure DC voltage?
No. It is a transformer and only works with AC.
How do I calibrate it?
Measure mains with a true-RMS multimeter and adjust the trimmer and code factor until they match.
Does it work with ESP32?
Yes, with the output scaled to 3.3 V, and the ESP32's ADC benefits from averaging.
Can I measure power with it?
Yes, combined with a current sensor sampled at the same time; EmonLib does the maths.
What range can it read?
Up to about 250 V AC on standard modules.
Parts for this guide
Calculators
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.
