Can't read (volt, current, power, energy) from PZEM-004

Hi,
I connected arduino with PZEM-004 to read (volt, current, power, energy) from motor but (volt, current, power, energy) alway display 0 in Serial Monitor

#include <PZEM004Tv30.h>
PZEM004Tv30 pzem(11, 12);
void setup() {
Serial.begin(115200);
}
void loop() {
float voltage = pzem.voltage();
if(voltage != NAN){
Serial.print(“Voltage: “); Serial.print(voltage); Serial.println(“V”);
} else {
Serial.println(“Error reading voltage”);
}
float current = pzem.current();
if(current != NAN){
Serial.print(“Current: “); Serial.print(current); Serial.println(“A”);
} else {
Serial.println(“Error reading current”);
}
float power = pzem.power();
if(current != NAN){
Serial.print(“Power: “); Serial.print(power); Serial.println(“W”);
} else {
Serial.println(“Error reading power”);
}
float energy = pzem.energy();
if(current != NAN){
Serial.print(“Energy: “); Serial.print(energy,3); Serial.println(“kWh”);
} else {
Serial.println(“Error reading energy”);
}
float frequency = pzem.frequency();
if(current != NAN){
Serial.print(“Frequency: “); Serial.print(frequency, 1); Serial.println(“Hz”);
} else {
Serial.println(“Error reading frequency”);
}
float pf = pzem.pf();
if(current != NAN){
Serial.print(“PF: “); Serial.println(pf);
} else {
Serial.println(“Error reading power factor”);
}
Serial.println();
delay(2000);
}

IS the motor powered from AC mains and does the motor rotate?

Yes

And are you seeing all the error messages on the serial monitor?

Serial monitor don’t display error, only show 0V,0A,0W,0Wh

I do not see where you define the type of processor you are using. Reading the documentation for the include file, it shows a #define for the processor type so the code that results matches your actual processor.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.