ESP32 with ZMPT101B Voltage Sensor: AC Voltage Measurement Guide
Introduction
Measuring AC voltage safely and accurately is essential for IoT, home automation, energy monitoring, and smart power management systems. The ESP32, combined with the ZMPT101B AC Voltage Sensor, provides a reliable and cost-effective solution for monitoring mains voltage in real time.
In this blog, we’ll explore how the ESP32 works with the ZMPT101B voltage sensor, its working principle, wiring connections, advantages, and practical applications.
What is ZMPT101B Voltage Sensor?
The ZMPT101B is a high-precision AC voltage sensor module based on a voltage transformer. It is designed to measure single-phase AC voltage while providing electrical isolation between high-voltage and low-voltage circuits.
Key Features
- Measures AC voltage up to 250V
- High accuracy and good linearity
- On-board adjustable potentiometer
- Electrical isolation for safety
- Analog output compatible with microcontrollers
Why Use ESP32 with ZMPT101B?
The ESP32 is a powerful microcontroller with built-in Wi-Fi and Bluetooth, making it ideal for IoT-based voltage monitoring systems.
Advantages of ESP32
- Dual-core processor
- High-resolution ADC
- Low power consumption
- Wi-Fi & Bluetooth connectivity
- Suitable for real-time cloud monitoring
Combining ESP32 with ZMPT101B enables safe, wireless, and real-time AC voltage measurement.
Working Principle
The ZMPT101B uses a miniature voltage transformer to step down high AC voltage to a safe, low-level signal. This signal is then processed through an onboard operational amplifier.
- AC mains voltage is applied to the sensor input
- Voltage transformer isolates and scales down the voltage
- Analog output is sent to ESP32 ADC pin
- ESP32 processes and converts analog data into RMS voltage
ESP32 and ZMPT101B Pin Connections
ZMPT101B Pins
- VCC → 3.3V or 5V
- GND → Ground
- OUT → ESP32 ADC pin (GPIO 34, 35, or 32 recommended)
Example Connection
| ZMPT101B | ESP32 |
|---|---|
| VCC | 3.3V |
| GND | GND |
| OUT | GPIO 34 |
⚠️ Safety Note: Always use proper insulation and precautions when dealing with AC mains voltage.
ESP32 ADC Reading & Voltage Calculation
The ESP32 reads the analog signal from ZMPT101B using its ADC. Since AC voltage fluctuates, multiple samples are taken to calculate the RMS (Root Mean Square) voltage, which represents the actual usable voltage.
Key Steps
- Read analog samples
- Find peak-to-peak value
- Convert ADC values to voltage
- Calculate RMS voltage
- Calibration is crucial for accurate voltage measurement.
Calibration Steps
- Apply a known AC voltage (e.g., 230V)
- Adjust the onboard potentiometer
- Compare readings with a multimeter
- Fine-tune in software if required
Proper calibration ensures high accuracy and stability.
Applications
The ESP32 + ZMPT101B combination is widely used in:
- Smart energy meters
- Home automation systems
- Power monitoring dashboards
- IoT-based electricity monitoring
- Over/under voltage protection systems
- Industrial power analysis
Advantages of This Setup
- Safe electrical isolation
- Low-cost solution
- Wireless monitoring via Wi-Fi
- High accuracy after calibration
- Compact and scalable design
Limitations
- Measures only AC voltage (not current)
- Needs calibration for precise readings
- ESP32 ADC can be noisy (software filtering recommended)
Conclusion
Using the ESP32 with ZMPT101B Voltage Sensor is an excellent approach for building smart AC voltage monitoring systems. The combination offers safety, accuracy, and IoT capabilities, making it ideal for both hobbyists and industrial projects.
With proper calibration and signal processing, this setup can be transformed into a professional-grade energy monitoring solution.
HOW TO OPERATE WITH ESP32
/**
* This program shows you how to use the basics of this library.
*/
#include <ZMPT101B.h>
#define SENSITIVITY 500.0f
// ZMPT101B sensor output connected to analog pin A0
// and the voltage source frequency is 50 Hz.
ZMPT101B voltageSensor(34, 50.0);
void setup() {
Serial.begin(115200);
// Change the sensitivity value based on value you got from the calibrate
// example.
voltageSensor.setSensitivity(SENSITIVITY);
}
void loop() {
// read the voltage and then print via Serial.
float voltage = voltageSensor.getRmsVoltage();
Serial.println(voltage);
delay(1000);
}


Leave a Reply
You must be logged in to post a comment.