Blynk App Keeps Disconnecting and Reconnecting From Hardware

Thanks for the quick reply

I experimented the setTimeout() with this code:


#define BLYNK_PRINT Serial // uncomment it to view connection logs, comment it to disable print and save space

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
#define ESP8266_BAUD 9600       // Baud rate to communicate with ESP-01

char auth[] = "insertauth"; // auth token
char ssid[] = "insertssid";                  // WiFi SSID.
char pass[] = "insertpass";                       // WiFi password. Set password to "" for open networks.

SoftwareSerial EspSerial(2, 3); // RX, TX
ESP8266 wifi(&EspSerial);
BlynkTimer timer;

void first(){
  Serial.println("this is first");
}

void seco(){
  Serial.println("this is seco");
}

void third(){
  Serial.println("this is third");
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);                   // begin serial monitor, 9600 is recommended for ESP8266 shield setup
  delay(10);
  EspSerial.begin(ESP8266_BAUD);        // Set ESP8266 baud rate
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);  // start Blynk

  timer.setTimeout(1000, []() {
    timer.setInterval(5000L, first);
  });
  timer.setTimeout(2000, []() {
    timer.setInterval(10000L, seco);
  });
  timer.setTimeout(3000, []() {
    timer.setInterval(15000L, third);
  });
}

void loop() {
  // put your main code here, to run repeatedly:
  Blynk.run();
  timer.run();
}

and the serial output does not seem to have any overlapped prints. Do you mean that in the original code, the processor is actually taking some time to execute the things in the functions and 100ms is negligible to make any difference, so saying that the processor is available to do other things is invalid? I am kinda lost now…

The O in dO is actually an O, not zero, but I changed it to doOutput to make it easier to read.

The code works until I uncomment the line Blynk.virtualWrite(V4, doOutput); or Serial print it. But I will try to modify the calculation part and see if there is any luck.

Few years ago, I actually made something a little similar but the hardware setup is a standalone LoLin NodeMCU ESP8266 V3. The code is terrible (because I broke the rule of keeping your void loop() clean) but I don’t remember having any runtime errors