Not able to connect blynk GSM module with PZEM 004T Module

I am having Arduino Uno, SIM800 GSM module and PZEM 004T, 100 A module.
I want to build a project to view PZEM parametrs such as Voltage, Current, Power etc. through IoT application. For this I am using Blynk application through GSM/ GPRS Module.
The problem with me is that while connecting Arduino uno with both GSM module and PZEM module, it doesn’t work together.
Instead, if any one of them is used, it works fine.
Probably I am not able to use two serial ports or can’t communicate with two hardwares.
The code is as below:


#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM800

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
#include <PZEM004Tv30.h>
 
PZEM004Tv30 pzem(11, 12);   //RX of PZEM to 12, TX of PZEM to 11
float voltage, current, power, energy, frequency, pf;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "my Auth Token";

char apn[]  = "internet";
char user[] = "";
char pass[] = "";

#include <SoftwareSerial.h>
SoftwareSerial SerialAT(6, 9); // SIM900 RX, TX with #9, #6
BlynkTimer timer;
TinyGsm modem(SerialAT);
void sendSensor(){
  voltage = pzem.voltage();
  current = pzem.current();
  power = pzem.power();
  energy = pzem.energy();
  frequency = pzem.frequency();
  pf = pzem.pf();
  Blynk.virtualWrite(V0,voltage);
  Blynk.virtualWrite(V1,current);
  Blynk.virtualWrite(V2,power);
  Blynk.virtualWrite(V3,energy);
  Blynk.virtualWrite(V4,frequency);
  Blynk.virtualWrite(V5,pf); 
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  delay(10);
  // Set GSM module baud rate
  SerialAT.begin(9600);
  delay(3000);
  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  modem.restart();
  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");
  Blynk.begin(auth, modem, apn, user, pass);
  timer.setInterval(10000L, sendSensor);
}
void loop()
{
  Blynk.run();
  timer.run();
}

The output on serial monitor shows connected to Blynk cloud server, but after few seconds probably due to PZEM module run, the blynk stops and again tries to connect to cloud server. And again stops.
Can anybody please help me.
In there any way out?
I want to do the project with these available materials only.

How long does it take for your sendSensor function to complete?
Have you tried just pulling one parameter from the PZEM and sending it to Blynk?

Pete.

No any parameter value is getting displayed in blynk app.
I tried putting serial.print command in sendSensor() function like below:

Serial.print("Voltage: ");
voltage = pzem.voltage();
Serial.println(voltage);

On serial monitor, the output is giving “Voltage: 230.4” but then afterwards it again searches for connection to blynk-cloud.com and then it stops. Actually, the app project gets disconnected and blynk application doesnot display any value.

I don’t really understand what you are saying, and it certainly doesn’t answer these questions…

Pete.

I have used following code :

Serial.print("Voltage: ");
voltage = pzem.voltage();
Serial.println(voltage);

The serial monitor displays the output voltage but the blynk application does not show the voltage.
The sendSensor function probably takes 3-4 seconds to complete as it is reading values from PZEM module.

I tried pulling one parameter (Voltage) as below code:

Serial.print("Voltage: ");
voltage = pzem.voltage();
Serial.println(voltage);

But the voltage data didn’t go to blynk app, rather it got disconnected from blynk server and started reconnecting to blynk-cloud.com.

Well, the lines of code you’ve shown above don’t have any Blynk.virtualWrites in them.

Pete.

Dear Sir,
My code was as below:

void sendSensor(){
Serial.print("Voltage: ");
voltage = pzem.voltage();
Serial.println(voltage);
Blynk.virtualWrite(V0,voltage);  
}

On serial monitor, the output is giving “Voltage: 230.4” but then afterwards it again searches for connection to blynk-cloud.com and then it stops. Actually, the app project gets disconnected and blynk application doesnot display any value.

Do you solve the problem?
My project have same issue

@Fandi_Ahmad my advice would be to create a new topic and explain fully what hardware and code you are using, and what results you are seeing.

As you can tell from the topic above, getting valid information out of @sashikant to help him with his problem was very difficult!

Pete.