ZMPT101B, powerfactor and current shown

@xekon I measured the phase angle between mains (250vac at the lab) and the output of the module powered by a cleanish 5V.
Yes, I used a 2ch scope. The 1000V rated high impedance inputs don’t cause too much added phase shift. If your scope can’t take the voltage, a resistor divider is fine enough to bring it down, just gotta be careful with that there live wire.
It’s an Okay scope I had access to, it automatically found the phase shift and gave me a value in microseconds of the shift, which I converted into radians (and then degrees) according to the frequency, which was 49.8Hz, or something thereabouts. phase angle in degrees is… (time delay/period)*360 … might need correcting there.
Interested to know if you get similar results or manage to get a clean signal from the voltage transformer without the smoothing (so the flat tops are visible), without the opamp! But it does sound like you need a better scope with more resolution.

At the moment my conclusion, similar to Robert’s but for different reasons it seems, is that the modules are useful as amplitude and frequency measurement devices, but not for super-accurate monitoring.

This discussion has got me thinking about another test to make on the transformer component, sans module, might have another go at it.

Well, my take on mains voltage… mains voltage is nasty, but not too nasty. If it were, it wouldn’t be in the walls of our houses. I’ve had a few shocks, not that bad. An experienced sparky said to me he used to test wires with his thumb nail. Could’ve been taking me for a ride. But I duly took it on board regardless, and after flipping a breaker for electrical work, I test wires (including neutral and earth) with my thumb nail before handling it properly, after all, better safe than sorry.
I jest, a little.
But get this. You might know, in the EU, the standard socket outlet is 230Vac and there is NOTHING stopping a child from sticking a metal skewer into that live connection. THAT is dangerous. At least in the UK we have the plastic gate-things which require an earth pin to be inserted for the live to be revealed and accessible.

Interestingly perhaps, I was going to say that since you’ve done your own wiring (first time?) you might want to get a professional to take a look. I wasn’t going to say this at first, didn’t want to patronise you. I’ve had the fortune of being shown how to do house wiring and take it for granted now, despite it not being my profession per se, really glad someone showed me.
And I read now… electrical fires cause many more deaths than electrical shocks. I don’t mean to minimise the deaths that do occur because of shock either.

If we’re going to talk safety, we might as well get our priorities straight innit.

For @xekon’s benefit, the standard UK plug looks like this.

Just to pick up on that point, that’s one way it’s done. The other way is a rotating shutter that needs both line and neutral pins to be inserted together to unlock and rotate it to allow the pins to enter and make contact.

And when @TrystanLea reads this: The plastic “socket protector” that looks like a very flat BS1363 plug, that’s sold to put in sockets to prevent children poking things in actually make the socket MORE dangerous than without it, because children have been known to pull it out, rotate through 180° and use it to open the shutter. :exploding_head:   :roll_eyes:

But we’re OT here.

We are. But I have to say, David Peacock was a bit of a dude. Good on him.
And that child in the video is remarkably adept at pulling those covers off, and that parent is rather relaxed about it. If I was looking after a kid I’d scare the shit out of them with a loud noise any time they put their hand on a socket. Pavlovian style.

I would be inclined to use covers anywhere else apart from the UK though. The saving grace of the EU socket be a very snug fit for a cover.

@xekon Op.Amps are very interesting right?
Continually hunting to balance the + and -.
The video’s okay but could be clearer at the outset about the IDEAL op amp. I read there were 6 characteristics of the ideal op.amp. That’s worth a look.

This is the sketch:

// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h"             // Include Emon Library
EnergyMonitor emon1;             // Create an instance
String mystring = "";

void setup()
{  
  Serial.begin(9600);
  analogReadResolution(ADC_BITS);
  
  //emon1.voltage(0, 330.1, 1.7);  // Calibration for ZMPT101B Voltage: input pin, calibration, phase_shift
  emon1.voltage(0, 19800, 1.7);  // Calibration for AC-AC Adapter Voltage: input pin, calibration, phase_shift
  emon1.current(1, 103.1);       // Current: input pin, calibration.
}

void loop()
{
  emon1.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  //emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
  
  float realPower       = emon1.realPower;        //extract Real Power into variable
  float apparentPower   = emon1.apparentPower;    //extract Apparent Power into variable
  float powerFActor     = emon1.powerFactor;      //extract Power Factor into Variable
  float supplyVoltage   = emon1.Vrms;             //extract Vrms into Variable
  float Irms            = emon1.Irms;             //extract Irms into Variable (currentDraw)

  //mystring = "V:" + String(supplyVoltage) + " PF:" + String(powerFActor);
  mystring = String(supplyVoltage);
  Serial.println(mystring);
  delay(300);
}

I think I figured it out. The AC-AC adapter I was using was not giving a proper sine wave or voltage when checked with the DSO150. I previously spliced a 3.5mm stereo connector as the end of the plug for the AC-AC adapter, because I had plenty of stereo jacks for the shield I made. however the size of the wire on the 3.5mm stereo connector that I spliced on is so small that it was messing up the signal from the AC-AC adapter. removing the stereo connector from the plug and checking the wires directly provided a nice clean sine wave. I am about to hook this power adapter up to the arduino shield without the stereo jack and see how it goes.

