Hello,
I have a problem regarding the measurement of the 220VAC with ZMPT101B sensor from China, which has an operating level of 5V or more. I connected an external power supply of 12V to power this sensor.
The power supply has L, N, GND, -V, +V. I connected the L, N, GND to 220VAC.
-V of power supply -> GND of ZMPT101B
+V of power supply -> VCC of ZMPT101B
Between these 2 points I have 12V.
Now the ZMPT101B has 2 more pins: OUT and 1 more GND.
The OUT pin connects to A2 of ADS1115.
However, I am not sure whether the GND of the ZMPT101B should be connected to A3 of ADS1115 in order to measure in differential mode ads.readADC_Differential_2_3() for accurate measurement of the 220V or if it should be connected to common GND of ADS1115 and Arduino's (Arduino MKR) and do a single ended point measurement relative to the GND of the ADS1115 as in ads.readADC_SingleEnded(2).
Should I measure and calculate and do the things in the same manner for Voltage as I do for Current or not? Given the fact that the Voltage should output (graphically) a sinusoidal function, should I use some Min and Max values for Voltage and calculate the RMS from there on?
My code is the following:
#include <Wire.h>
#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 ads;
const float FACTOR = 30; //30A/1V from teh CT
const float multiplier = 0.00003125;
void setup() {
Serial.begin(9600);
ads.setGain(GAIN_FOUR); // +/- 1.024V 1bit = 0.5mV
ads.begin();
}
void printMeasure(String prefix, float value, String postfix)
{
Serial.print(prefix);
Serial.print(value, 3);
Serial.println(postfix);
}
void loop() {
float currentRMS = getcurrent();
float voltageRMS = getvoltage();
printMeasure("Irms: ", currentRMS, "A");
printMeasure("Vrms: ", voltageRMS, "V");
delay(1000);
}
float getcurrent()
{
float voltage;
float current;
float sum = 0;
long time_check = millis();
int counter = 0;
while (millis() - time_check < 1000)
{
voltage = ads.readADC_Differential_0_1() * multiplier;
current = voltage * FACTOR;
sum += sq(current);
counter = counter + 1;
}
current = sqrt(sum / counter);
return (current);
}
float getvoltage() // question-related function
{
float voltage;
float sum = 0;
long time_check = millis();
int counter = 0;
while (millis() - time_check < 1000) {
voltage = ads.readADC_Differential_2_3() * multiplier; // question-related line of code
sum += sq(voltage);
counter++;
}
voltage = sqrt(sum / counter);
return voltage;
}
Thank you for your time!

