To simulate real-world AC voltage sensing, you must build a complete test bench around the ZMPT101B component block in Proteus. 1. The High-Voltage AC Source
// Arduino code for ZMPT101B AC Voltage Simulation Testing const int sensorPin = A0; const float vPeakToPeakTarget = 5.0; // Expected peak-to-peak output swing const float gridVoltageTarget = 220.0; // Target grid baseline void setup() Serial.begin(9600); void loop() int maxValue = 0; int minValue = 1023; unsigned long startTime = millis(); // Sample for 50ms to capture at least 2-3 full 50Hz waves while (millis() - startTime < 50) int readValue = analogRead(sensorPin); if (readValue > maxValue) maxValue = readValue; if (readValue < minValue) minValue = readValue; // Calculate voltage metrics based on ADC steps (0-1023) float voltagePeakToPeak = ((maxValue - minValue) * 5.0) / 1023.0; // Basic scaling factor calculation based on simulation calibration float calibrationFactor = gridVoltageTarget / vPeakToPeakTarget; float rmsVoltage = (voltagePeakToPeak / 2.0) * 0.707 * calibrationFactor; Serial.print("Vpp Signal: "); Serial.print(voltagePeakToPeak); Serial.print("V Use code with caution. Running the Simulation
This proves that the simulation model is functioning correctly, accurately protecting the simulated downstream microcontroller from negative voltages and overvoltage damage. Troubleshooting Common Issues
any accompanying .HEX or .MDF simulation engine model files. zmpt101b library for proteus
You can use standard ZMPT101B Arduino libraries (like the one by TrueRMS or EmonLib) or use a raw analog sampling loop like the example below:
Click the folder icon next to the field, select your exported .hex file, and click OK.
Press the button on the keyboard (or click the 'P' icon next to the Devices list) to open the Pick Devices window. In the keywords search bar, type ZMPT101B . To simulate real-world AC voltage sensing, you must
To simulate a poorly calibrated module, you can set GAIN too high, causing the output to clip at 5V or 0V — exactly what happens in real hardware if the pot is misadjusted.
To see results in your simulation, you must upload a hex file to your simulated Arduino. The code must read the analog pin, find the peak-to-peak voltage, calculate the Root Mean Square (RMS) voltage, and convert it back to the corresponding high-voltage value. Sample Arduino Simulation Code
Comprehensive Guide: ZMPT101B Library for Proteus Simulation Troubleshooting Common Issues any accompanying
ZMPT101B library for Proteus a specialized simulation model used by engineers and hobbyists to test AC voltage monitoring circuits
The ZMPT101B library for Proteus offers several features that make it an essential tool for engineers and designers:
Open the window. You should see a standard sine wave on Channel B hovering entirely above 0V (centered on 2.5V).
const int sensorPin = A0; float sensitivity = 0.025; // Calibrate this value based on your simulation response float vRMS = 0; float vPP = 0; void setup() Serial.begin(9600); pinMode(sensorPin, INPUT); void loop() int maxValue = 0; int minValue = 1023; unsigned long startTime = millis(); // Sample the signal for 20ms (one full 50Hz cycle) while((millis() - startTime) < 20) int readValue = analogRead(sensorPin); if (readValue > maxValue) maxValue = readValue; if (readValue < minValue) minValue = readValue; // Calculate Peak-to-Peak Voltage vPP = ((maxValue - minValue) * 5.0) / 1023.0; // Calculate RMS Voltage based on sensor calibration vRMS = (vPP / 2.0) * 0.707 * (1.0 / sensitivity); Serial.print("Measured AC Voltage: "); Serial.print(vRMS); Serial.println(" V"); delay(500); Use code with caution. Compiling and Simulating Compile the code in the Arduino IDE.