Power & power factor reading issue while using ACS712 & ZMPT101B Module

Hi Everyone,

I’m currently working on an Energy meter project to measure voltage, current, power, power and energy. I stumbled upon emoblib and currently using it to measure above parameters.

I’ve directly connected ACS712 & ZMPT101B sensors to arduino and made following changes in calibration as follows

emon1.voltage(1, 325.3, -2); // Voltage: input pin, calibration, phase_shift
emon1.current(2, 13.5); // Current: input pin, calibration.

Also, Ive not done any other calibration other than the above changes. Please suggest me if anything else needs to be done.

I’m getting proper voltage, current, power, pf values for resistive load (incandescent bulb) which i cross checked with an energy meter. But, I’ve no luck in getting proper power and pf for loads such as CFL bulb, led light etc.

This project i’m working on is very time sensitive. So, any help will be highly appreciated. Thanks in advance

Regards
Karthik

Those are the only calibration values available to you - and the only ones that should be necessary. However, I’m rather concerned by the value -2 for the phase shift. Ideally, the value for that should lie between 0 and 1. In the circumstances for which emonLib was designed, it compensates for both phase errors in the transformers and for the timing error between making the two readings. The phase errors of your transducers should be very small, all you should need to correct for is the delay between the two readings, so I’m wondering whether you have got the interface for your sensors right, and not introduced a phase shift somewhere.

Have you considered noise? In our experience, Arduino ‘breadboard’ builds are often susceptible to excessive noise, and this of course will confuse the readings at low currents, which I think are implied when you say CFL bulb and LED light - in the singular.

The other question is - what is the standard against which you are comparing? It might well be that this too has errors.

Thank you so much for the quick response, sir.

‘’‘so I’m wondering whether you have got the interface for your sensors right, and not introduced a phase shift somewhere’’’

I’ve directly connected them to arduino. should there be any circuitry in between? or what exactly did you mean by interface for the sensors?

‘’‘Have you considered noise?’’’

will adding decoupling filters solve the issue? open for suggestion if not.

‘’‘what is the standard against which you are comparing? It might well be that this too has errors’’’

Ive used an energy meter from HTC to verify the data from arduino. I’m pretty much confident that this energy meter is giving me right data.

I’ve now been able to run a test for you. Using an emonTx V2 (because all the input pins are accessible), I’ve linked one of the ADC current inputs to the voltage input, so exactly the same wave is reaching both input pins.

With the phase calibration value set to 0.0, I get a power factor of 0.9877 (to 4 figures).
With the phase calibration value set to 1.0, I get a power factor of 0.9994 (to 4 figures).

p.f. = 0.9877 represents about 9° of phase error, which is close to the number I expect given the sample rate of emonLib.

[Edit: With no input, I see p.f. values anywhere between 0.07 and 0.3, but mostly around 0.13 Those are not of course true power factors, but the result of multiplying random small numbers arising from circuit and power supply noise. ]

I think you must have introduced somewhere, inadvertently of course, either a time delay or a phase shift, into one or both of the measurements. You should not need a phase calibration of -2.0 When I use that, I get a pf of 0.9635, representing a phase/timing error of 15.5° There’s something seriously wrong somewhere.

Have you ensured that the mid-point bias for the ZMPT101 is adequately decoupled, as that will appear as a high-pass filter to the ADC.

The noise source can be the power supply to your Arduino, or it can be the Arduino itself. There’s evidence to suggest that the internal power supply regulator is likely to be better in this respect than most 5 V sources, therefore it’s recommended that you use the 9 - 12 V barrel connector.
You also need to follow or exceed the data sheet recommendations for the ACS712.

[Edit]

Were you telling the truth when you wrote that you have a ZMPT101B, or were you misleading everybody and do you really have a ZMPT101B MODULE with op.amps. and filters?

Because if you have, that’s where your 15° phase error is coming from. For our purposes, that module is rubbish - throw it away - just keep the ZPMPT101B itself and follow its data sheet for the voltage multiplier and burden resistors around it, and bias it like an ordinary a.c. adapter according to the instructions in the ‘Learn’ section.

Hi Robert, Thanks again for the response. Sorry, I was out of station and couldnt respond any sooner.

