PZEM 004T V1
1.0.0
Author: Dali Hillary
Role: Software & Hardware Engineer
The PZEM004TV1 library is designed to interface with the PZEM-004T V1.0 module, a power monitoring device. This library provides an easy-to-use set of functions to read various electrical parameters such as voltage, current, power, energy, frequency, power factor, and alarm status.
Include the Library:
#include "PZEM004TV1.h"Instantiate the PZEM004TV1 Object:
PZEM004TV1 pzem(RX_PIN, TX_PIN); Read Electrical Parameters:
float voltage = pzem.readVoltage();
float current = pzem.readCurrent();
float power = pzem.readPower();
float energy = pzem.readEnergy();
float frequency = pzem.readFrequency();
float powerFactor = pzem.readPowerFactor();
bool alarmStatus = pzem.checkAlarmStatus();Reset Energy:
pzem.resetEnergy();#include "PZEM004TV1.h"
PZEM004TV1 pzem(RX_PIN, TX_PIN);
void setup() {
Serial.begin(9600);
}
void loop() {
float voltage = pzem.readVoltage();
float current = pzem.readCurrent();
float power = pzem.readPower();
float energy = pzem.readEnergy();
float frequency = pzem.readFrequency();
float powerFactor = pzem.readPowerFactor();
bool alarmStatus = pzem.checkAlarmStatus();
Serial.println("Voltage: " + String(voltage) + " V");
Serial.println("Current: " + String(current) + " A");
Serial.println("Power: " + String(power) + " W");
Serial.println("Energy: " + String(energy) + " kWh");
Serial.println("Frequency: " + String(frequency) + " Hz");
Serial.println("Power Factor: " + String(powerFactor));
Serial.println("Alarm Status: " + String(alarmStatus));
delay(5000);
}