ESP32 going offline every few min


I have 2 ESP32 devices running on stock edgent sketch with indicator attached on pin 5.

If the ISP is down or the Wifi goes down, the indicator still breaths indicating the ESP32 is connected to the cloud. Whereas the app shows the device is offline. Only then i get to know that the device has lost connection.

To check this behaviour, I unplugged the incoming connection from ISP to create a scene of No internet.

The indicator breath normally indicating it’s connected to the cloud. Even after the internet is back it doesn’t come online, because it never knew it has lost connection and doesn’t try to reconnect back.

And very randomly every 1 out of 100 times it starts blinking saying no internet and connects back when the ISP is Up.

This is really strange. There is no changes made in the .h files or .ino

And the loop is absolutely clean. No delays.

Even the serial monitor shows no signs of connection. If I restart the esp32 manually, it will connect and stay connected for a while and then again goes offline. But the ESP32 doesn’t know that. Until I reboot seeing the offline status on the app.

Can you guys point me on how to solve this issue.

Posting your code might help .

Bare minimum sketch that is given in arduino examples. No changes made. Uncommented LED pin and defined pin 5 as indicator LED. No more changes or additions made.


Is there any way to force check connection status and reconnect to the cloud? This is already there in the Edgent sketch. But its not working now.

Downgrading the lib version will help? Is it a good idea to do so? I am now on the latest version. And latest ESP32 core.

I’d start by adding some debug info into void runBlynkWithChecks() in BlynkEdgent.h


void runBlynkWithChecks() {;
  if (BlynkState::get() == MODE_RUNNING) {
    if (!Blynk.connected()) {
      if (WiFi.status() == WL_CONNECTED) {
        Serial.println("MODE_CONNECTING_CLOUD"); // added
      } else {
        Serial.println("MODE_CONNECTING_NET");  // added

Just tried. But there is no output. Because it never checks for the wifi connection or internet. It just executes Serial monitor is empty. After it shows the Blynk banner on boot with connection status.

Also tried two different approachs

void check_conn() {
  if (!Blynk.connected()) {
    if(Blynk.connect()) {
    } else {
      BLYNK_LOG("Not reconnected");


void check_conn() {
  if (Blynk.connected()) {
  } else {

The above function is called by a timer (tried with 15sec, 30sec, 60sec). But no luck. If i restart the device manually then it connects back as usual and stays online for few min. Later goes offline and stays there. No change in the indicator pattern. The app shows offline.

once in a while very randomly it reconnects with the following output on serial monitor

[878621] Connecting to   ////////////// turned off wifi for testing
[878621] Secure connection failed
[883622] Connecting to
[883622] Secure connection failed
[888623] Connecting to
[888623] Secure connection failed
[891620] Not reconnected
[906620] Connecting to
[906620] Secure connection failed
[911621] Connecting to
[911621] Secure connection failed
[916622] Connecting to
[916622] Secure connection failed
[921623] Connecting to
[921623] Secure connection failed
[924620] Not reconnected
[924620] Using Dynamic IP:   ////////////// turned on wifi for testing
[924630] Connecting to
[925677] Certificate OK
[925879] Ready (ping: 200ms).
[926058] Time sync: OK
[926185] Time sync: OK

The above output is printed only if the device is working normally. If it hangs then, there will be no output on serial monitor related to blynk.

i have an switch connected that turns on a led when pressed(to see if the board is still working[testing]) and yes the led responds to the button presses. This proves that only the Blynk part is hanging.

I don’t think the couple of lines of code you’ve added prove very much. I’d add a serial print after each if statement to understand which ones are evaluating as true and which as false.


Agreed. But when it hangs, there is no output whatsoever. Serial monitor stays blank.

I added serial print along with the button presses and that prints when button is pressed.

But serial prints related to blynk stuff never prints. Like the once i added above.

As per my understanding, the runBlynkWithChecks hangs and never runs again. Thats the reason the led indicator breath normally stating the connection is successful.

I’m not really following what you’re saying here.


Blynk part of the code hangs. Rest all works. That is what i got to know.

Because even after the internet is back, it doesn’t try to reconnect.


I have the same code running on other ESP32’s fine. But only these 2 particular ones are giving issues.

Not sure is it something to do with the hardware. Let me change the modules and see if this solves the issue. I will update her.


It seems like its something to do with the hardware. The same exact code is working fine on other ESP32.

The two modules i mentioned earlier must have gone bad. Not sure.

But non blynk sketch and normal wifi connections works fine on these (bad onces).

I couldn’t come to an conclusion on what was wrong.

But there seems to be no problem in the code.