I’m very new to all of these and still at the learning phase. So, some of the things that you’ve mentioned has gone straight over my head. Extremely sorry for that.

“Were you telling the truth when you wrote that you have a ZMPT101B, or were you misleading everybody and do you really have a ZMPT101B MODULE with op.amps. and filters?”

I really didnt know that ZMPT101B existed without the module. When I look for AC voltage sensor, all I saw was this sensor module and assumed this is how it comes as one packed module.

“Have you ensured that the mid-point bias for the ZMPT101 is adequately decoupled, as that will appear as a high-pass filter to the ADC.”

Would you please share more insights about this?

UPDATE: I’ve totally discarded the ZMPT101B sensor module and have used the voltage sensing method (230v~9v method using a voltage transformer) mentioned in the LEARN section. Yet, i’m still getting some degree of phase error. when I connect a 60W incandescent bulb, power factor shown was 0.86 for emon1.voltage(2, 234.26, 1.7) and emon1.current(1, 13.5) calibration. At this point i’m really confused as where exactly this phase error is being introduced.

There’s no need to be sorry. We all had to learn once - as long as you’re prepared to listen and learn, I’m prepared to help you, and I think you’ll find that’s true with most people here.

Yes it does. While the design of that module is OK if you want a number for the voltage, when you need to do more - as we do in the maths inside emonLib and calculate the power at one instant in time, and repeat that 2500 times per second - a delay between the mains voltage and what appears at the output terminal is critical, as you’ve found out.

I don’t think that is a problem. If you look at the circuit for the c.t. input to an Arduino in ‘Learn’ Learn→Electricity Monitoring→CT Sensors→3. Interfacing with an Arduino→CT Sensors - Interfacing with an Arduino,
it is the capacitor C1 that “decouples” the mid-point voltage so that no a.c. voltage appears there. If there was an a.c. voltage - say the 5 V supply was not steady - then it would find its way into the ADC input, which you don’t want.

The reason for that is the a.c. adapter also has a phase error, but it is much smaller that the ZMPT101B Module’s. You should be able to compensate for that.

But, as you have the ZMPT101B, why not use it? Did you notice a small circuit on the ZMPT101B data sheet? You can use that with the interface you have for the a.c. adapter.

Calculate R’ = your voltage ÷ 2 mA, then split that (for safety reasons) into at least two equal resistors in series to give you the nearest to the correct value. Using the actual value you have for R’, calculate R, the burden (or sampling or load) resistor, using the equation given. The value you use for U2 is the rms value that is about 0.3 × the input voltage range of your ADC. That will give you about 10% spare to allow for mains voltage fluctuations.

You then connect that circuit almost exactly as you have connected your a.c. adapter, except that you do not use the voltage divider resistors that you have with the a.c. adapter - connect one side of U2 to “mid-point” and the other side to the ADC input.

And that should give you a good power factor.

“There’s no need to be sorry. We all had to learn once - as long as you’re prepared to listen and learn, I’m prepared to help you, and I think you’ll find that’s true with most people here.”

Thanks for the kind understanding.

"But, as you have the ZMPT101B, why not use it? Did you notice a small circuit on the ZMPT101B data sheet? You can use that with the interface you have for the a.c. adapter.

Calculate R’ = your voltage ÷ 2 mA, then split that (for safety reasons) into at least two equal resistors in series to give you the nearest to the correct value. Using the actual value you have for R’, calculate R, the burden (or sampling or load) resistor, using the equation given. The value you use for U2 is the rms value that is about 0.3 × the input voltage range of your ADC. That will give you about 10% spare to allow for mains voltage fluctuations.

You then connect that circuit almost exactly as you have connected your a.c. adapter, except that you do not use the voltage divider resistors that you have with the a.c. adapter - connect one side of U2 to “mid-point” and the other side to the ADC input.

And that should give you a good power factor."

To see if i’ve understood correct,
so,

R’=260(fluctuations in India) / 2mA = 130kohm
if i take U2 = 0.3 x 5 = 1.5V then
R=(1.5x130k)/260=750ohm

Please let me know if the assumptions are right. If this is right then i’m bring in all necessary components and check if I get the right power factor

One last thing, If i use the below CT then do i have to decouple the CT output before feeding it to the ADC or is it already decoupled as the output is already 1V?

