New PZEM004T v3.00 and power flow direction

New on this forum , Hello all.
I have purchased an energy meter based on the new version (v3.0) of the PZEM004T ( 100A CT) little board. After having tested many Modbus request with the serial line 3 of my Arduino Mega 2560, it seems that no indication of the polarity of the power exchange is available : It is always positive irrelevant of the sign of the product V x I . The position direction of the wire inside of the 100A Current Transformer is not changing anything of the value of the power sign. Is anybody aware on how we can "see" the direction of the power exchange with such a device? Is there any software solution to detect if I consume power or resell the power to the public mains? Many thanks for your advices. Regards. JFB

You have not supplied a diagram of how you have all this hooked up.

What exactly does this mean :" how we can "see" the direction of the power exchange". What exchange? You are dealing with AC, right?

Are you using the sample program?


Hello Paul,
Attached a simple view of a consumption connexion of the PZEM004T power meter on 230Vac mains.

This arrangement is normaly dependant on the way you pass the current wire inside the 100A Current Transformer. This has nothing to do with AC measurement but the direction of the energy flow. The convention is that if you consume power the average product V x I is positive and if you generate power ( with solar cells and inverter for exemple) the sign of the exchange is negative. The PZEM004T version 3.00 with embedded communication MODBUS RTU is not able to change the polarity of the power when you invert the Current Transformer current flow!

There is no software supplied with it only the simplified protocol used to acces the registers. This part works fine after understanding how CRC control bytes are organized. ( probably HH and LL bytes inverted!)

The PIC and DSP embedded inside the Vango V9881D have a lot of registers and the documentation found in the china’s manufacturer site is gigantic to read and not easy to understand.
If anybody has encounter such a difficulty to identify when the power is consummed or generated I am interested to know it to adapt my display software!

Regards, JF

hello All,
Can somebody explain the meaning of an holding register in simple words? The PZEM004T V3 is replying to the request address 3 but because the documentation says nothing about it. The general MODBUS RTU layer says something for the people writing software on the subject of the "holding register"?
Best regards,

Hello all, there is a lot of confusion about PZEM-004T V3.0 on internet, After a lot of search and time spent I collected its detailed information about it, Plese check my Blog where I posted its connection and Arduino code.


Hello Innovator Guru,
Thanks for the repository librairy and Arduino example. It works correctly except for the sign of the power as mentioned in the tittle of the subject.
I suspect that the embedded firmware of the VLSI does not distinguish the direction of the power flow!
Accessing to the holding registers does not show indication on this bug!
Best regards,

Just found this as I’m looking at using a new V3; from what I can tell the internal coding of the PZEM004 must just spit out the figures as positive, however there was a hack detailed in the following link that supposedly allowed you to detect direction:

Pin 51 of the SDIC SD3004 is described as “Goes high when phase difference between voltage and current is greater than 90 degrees. REVP updates its logic state when a CF pulse is issued.” Theoretically(!) if this is high then you are exporting power to the grid (if monitoring your mains connection), but I haven’t found any confirmation of this and haven’t had a CT installed to test; I’d greatly appreciate if someone (Bouteille_JF?) with an existing setup could confirm whether this is the case. Note the optical isolator so things (or you) don’t accidentally get fried!

The following openenergymonitor links detail the theory, but those links and apreb’s hack are the only reference I’ve found anywhere on line as to how to detect when you are exporting to the grid (phase difference), and even those at my workplace who deal with metering don’t know the details of how exactly you can “feed in” to the grid!

I am also concerned about the direction of the current of the v3.0. who can help me

Can anyone help me?

I am also concerned about the direction of the current of the v1.0. Can i do it?


I am also very very interested in detecting direction. It's a must have for us having PV solar panels.

Did someone manage to do this?


Hello to all, first post here!

I've just received my PZEM004T V3 modules from China, I've been investigating on how to use it and found this thread. Although I don't' (still) have PV generation a home, I'm also interested in detecting power flow direction.

I've been googling about the subjects and all the discussions about the topic seem to reach a dead-end, like this one, so I'll share what I've found just in case someone can find something from that.

With the previous version, as stated in post #6, it was possible to do it as the main chip in there had a specific pin for that, but this version has a completely different one, marked V9981D.

I've found the datasheet for this chip (V9981) and, from the information there, the IC is capable of detecting power flow direction. The first page states "Positive/Negative and
active/reactive energy", and, for example, it has different registers for accumulating positive and negative energy (see 11.13.1. on page 114). I haven't found there if one of the pins is used to signal power flow.

So I'm afraid the problem is in the PZEM004T firmware, which apparently isn't prepared to use these capabilities if the main chip (or, at least, the commands for that are not documented).

