-
Notifications
You must be signed in to change notification settings - Fork 114
Basic Setup
Most of us are comfortable wiring up breadboards using low voltages and currents. But most of us buy the PZEM004T because it lets us access information about our AC mains running at 120, 230 or 240V.
The first thing you should know is that the PZEM004T will return "-1" to everything unless it is connected to power on both sides. That means GND and 5V DC on the data side and 80V-260V AC on the measuring side. I did not want to play around with an open circuit to the mains while testing, so it took me a full day of testing different boards and serial configurations before I figured out I needed to hook it up to an outlet, after that it was easy.
Wire up your unit like this:
I am going to use a software serial port in my example. This because most Arduinos come with only one hardware serial and its shared with the upload / serial monitor.
Copy this sketch from the examples folder Click Here.
The 4th line reads:
PZEM004T pzem(10,11);
You simply replace "10" with the pin number you have connected to the green wire on the data side and replace "11" with the pin number you have connected to the white wire on the data side.
If your Arduino is 5V you are in luck. All you have to do is connect the red wire on the data side to your 5V on the Arduino and the black wire on the data side to your GND.
If your Arduino is 3.3V you have 2 choices.
-
Power the data side with an external 5V power supply and (if needed) use a logic converter to shift the serial signal voltage.
-
I have not tested this, but This Page suggests you can replace R17 (resistor located just below the serial port) with a 510 Ohm resistor which enables the PZEM004T to operate at 3.3 Volts, see this page for more details.
This is the scary part because we are working with voltages that are potentially lethal.
Look at the drawing above again. You will need to wire the 2 terminals on the right side of the board directly to the AC source. Not in line with any equipment you wish to measure, directly to the power source.
Attach the coil to the 2 terminals on the left side of the board. The CT (Current Transformer) is used to measure how much current is passing through a SINGLE wire. For example, a lamp cord in the US will have a minimum of 2 wires in it. If you want to measure how much current the lamp draws, you pass ONE wire through the CT. The other wire MUST stay outside the CT.
Tip. If you are using a 3.3V Arduino power with USB e.g. HUZZAH ESP8266 from Adafruit, you can power the data side using the USB 5V, even though the board is 3.3V. You should still protect your receive pin with a voltage divider.