Zmpt101b Library For Proteus Access

#define SENSOR_PIN A0 const float FACTOR = 0.425; // Calibration coefficient (adjust in simulation) const float V_OFFSET = 2.5; // Onboard op-amp shifts the wave by 2.5V void setup() Serial.begin(9600); pinMode(SENSOR_PIN, INPUT); void loop() float voltageSum = 0; long sampleCount = 0; unsigned long startTime = millis(); // Sample the AC wave for exactly 20ms (one full 50Hz cycle) while ((millis() - startTime) < 20) int rawValue = analogRead(SENSOR_PIN); // Convert raw ADC steps back to voltage (0-5V range) float sampleVoltage = (rawValue * 5.0) / 1023.0; // Remove the 2.5V DC offset to isolate the pure AC wave float pureACSample = sampleVoltage - V_OFFSET; // Square the value for RMS calculation voltageSum += (pureACSample * pureACSample); sampleCount++; // Calculate Root Mean Square (RMS) float meanSquare = voltageSum / sampleCount; float rmsVoltageOutput = sqrt(meanSquare); // Scale the output to match the original mains high voltage float finalCalculatedMainsVoltage = rmsVoltageOutput * FACTOR * 100; Serial.print("Measured AC Voltage (RMS): "); Serial.print(finalCalculatedMainsVoltage); Serial.println(" V"); delay(500); Use code with caution. Compiling and Loading Code into Proteus

Simulating this workflow in Proteus provides several key benefits:

Connect the and N (Neutral) terminals of the Proteus ALTERNATOR to the input pins of the ZMPT101B module. zmpt101b library for proteus

Look for trusted electronics community repositories (such as GitHub, Engineering Projects, or institutional forums) hosting the ZMPT101B library. Ensure the package contains two essential file types: .IDX (Index file) .LIB (Library file)

Remember these key takeaways:

The model outputs a scaled AC waveform centered around 2.5V (for single-supply operation). You’ll need to sample it and compute RMS in your firmware.

(or your preferred microcontroller simulation model) VIRTUAL TERMINAL (to display serial monitor data) #define SENSOR_PIN A0 const float FACTOR = 0

Here’s a review of the , based on common user experiences and technical considerations:

The sensor operates on a straightforward principle: a built-in voltage transformer steps down the AC input voltage, and a voltage divider circuit further reduces it to a safe, proportional output voltage (usually 0–5V or 0–3.3V) that can be read by a microcontroller's analog-to-digital converter (ADC). This output is directly proportional to the input AC voltage, allowing for accurate measurements. You’ll need to sample it and compute RMS in your firmware

Example pseudocode (concise):

Navigate to the folder in the same Proteus directory.