I have problem with connection to blynk

I have a problem with my project it always disconnect and connect and I use a timer for that and it not work it still disconnect and connect .What is wrong? Need some one help my code as below

#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

SoftwareSerial chat(D5, D6); // RX, TX

String a ;
String b ;
String c ;

int val1 = 850 ;
int val2 = 450;
int val3 = 650;


char auth[] = "cbb82ece3298xxxxxxx72cc0cc452";
char ssid[] = "TEX_HOME";
char pass[] = "20xxxxx18";

BlynkTimer timer;

void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  
  chat.print("Question1");
  a = chat.readString(); 

  chat.print("Question2");
  b = chat.readString(); 

  chat.print("Question3");
  c = chat.readString();
  
  Blynk.virtualWrite(1,a); 
  Blynk.virtualWrite(2,b);
  Blynk.virtualWrite(3,c);
   
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  chat.begin(4800);
  delay(10);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
  
}

How to solve this problem ? thank you very much

I am not familiar with these commands… however they look suspiciously like they are holding up things while awaiting input… so basicly you are killing the connection with a blocking command.

I connect nodeMCU esp8266 with arduino mega 2560 for more analog input pin and send data . I use Arduino mega 2560 to collect analog data and then I send all data to NodeMCU for wifi connecttion . so if it is a blocking command What is the better way to solve this problem. I have only arduino mega2560 and NodeMCUesp8266 and I need to send data from arduino to NodeMCU for wifi connection . Please help me . Thank you very much.

Try this

I think that is not a point. Because I try only send Blynk.virtualWrite code It still occur . It still disconnect and connect . The difference of two case is ping time . What wrong with it ? Please help. The new code as below

#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>



int val1 = 850;
int val2 = 450;
int val3 = 650;


char auth[] = "cbb82ece329xxxxxxxxx72cc0cc452";
char ssid[] = "TEX_HOME";
char pass[] = "20xxxx018";

BlynkTimer timer;

void myTimerEvent()
{
  Blynk.virtualWrite(1,val1); 
  Blynk.virtualWrite(2,val2);
  Blynk.virtualWrite(3,val3);  
}

void setup()
{
  Serial.begin(9600);
  
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, myTimerEvent);

}

void loop()
{
  
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
  
}

Well that first ping time was absolutely atrocious… and would have caused issues anyhow.

Perhaps you are dealing with power related issue, the MCU browns out when running the WiFi… How are you powering your NodeMCU? Has it ever worked before, or is this your first time using it?