I haven't still started to use the sensor, but the first thing I'll try is to see if the accumulated energy works the same with the current transformer inserted in both ways (or line-neutral changed). If the implemented read energy function is related only to one of those registers, maybe it's possible you get a positive power value regardless of the phase between V and I, but it only would accumulate energy when connected "properly" (if somebody has already tried this, please comment). If this was the case, it could be used to detect power flow via software (although you wouldn't have accumulated energy info in one of the directions and would have to do it via software).

The best solution would be, of course, if Peacefair issued a new firmware revision that made better use of the SoC's capabilities, but the problem then would be how to flash it to the V9981 microcontroller...

I am also concerned about the direction of the current of the v1.0. Can i do it?

Here you can find the implementation of power direction in V1:

Are you connected correctly? You can check Wiring Diagram PZEM-004T V3.0 3

As I said, I haven't still tested the module but, from what people say, it always reports positive power regardless of how you connect line and neutral and the current transformer (talking about "polarity", obviously; voltage and current must, of course, be connected to their specific terminals).

Even if you connect line and neutral as per that diagram, reversing the current transformer connections (or the way the power conductor passes trough it) should change the sign of power, if the sensor was designed to take power flow direction into account.

OTOH, where I live (and also in other countries in Europe), line and neutral can be easily reversed in a plug-in appliance (e.g., if you install the PZEM004 in a power strip), as AC plugs don't have "polarity" and network codes don't oblige to connect line or neutral to a specific side of the plug, so it would be difficult to respect that (wouldn't be a problem for power direction, as if you invert line and neutral in such a power strip, you'd be simultaneously inverting the current transformer, and both effects would compensate each other).

Here you can find the implementation of power direction in V1:
GitHub - apreb/eNode: Device to measure energy and temperature

The eNode workaround is only applicable to V1 chips... the V3 has other type of chip, as you mentioned before.

Anyway, in that example, there are almoust no info except one picture with an opto... There is no mention what type of opto is using, how many volts come from the output of the SD3004 chip at pin 51 (REVP). At least these info's are essential to implement the current sense "trick".

After some googling around, (and some live observation, of my friends PV plant) I found that it is a relation between the value of the voltage from the PV inverter, and the value of the grid voltage. So, it's preety easy to detect power flow, without any complication.
So, If the PV inverter voltage is higher than the grid voltage... that means you are consuming from PV (and you make injection ).
If the grid voltage is higher than the voltage from the PV inverter ,means the current flows from the grid in to your house (no injection).

Seems like it is preety simple...

As I said, I haven't still tested the module...

Tested with the Windows app and confirmed: It always read positive power regardless of the connection of the current transformer, and it also accumulates energy in both alternatives, so the trick of using energy to detect power flow direction wouldn't work.

It seems like Peacefair decided this on purpose as considering the datasheet states there are two different registers for "positive" (consumed) and "negative (generated) energy, it would have been easier to read and export via serial output just one of them.

I imagine they decided this sensor was always going to be used for a determined sense of power flow and the way they programmed it would be easier for this use, as you don't have to worry about current transformer (CT) connection. A pity, anyway, as it would have been as easy as, if you get negative when you expect positive, just reverse the CT connections...

Je vous propose un schéma de détection de sens du courant AC, je n’ai pas encore teste, si quelqu’un veut faire une maquette ça serait super.

DetectSensAcCurrent.pdf (317 KB)

After some googling around, (and some live observation, of my friends PV plant) I found that it is a relation between the value of the voltage from the PV inverter, and the value of the grid voltage. So, it's preety easy to detect power flow, without any complication.

Hi adiculiniute ,
how do you know the grid voltage when measuring ? I measure with the sensor on one point, I assume this will be the voltage who is the strongest at that time. But what if you partially consume from the grid and partially from the invertor what will be the voltage on that moment. Also the grid voltage is not always constant. I see indeed that the voltage is higher when I produce from the invertor. But how can we know the exact point in voltage when the current is negative, so the invertor produces more energy then we consume.

Hello dwienie!
Man, If I could, I would retract my previous post... since it is not 100% a thing you can trust. Indeed the voltage is higher when you produce power, but this is not a reliable indication of injection in grid.

So, I gave up on this, and I switched to plan B. I bought a digital meter:
This one, has a reverse indicator (LED). So, I put a LDR in front of this reverse indicator LED, and when it is ON, the arduino knows that injection is happening :slight_smile: You can search any meter who has the reverse indicator. This model, is not very responsive, compared to my main grid meter (the one who belongs to my electricity company) It needs a couple of seconds to detect the reverse condition... but I can get over this...

Best regards!