The picture above is an error when using esp32 with pzem V3.0. There is cannot connecting to PZEM Module V3.0 the program always looping again to connecting blynk server after “connecting to PZEM” in serial monitor
whereas before using pzem v 1.0 there were no problems like that
There ia my code to connect esp32 + pzem 004t V1.0 with blynk. And its work
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = " Auth Token Blynk ";
char ssid[] = "SSID Wifi ";
char pass[] = "Password WiFi";
#include <HardwareSerial.h>
#include <PZEM004T.h>
#define HardwareSerial Serial2(2); // hwserial UART2 at pins IO-16 (RX2) and IO-17 (TX2)
PZEM004T pzem(&Serial2);
IPAddress ip(192,168,1,1);
float v;
float i;
float p;
float e;
void setup() {
Serial.begin(115200);
while (true) {
Serial.println("Connecting to PZEM...");
if(pzem.setAddress(ip))
break;
delay(1000);
Blynk.begin(auth, ssid, pass);
}
}
void bacaPZEM(){
//PZEM
v = pzem.voltage(ip);
if (v < 0.0) v = 0.0;
Serial.print(v);Serial.print("V; ");
i = pzem.current(ip);
if(i >= 0.0){ Serial.print(i);Serial.print("A; "); }
p = pzem.power(ip);
if(p >= 0.0){ Serial.print(p);Serial.print("W; "); }
e = pzem.energy(ip);
if(e >= 0.0){ Serial.print(e);Serial.print("Wh; "); }
Serial.println();
delay(3000);
}
void sendtoblynk(){
Blynk.virtualWrite(V0, v);
Blynk.virtualWrite(V1, i);
Blynk.virtualWrite(V2, p);
Blynk.virtualWrite(V3, e);
}
void loop() {
bacaPZEM();
delay(1000);
sendtoblynk();
Blynk.run();
}
But now i just bought pzem module version V3.0 and there are can to compiling and uploading to my esp 32. But there are no respond in serial monitor AND my esp 32 cannot connecting pzem, so it cannot connect to my blynk server. I think there are different configuration between PZEM V1.0 and PZEM V3.0. Maybe different in HardwareSerial or maybe SoftwareSerial.
I found library PZEM004Tv30 and modify to my code. But there still show error in my serial monitor. I do know what must i do to fix this. Please somebody help me to fix that.