it is working now with my AC-AC adapter :slight_smile: YAY! The voltage is more accurate with this AC-AC adapter than it was with the ZMPT101B, with the ZMPT101B I was seeing +/- 1 volt. With the AC-AC adapter I am seeing +/- 0.1 volt.

I still plan to modify the ZMPT101B removing the op.amps to see what it does for it, however I now have a working system, about to do the rest of the calibration and make sure current and powerfactor all look right.

Yes, I found it very interesting indeed!

Now that I am working with the AC-AC adapter and trying to dial in the calibration with it, I have made a new thread (Arduino Due Calibrating Voltage sense +/- 0.1 at first, now +/- 0.3 what does it mean?) instead of continuing to post to this one.

I will come back here later when I play with the ZMPT101B some more.

1 Like

I am currently researching how this is done. I have like 10 spare sound cards sitting in a box.

Edit: I was reading earlier about sound card oscilloscopes and plan to give that a try. I know your not supposed to use a voltage divider for AC Mains directly with emon/arduino because it can be dangerous, but if your careful maybe its less dangerous for a temporary test with the sound card. What type of circuit did you use to interface your AC Mains with your sound card? (most of the circuits i see online are voltage dividers with diodes.)

edit2: I figured I would start off using the older/cheaper sound cards just incase i do happen to make a mistake and fry the card.

I am assuming your talking about adjusting your voltage divider so that the two voltages are equal.

Very carefully, bearing in mind sound cards only expect around 1V maximum input.

I use Soundcard Oscilloscope from Soundcard Scope

The spreadsheet is not that difficult, it’s mainly the same formula then copied 881 more times.
So rather than attaching the spreadsheet, here it is as instructions to type up (44.1 kHz sampling over 20 ms assumed - you need to change that to 16.666 ms):

(‘R’ = row)

Col A:
R2: “Time [sec]”
R3 - R884: the recorded time values.

Col B:
R2: “Amplitude”
R3 - R884: the recorded sample values for channel A.

Col C:
R2: “Amplitude”
R3 - R884: the recorded sample values for channel B.

Col E:
R2: “Sample”
R3 - R884: sample number starting at zero

Col F:
R1:“Output”
R2: “sin”
R3 - R884: Formula “=$C3SIN($N$3$E3)”

Col G:
R2: “cos”
R3 - R884: Formula “=$C3COS($N$3$E3)”

Col I:
R1:“Input”
R2: “sin”
R3 - R884: Formula “=$B3SIN($N$3$E3)”

Col J:
R2: “cos”
R3 - R884: Formula “=$B3COS($N$3$E3)”

Col L:
R2: “Harmonic”
R3: “step”
R5: “Output”
R6: “sum sin”
R7: “sum cos”
R8: “angle”
R9: “phase”
R10: “amplitude”

R13: “Input”
R14: “sum sin”
R15: “sum cos”
R16: “angle”
R17: “phase”
R18: “amplitude”

R21: “Result”

Col N:
R2: the harmonic number you’re analysing (usually 1)
R3: formula “=-$N$22PI()/882”
R6: formula “=SUM(F3:F884)”
R7: formula “=SUM(G3:G884)”
R8: formula “=ATAN2($N$6,$N$7)”
R9: formula “=DEGREES($N$8)”
R10: formula “=SQRT(N6N6+N7N7)/441”
R14: formula “=SUM(I3:I884)”
R15: formula "=SUM(J3:J884)!
R16: formula “=ATAN2($N$14,$N$15)”
R17: formula “=DEGREES($N$16)”
R18: formula “=SQRT(N14N14+N15N15)/441”
R21: formula “=MOD(($N17-$N9+180),360)-180”

Col O:
R9, 17 & 21 “degrees”

1 Like

Either way, the dangers are the same. If the neutral wire becomes disconnected outside or inside your home, or a neighbour on the same transformer does something silly, everything could become live to line. Everything, that includes the computer and anything that has a wired connection to it. So you are best using a laptop running on batteries with nothing else connected. If you have access to an isolating transformer that you can run your computer plus the a.c. adapter under test from, then do that, as it will isolate you from the supply. But you are still potentially handling live mains. You must still be extremely careful, and work out exactly what could become live in the event of a fault before you start.

I happen to have a transformer “ex equipment” that I found out was originally designed as a phase reference, so it has an extremely low phase error, so I use that. If you’re using resistors, use several lower value ones in series for the “top” part of the voltage divider - if one fails to a short, it won’t be a complete disaster.

Not only voltages, stray and cable capacitances as well as they will affect the phase measurement.

1 Like

I have a badly damaged UPS that I can salvage for parts, with two fairly large transformers in it, however I do not know if they are considered isolating transformers, I will need to research how to identify what type they are.

Without knowing the details of your UPS, it’s impossible to say whether it would be useful. What I thought that you’d more likely have access to is the sort of isolating transformer used for portable tools, but even that might be the wrong voltage.

My reference transformer output is 3 V, so very easy to divide down.