Screen Shot 2021-01-07 at 19.02.16

I would make R’ 2 × 68 kΩ in series. Each resistor will then dissipate just under 250 mW, so a ½ W component, with a 250 V or 350 V rating, will be suitable. (Note, the peak voltage of a 260 V supply is above the highest common resistor voltage rating, which is 350 V. This is one of the reasons for using at least two in series.)

That will make R = 784 Ω, so choosing the next lower value, 750 Ω should be fine.

That c.t. already has a burden resistor built in, so use the circuit here Learn→Electricity Monitoring→CT Sensors→3. Interfacing with an Arduino→CT Sensors - Interfacing with an Arduino but DON’T have the 33 Ω burden - you already have that inside the case of the c.t.

But - you might be making things complicated for yourself. Both the c.t. and the a.c. adapter have a phase error, and it’s the difference between the two phase errors that causes you to read the wrong power factor, and which PHASECAL attempts to compensate for.

The ZMPT101B and the ACS712 both have a very small phase error, so the difference between those is very small.

I would advise you to use either the a.c. adapter and c.t., OR the ZMPT101B and the ACS712, and not mix them.

You can read about the phase error for our a.c. adapter and the c.t. (the 100 A version - but that 15 A one will be similar) in the test reports in the ‘Learn’ section here.

Hello, I’m doing the same project on power factor monitoring and correction. The main problem I’m facing is the issue to deal with phase shift. My circut gives me a power factor of 0.8 for a resistive load, ie 40w incandescent lamp

Welcome to the OEM forum, Victor.

If you’re using a ZMPT101B module like the title of this topic, then this is where your problem lies. Throw it way, use the ZMPT101B transformer as it is meant to be used, not with the op.amp and the very silly filter hung on it. It’s the band-pass filter that causes the problem.

A p.f. of 0.8 is about right, it is the error the filter introduces.

Hello Robert
Thanks,
I have follow your sugestion, using ZMPT101B transformer and acs712 30A
But for load 60w incandescent lamp, i only get 0,9
and for Phillips led lamp 13w, i only get 0,6

I have Pzem-004T v3.0 with PZCT 100A/100mA with ESP01S running, and compared to Pzem reading, for 60w incandescent lamp i got 1,0
And for the Led Lamp, i got 0,5

When i change PHASECAL from 1.7 to 2.0 to -3 but i got the same pF reading when i change the value of PHASECAL

Then, i try to use the PZEM CT Transformer, because i saw EmonTX v4 using ZMPT101B and CT Transformer
But it cannot read the pF corrctly

This when no Load

 Vrms: 233.64 V
 Irms: 0.3506 A
 real Power: -4.4634 W
 apparent Power: 81.9073 W
 Power Factor: -0.05

This When 13w Led Lamp is turn on

 Vrms : 238.13 V
 Irms: 0.3013 A 
 real Poweri: 8.2700 W
 apparent Power:: 71.7560 W
 Power Factor: 0.12

 Vrms : 238.05 V
 Irms: 0.2852 A
 real Power: 12.5708 W
 apparent Power: 67.8972 W
 Power Factor: 0.19

I have read this AVR-DB: emonTx V4, new hardware in progress
So why in EmonTX v4 it could use ZMPT101B and CT Transformer, is there something wrong with my setup?

I use STM32F103 C6T6 and Arduino 1.8.12 and RogerClark Core

Best Regrads,
Teguh

Welcome, @TeguhTeknisi to the OEM forum,

Those numbers are believable, and I can quite believe the power factor of the LED lamp and c.t. errors (which increase rapidly at very small currents) would give a p.f. of 0.5.

Accurate reading of real power (hence power factor), depends on compensating in the software for three things: a possible phase error in the voltage sensor, a possible phase error in the current sensor, and a possible time error between reading the two sensors - which equates to a third phase error.

EmonLib and emonLibCM are both designed to be used with the Atmel ATMega328P, so both incorporate a compensation by way of phasecal (in emonLib) and phasecal plus the ADC conversion time in emonLibCM. Unless the overall compensation for all three sources of error is correct, you will get a power factor error - and an error in the value of real power.

Without deeply studying the data sheets for all the components you are using, which I don’t at present have time to do, I’m afraid I can’t make a specific recommendation.

