mandulaj / PZEM-004T-v30

Arduino library for the Updated PZEM-004T v3.0 Power and Energy meter
MIT License
256 stars 108 forks source link

Current direction #83

Closed jjtoard closed 1 year ago

jjtoard commented 2 years ago

Hi, I want to use the PZEM-004T to measure the power from and to the grid. It woud be nice if this could be added to the code.

I created somethins myself with sct-013 and a ZMPT101B. I can measure current and voltage and if the most part of the current sinewave is the opposite from the voltage sinewave, I consider this negative. I'm not that technical but this looks to do the trick. What this solution doesn't do correctly is the powerfactor so my power calculations are off when having capacitive and inductive load like airco, induction cooking, ...

Could the current direction be added to this project ?

mandulaj commented 2 years ago

Hey @jjtoard, the method you use for determining the power flow is essentially correct. Maybe a more precise definition is that the power flow is negative if the phase between the current and the voltage is more than 90deg or less than -90deg....

But as was mentioned earlier, the problem is we don't control the software doing the actual voltage, current aggregation. This is done internally in the PZEM chip by it's firmware which we can't modify.

This library only interfaces with the chip to get the voltage and current amplitudes and the power factor, which is the cosine of the phase. If the power factor is negative, your power flow is reversed. However the PZEM only provides the absolute value of the power factor so the power direction is lost.

mandulaj commented 1 year ago

Closing as duplicate of #2