The PZEM004t is a digital power meter designed for measuring key electrical parameters in AC circuits, including voltage, current, power, energy, and frequency. It is widely used in applications requiring real-time monitoring and data logging, such as home automation, industrial equipment monitoring, and energy management systems. The module features a built-in display for standalone operation and supports UART communication, making it easy to interface with microcontrollers like Arduino or Raspberry Pi for advanced data analysis.
The PZEM004t is a versatile and compact module with the following key specifications:
Parameter | Value |
---|---|
Voltage Range | 80V - 260V AC |
Current Range | 0A - 100A (with external current transformer) |
Power Range | 0W - 22kW |
Energy Range | 0kWh - 9999kWh |
Frequency Range | 45Hz - 65Hz |
Communication Protocol | UART (9600 baud rate) |
Power Supply | Self-powered from AC input |
Accuracy | ±0.5% |
The PZEM004t module has a 4-pin interface for UART communication and power connections. The pinout is as follows:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply for UART interface (3.3V or 5V) |
2 | GND | Ground connection |
3 | RX | UART Receive pin (connect to TX of microcontroller) |
4 | TX | UART Transmit pin (connect to RX of microcontroller) |
The PZEM004t can be easily interfaced with an Arduino UNO using the SoftwareSerial library. Below is an example code to read data from the module:
#include <SoftwareSerial.h>
// Define RX and TX pins for SoftwareSerial
SoftwareSerial pzemSerial(10, 11); // RX = pin 10, TX = pin 11
// Include the PZEM004t library
#include <PZEM004Tv30.h>
// Initialize the PZEM004t object
PZEM004Tv30 pzem(&pzemSerial);
void setup() {
Serial.begin(9600); // Start the serial monitor
pzemSerial.begin(9600); // Start communication with PZEM004t
Serial.println("PZEM004t Power Meter Example");
}
void loop() {
// Read voltage
float voltage = pzem.voltage();
if (!isnan(voltage)) {
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.println(" V");
} else {
Serial.println("Error reading voltage!");
}
// Read current
float current = pzem.current();
if (!isnan(current)) {
Serial.print("Current: ");
Serial.print(current);
Serial.println(" A");
} else {
Serial.println("Error reading current!");
}
// Read power
float power = pzem.power();
if (!isnan(power)) {
Serial.print("Power: ");
Serial.print(power);
Serial.println(" W");
} else {
Serial.println("Error reading power!");
}
// Read energy
float energy = pzem.energy();
if (!isnan(energy)) {
Serial.print("Energy: ");
Serial.print(energy);
Serial.println(" kWh");
} else {
Serial.println("Error reading energy!");
}
// Wait for 1 second before the next reading
delay(1000);
}
No Data Output:
Incorrect Readings:
Module Not Powering On:
Q: Can the PZEM004t measure DC circuits?
A: No, the PZEM004t is designed specifically for AC circuits and cannot measure DC voltage or current.
Q: Can I use the PZEM004t with a Raspberry Pi?
A: Yes, the PZEM004t can be interfaced with a Raspberry Pi using its UART pins. Ensure proper voltage level shifting if required.
Q: How do I reset the energy reading to zero?
A: The PZEM004t library provides a function to reset the energy reading. Refer to the library documentation for details.
Q: What is the maximum distance for UART communication?
A: The maximum distance depends on the quality of the wiring and the environment, but it is generally recommended to keep the distance under 10 meters for reliable communication.