Bear in mind that the phase error will change with the voltage, so you need to measure at your normal voltage. You can see how much the UK a.c adapter’s phase error changes from the test report in Learn. Learn→Electricity Monitoring→Voltage Sensing→Report: IdealPower 9V AC-AC Adapter→Ideal Power 9V AC-AC Adaptor (Voltage Transformer)

1 Like

using a voltage divider calculator I found that a divider of 3000R / 10R for 120v should output 0.399v

I was thinking I could use 3 of these 100w 1000ohm wirewound resistors in series:

above a 100w 10ohm wirewound resistor:

I will use a laptop, i have several really old ones that I no longer use.

does my choice of resistors (wirewound 3x1000R / 10R for 120v should output 0.399v) sound correct to you?

Also you said sound card max input is 1v. So at 0.399v I am leaving myself a lot of headroom, possibly too much. What value should I be shooting for?

I was thinking even resistor rated for 10 watts should be more than enough, but the cost difference between the 10watt ones and these 100 watt ones is not that much. My thinking was that these ones would be less likely to fail or short, especially if I point a fan at them and keep them cool.

Thanks :slight_smile:

No. Why do you need so much current and hence to dissipate so much power? That’s overkill.

The “bottom” resistor in the chain wants to be 10 or more times smaller than the input impedance of your sound card. That’s likely to be not less than about 10 kΩ. So we’ll have a 1 kΩ resistor there. Let’s say you want 0.5 V rms across it, so the current in it will be 0.5 mA. Power dissipation is then 0.25 mW.

The “top” resistor will be passing the same 0.5 mA, and needs to drop 120 V (we’ll forget the 0.5 V - it represents a ½% error). The resistance value needs to be 240 kΩ. That’s very conveniently 2 × 120 kΩ resistors in series, but it wouldn’t make much difference if you had 3 × 82 k, or 4 × 62 kΩ. The total power dissipated in the ‘top’ resistor will be 60 mW. (30, 20 or 15 mW in each resistor.)

So you can use common 0.25 W or 0.33 W resistors with no problem.

More to the point, if you do touch anything other than the 120 V line, the current will hardly be enough to feel, let alone cause you any injury. (It might even not damage your laptop!)
With your 1 kΩ resistor, you could have 120 mA - that could kill you.

1 Like

Thank you Robert, that is scary! I was only focusing on the output voltage and not the output current. The good news is I think already have these resistors. I don’t have to order and wait for them to arrive.

Thank you very much for the info :slight_smile:

Don’t take this the wrong way, but I’d much prefer to scare you now than you find out the painful (hopefully), or worse, way.

1 Like

absolutely! I appreciate it.

edit: just finished rummaging through what I have for resistors, which is nowhere near as much as I thought. I just ordered a 3120 pcs pack https://www.ebay.com/itm/143244374343

Will be back at it once they arrive in 2-3 weeks :slight_smile:

If you want to improve your odds against a mis-wired outlet/plug, you can treat both of them as equally scary with something like this:


That’s intended for the differential inputs of an energy IC, so you might need to tweak appropriately for your needs.

In the lab, when working on something with “dual supplies” you really need to be careful you’ve isolated everything before you dive in to probe/debug. A trap is to disconnect the USB (or PoE cable in my case) see all the LEDs go out and think it’s safe to pick up the board and start adding scope probes.

For additional security against concentration lapses, you can wrap both sides of the board around the divider network in a 3D printed safety cover:

When I was doing my student apprenticeship, at a firm making thyristor drives, for a reason I can’t remember now the electronics ran off about 15 V d.c (of course), but the whole lot was live to line. It was common practice to have all the 'scopes unearthed, so when the scope’s GND lead was clipped onto the electronics 0 V, the body and the case of the 'scope was live. That’s when I learned to be very careful when working on live gear. And I can’t remember ever getting a shock.

This of course was a long time before the days of health and safety gone stupid.

I’ve had another look at this transformer. I desoldered it from the module and followed it’s datasheet.

500k input resistance across a bunch of resistors and potentiometers. 100R burden on the output.

Yellow trace is mains AC. Blue is the output across the burden.

Simultaneously the waveform is smoothed very slightly, and noise is added.
Adding a 100nF capacitor in parallel with the burden made the output noisier, no perceptible phase shift.
Here’s 47uF in parallel with the burden, much more shifty, different scale too so the amplitude is actually decreasing significantly:

The c.t burden voltage should be 200 mV rms. It actually looks to be about 50 mV. I would suggest the noise is generated inside the 'scope.

I have of course looked at the data sheet. What’s attractive about this c.t. is it operates at 2 mA, therefore the power dissipated by the multiplier resistor is low - ½ W - which can easily be handled by two ½ W resistors in series.

For the multiplier resistor, I’d normally put two equal values in series anyway for the voltage rating. Those are in series with the primary to convert the mains voltage into the current that the c.t. requires, then the burden resistor recreates a voltage for the ADC. The snag of course is that 200 mV is rather too low for an ADC with a 3.3 V reference, hence the suggestion to use an op.amp to generate a more appropriate voltage.

With the phase shift claimed to be less than 20 minutes of arc, I wouldn’t expect to be able to see that on a 'scope at that horizontal resolution.