Using a ZMPT101B to detect 120v AC live circuit

Hey there everyone,

I am simply trying to get a digital signal to my Mega256 Arduino board that will indicate whether or not a 120v AC circuit is live. I realize I can just use an AC relay, but I already have a couple ZMPT101B modules sitting around. So I am wondering if those can be used to detect if the circuit is on or not. Preferably using a digital signal.

Thanks!

The ZMTP101B AC Single Phase Voltage Sensor Module should be used for its design purpose. If you don't know what that is, have a look at the data sheet or product manual.

"lets get started"
That GreatScott have ruined a whole generation of YouTubers :grinning_face_with_smiling_eyes:

If somebody picks that thing up trying to adjust it like - things could get exciting.

Why? :sweat_smile:

You watched the vid? Nowadays every electronic Youtuber uses that phrase :upside_down_face: Not everyone but you know, a GreatScott deal of them!

what do you mean by circuit is on or not?
if you wish to detect if circuit is on and current is flowing a SCT-013 current clamp is worth considering - it is none invasive just clipping around ONE of the supply leads

there is also the pzem-004t-v3 voltage and current sensor which gives a digital output

unless you know what you are doing working with mains level voltages is dangerous
I tend to use an isolation transformer when working on such projects

With some additional circuits it's possible.

Why did you buy these, if you don't know what they are for or how to use them?

People buying stuff and having little or no idea how to use it is a regular occurrence here, a commonplace.

Here is the schematic for the ZMPT101B module:

The output is a sinewave with an offset of half the supply voltage. There is a potentiometer to adjust the sensitivity.

Here is some code that takes 50 analogRead( ) samples at 0.5ms intervals (to ensure that we are monitoring at least one whole period of the incoming 50 Hz or 60Hz input).
It finds the maximum and minimum values measured and subtracts the minimum from the maximum to calculate the amplitude.
The code then turns an output high if the amplitude is above a threshold.

code here


const byte inputPin = A0;
const byte outputPin = 12;
int input = 0;
int minInput = 1023;
int maxInput = 0;
int amplitude = 0;
int threshold = 100;


void setup() {
  Serial.begin(115200);
  pinMode(inputPin, INPUT);
  pinMode(outputPin, OUTPUT);
}

void loop() {

  minInput = 1023;
  maxInput = 0;

  for (int i = 0; i <= 50; i++) {
    input = analogRead(inputPin);

    if (input >= maxInput) {
      maxInput = input;
    }

    if (input <= minInput) {
      minInput = input;
    }

    delayMicroseconds(500);
  }

  amplitude = maxInput - minInput;

  if (amplitude >= threshold) {
    digitalWrite(outputPin, HIGH);
  }
  else {
    digitalWrite(outputPin, LOW);
  }

  Serial.print(minInput);
  Serial.print(", ");
  Serial.print(maxInput);
  Serial.print(", ");
  Serial.println(amplitude);

  // You can do something else here,
  // but it will slow down the response time.
  
}

I don't have a ZMPT101B module, so I have used a function generator to test the code:

  • Channel 1 - yellow trace - Burst of 50Hz signal, amplitude 4V pk-pk.
  • Channel 3 - blue trace - detected output.

I also printed the minimum value, maximum value and amplitude to the Serial Monitor:

I've left the data as the raw ADC values, but it could be converted into voltage if required.

Can you upload a schematic in higher resolution please?

Sorry, I don't have one.

That one came from another forum topic:
forum.arduino.cc/t/warning-about-zmpt101b-voltage-sensor-modules-with-active-output/693258, but edited to remove text from at the top.

The ZMPT101B is mainly used for measuring AC voltage rather than just detecting if a circuit is live. While it might work, using an AC relay or an optocoupler would be a simpler and more reliable way to get a clear digital signal for your Mega2560. Hope this helps!

testing the PZEM004Tv30 on a UNO running File>Examples>PZEM004Tv30>PZEMSoftwareSerial
sample serial monitor output using a heater as a load

Custom Address:1
Voltage: 247.30V
Current: 0.00A
Power: 0.00W
Energy: 0.023kWh
Frequency: 50.0Hz
PF: 0.00

Custom Address:1
Voltage: 247.70V
Current: 0.00A
Power: 0.00W
Energy: 0.023kWh
Frequency: 50.0Hz
PF: 0.00

Custom Address:1
Voltage: 247.80V
Current: 0.00A
Power: 0.00W
Energy: 0.023kWh
Frequency: 50.0Hz
PF: 0.00



Custom Address:1
Voltage: 209.60V
Current: 3.91A
Power: 819.10W
Energy: 0.027kWh
Frequency: 50.0Hz
PF: 1.00

Custom Address:1
Voltage: 209.70V
Current: 3.91A
Power: 819.30W
Energy: 0.028kWh
Frequency: 50.0Hz
PF: 1.00

Custom Address:1
Voltage: 183.20V
Current: 6.72A
Power: 1231.20W
Energy: 0.030kWh
Frequency: 50.0Hz
PF: 1.00

Custom Address:1
Voltage: 182.50V
Current: 6.69A
Power: 1221.50W
Energy: 0.031kWh
Frequency: 50.0Hz
PF: 1.00

Custom Address:1
Voltage: 181.90V
Current: 6.67A
Power: 1213.40W
Energy: 0.033kWh
Frequency: 50.0Hz
PF: 1.00

results compared to a multimeter and a clamp meter

  PZEMsensor          meter
voltage current  voltage current
  247     0        245     0
  209    3.92      210    3.83
  181    6.72      181    6.5

the voltage drop as the current increases is due to overloading the isolation transformer

test setup

the PZEM004Tv30 sensor is in an enclosure

on my PZEM004Tv30 the 10amp test circuit does not work
from PZEM-004T-V3.0-Datasheet-User-Manual

on the PCB there is a track between the L and N inputs

which shorts the mains input resulting in blown fuses

on the PCB there is a track between the L and N inputs
Maybe the wiring diagram didn't keep up with the board rev.
I guess UL (TUV, et al.) would not be favorably impressed - but it's not like anyone is asking them.

:rofl: :rofl: :rofl:

That's because you probably have the -100A version that uses a CT and not the -10A version that uses a shunt.

I bought them for another project a while back, I am completely aware of what they are intended to be used for. I just figured if they can sense the voltage level, maybe it was worth looking into if they can be used to sense when there is or is not voltage at all. Rather than buying a different module.