Working Principle
The ZMPT101B is a miniature voltage transformer (VT) that provides galvanic isolation between mains AC voltage and the MCU. The primary winding connects across the AC line (via a high-value resistor to limit current). The secondary winding produces a proportional low-voltage AC output centred around a DC bias (typically VCC/2 = 2.5 V), safe for ADC input.
Analogy: Imagine a pair of coupled tuning forks. Striking one (mains voltage) causes the other (secondary) to vibrate at the same frequency but at a much smaller amplitude. The transformer couples energy magnetically without any electrical contact.
Electrical Characteristics
| Parameter | Value |
|---|---|
| Input Voltage | Up to 250 V AC |
| Output | Analog AC waveform centred on VCC/2 |
| Turns Ratio | 1:1 (with external resistor for ratio scaling) |
| Isolation | Galvanic (primary-secondary) |
| Phase Shift | <0.2° at 50/60 Hz |
| Module Supply | 5 V DC |
| Current Draw | <10 mA |
Interfacing with an MCU
The ZMPT101B module has 4 pins: VCC (5 V), GND, signal (analog out), and a potentiometer to adjust output amplitude. The signal output is an AC waveform riding on a ~2.5 V DC offset — connect directly to an ADC pin.
Calibration
Calibration requires a reference multimeter:
- Adjust gain: Turn the module potentiometer until ADC peak-to-peak range is within 0–1023 without clipping.
- Find DC offset: With no AC input, read the ADC — this is your zero reference (should be ~512 on Arduino).
- Determine scale factor: Apply known voltage (e.g., 230 V), compute RMS from ADC samples, then:
calibration_factor = actual_Vrms / measured_Vrms.
Code Example
/*
* ZMPT101B AC Voltage RMS — Arduino
* Wiring: Signal→A0, VCC→5V, GND→GND
* WARNING: Primary connects to mains AC — observe safety
*/
#define SENSOR_PIN A0
#define SAMPLES 1000
#define VREF 5.0
#define ADC_MAX 1023.0
#define CAL_FACTOR 234.0 /* Calibrate with multimeter */
void setup() {
Serial.begin(9600);
Serial.println("ZMPT101B AC Voltage Sensor Ready");
}
float readVoltageRMS() {
long sumSq = 0;
int offset = 512; /* DC bias ≈ VCC/2 */
for (int i = 0; i < SAMPLES; i++) {
int raw = analogRead(SENSOR_PIN) - offset;
sumSq += (long)raw * raw;
delayMicroseconds(100); /* ~10 kHz sample rate */
}
float rmsADC = sqrt((float)sumSq / SAMPLES);
float voltage = (rmsADC / ADC_MAX) * VREF;
return voltage * CAL_FACTOR;
}
void loop() {
float vrms = readVoltageRMS();
Serial.print("AC Voltage: ");
Serial.print(vrms, 1);
Serial.println(" V RMS");
delay(2000);
}
Real-World Applications
Home Energy Monitoring
DIY energy monitors pair ZMPT101B (voltage) with ACS712 or SCT-013 (current) to compute real power consumption (P = V × I × cosφ). Data is logged to an ESP32-based dashboard or sent to Home Assistant, enabling homeowners to identify energy-hungry appliances and reduce electricity bills.
Limitations
- Mains safety: Improper installation can cause electric shock or fire — only qualified persons should wire mains connections.
- Frequency dependency: Optimised for 50/60 Hz; accuracy drops at higher frequencies (harmonics).
- ADC resolution: Arduino's 10-bit ADC limits precision to ~0.5% — use an external 12/16-bit ADC for energy metering.
- Temperature drift: The transformer and resistor divider introduce small gain changes with temperature.