Closed msyth333 closed 3 years ago
You are using PZEM004T V3.0 (the same I have, with white optocouplers). The communication protocol is different from the one in the previous version, so this library is not compatible with V3.
This is the manual for V3, including the protocol description: https://innovatorsguru.com/wp-content/uploads/2019/06/PZEM-004T-V3.0-Datasheet-User-Manual.pdf
The manual for the older version is this one, which describes the same protocol as the readme in this library: https://www.circuitspecialists.com/content/189799/ac004.pdf (note that although it says "V3.0" It refers to PZEM-004, not PZEM-004T)
In this other issue: https://github.com/olehs/PZEM004T/issues/40 SumeriLal pointed to another library, specific for 004T V3.0: https://github.com/SumeriLal/Arduino/tree/master/MasterPZEM
Another library for PZEM004T-V3.0: https://github.com/mandulaj/PZEM-004T-v30
I have also this problem now it is still, the nan value . can someone help me with this I had been connecting pzem to ttgo tcall esp32. but the issue was my serial monitor can't read the reading even though I successfully upload my file. They just display the unit but when I turn on main supply and load, they did not detect the value.
LiquidCrystal_I2C lcd(0x27, 16, 2);
PZEM004Tv30 pzem(Serial1, TX, RX);
PZEM004Tv30 pzem(Serial1);
void setup() { / Debugging serial / Serial.begin(9600); lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.setCursor(0, 1); lcd.print("ENERGY METER"); delay(500); lcd.clear();
}
void loop() {
float voltage = pzem.voltage(); if(voltage != NAN){ Serial.print("Voltage: "); Serial.print(voltage); Serial.println("V"); lcd.setCursor(0,0); lcd.print("V:"); lcd.print("VOLTAGE");
}else{ Serial.println("Error reading voltage"); }
float current = pzem.current(); if (current != NAN){ Serial.print("Current: "); Serial.print(current); Serial.println("A"); lcd.setCursor(0,1); lcd.print("I:"); lcd.print("CURRENT");
}else{ Serial.println("Error reading current"); }
float power = pzem.power(); if (power != NAN) { Serial.print("Power: "); Serial.print(power); Serial.println("W"); lcd.setCursor(8,0); lcd.print("P:"); lcd.print("POWER");
}else{ Serial.println("Error reading power"); }
float energy = pzem.energy(); if (energy != NAN) { Serial.print("Energy: "); Serial.print(energy,3); Serial.println("kWh"); }else{ Serial.println("Error reading energy"); }
float frequency = pzem.frequency(); if (frequency != NAN) { Serial.print("Frequency: "); Serial.print(frequency, 1); Serial.println("Hz"); lcd.setCursor(8,1); lcd.print("F:"); lcd.print("FREQUENCY");
}else{ Serial.println("Error reading frequency"); }
float pf = pzem.pf(); if (pf != NAN) { Serial.print("PF: ");Serial.println(pf); lcd.setCursor(0,3); lcd.print("PF:"); lcd.print("pf"); }else{ Serial.println("Error reading power factor"); } Serial.println(); delay(2000); }
SERIAL MONITOR: Energy:
Voltage: nanV Current: nanA Power: nanW Energy: nankWh Frequency: nanHz PF: nan
@margohaux Wrong repo https://github.com/mandulaj/PZEM-004T-v30
i tried the code for the hardware serial for my ttgo tcall esp32 but i get an error, error reading.
hi.. I had been connecting pzem to nodemcu. but the issue was my serial monitor can't read the reading even though I successfully upload my file. They just display the unit but when I turn on main supply and load, they did not detect the value. Here was my hardware connection, result and coding. Hopefully someone can help me to figure out this issue.