Zmpt101b Library For Proteus Online

Notes:

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. zmpt101b library for proteus

To visually confirm that the module is successfully dropping and shifting the voltage, select the tool (the graph icon on the left toolbar). Choose the OSCILLOSCOPE and place it on your workspace. Notes: const int sensorPin = A0; float sensitivity = 0

Download the ZMPT101B library zip file and extract it. Step 2: Copy the .LIB and .IDX files. Notes: const int sensorPin = A0