Thanks for the reply.
so for now i will stick to ZMPT101B and Acs712

Btw, I use stm32f103 because 12bit adc and cost the same as Atmega328p clone, and i have read emonlib for stm32 too, i thought it will much better when using stm32
this where i know about stm32 STM32/EmonLib.md at master · openenergymonitor/STM32 · GitHub

for pzem ct transformer, its sold without pzem, and its cheap 100A/100mA ct transformer, its cost 3 us dollar on aliexpress
here the spec of pzem ct transformer

1. Product introduction
The current and voltage transformers of PZ and other products produced by our company are suitable for various electronic instruments, household appliances, and leakage safety detection. When zero-sequence grounding current is generated, it is used in conjunction with an electronic sampling device or a relay protection device to make the device components operate to achieve protection or monitoring. It has the characteristics of high precision, good linearity, reliable operation, convenient installation and beautiful appearance. 

2. Conditions of Use
Ambient temperature: Maximum temperature -20℃~+60℃
Relative humidity: ≤95%

3. Product category and data
voltage 150V~240V (AC)
frequency 50Hz (sub-harmonic 150~250 Hz)

4. Characteristics
The input bus is perforated, small and light, easy to install and fix; good mechanical and environmental resistance, strong voltage isolation, safe and reliable;

5. Performance
Ambient temperature:   -5 5 ℃-+85℃
Relative humidity: 40℃<90%
Working range: 20Hz-20KHz
Insulation heat resistance class: 0.1 class (130℃)
Insulation resistance: 1000MΩ
Anti-electricity: 5000V/1 minute
Flame retardancy: in line with VL94-VO level

6. Technical parameters
Output ratio : 1000/1
Precision : 0.1A
Linearity : 1%
Linear range : 0-100A
Blocking withstand voltage : 3KV
Operating temperature : -35-70C

The big thing missing from the spec. is phase error - and it’s most likely that which is causing you problems.

Thanks for the reply
I thought, the Pzem-004T CT its the best and cheaper i can use, because i can read Power Factor when using Pzem-004T v3.0 (FYI: Phillips Led Lamp 13W have PF 0,5 and Phillips incandescent Lamp 60W have PF 1.0 )

I read in here Learn | OpenEnergyMonitor , i thought, that i can use any CT Sensor

Best Regrads,
Teguh

Yes you can, provided that you calibrate it correctly - and if the difference in phase errors is markedly different from the same thing for our recommended sensors, you might need to change the code to account for that. Usually, the best way to do that is to store one or the other samples for one or maybe more samples (or remove the delay if there is one) so as to bring the phase calibration within an acceptable range,

1 Like

Thanks Robert, i will try to look into it when i need to use CT Sensor again.
For now, acs712 30A is enough for me.

There is something i want to ask, about STM32 branch of EmonLib ini here STM32/EmonLib.md at master · openenergymonitor/STM32 · GitHub

Is there a beneffit to use it on Arduino IDE ?
Because right now, i use standard EmonLib (not CM and not STM32 branch) for my STM32 Blue Pill Board

Btw, when i try to use STM32 branch, i cannot compile it ( Cannot compile using STM32duino core · Issue #20 · openenergymonitor/STM32 · GitHub )
I have to ask Frederic from STM32duino to look at the issue, but it seem not the problem from STM32duino core

Best Regrads,
Teguh

Sorry, I know almost nothing about the STM32. But if you are using a STM32, the timing is certainly wrong for emonLib.

Thanks Robert.
That fine, thanks for the help.

Btw, sorry, i don’t get about timing, is this about arduino timing? or timer?

Best regrads,
Teguh

emonLib and emonLibCM expect a single ADC to be used, switched between inputs. Therefore there is a time delay between reading voltage & current. This equates to a phase shift. Both transformers (if you have them - which is what we assume - also contribute a phase shift. It’s the cumulative effect of these 3 components that phasecal attempts to compensate for, Two will add, one will subtract. The order you read the inputs determines which. What you’re correcting for is the apparent difference in time (a phase error) between when each quantity appears to have been measured.

The physical phase errors depend on what you’re using, for the ACS712 & the ZMPT101B they will be small, and the STM32 operates at a totally different speed to the Atmel ATMega 328P, so that component is different too. It’s this that I was referring to.

1 Like