Connection loss to blynk after approx. 5 to 10 minutes

Hi all,

I’m a beginner and want to connect ESP32 via Wi-Fi to bylnk cloud with very generic code. Blynk Libary is v1.2.0.

After 5 to 10 Minutes device goes offline. There seams to be a connection loss.

In the serial monitor looks like this:


[2632] Connected to WiFi
[2632] IP: 192.168.1.139
[2632] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.2.0 on ESP32

 #StandWithUkraine    https://bit.ly/swua


[2642] Connecting to blynk.cloud:80
[2701] Ready (ping: 14ms).
[177806] Heartbeat timeout
[182788] Connecting to blynk.cloud:80
[201294] Connecting to blynk.cloud:8080
[219800] Connecting to blynk.cloud:80
[238307] Connecting to blynk.cloud:8080
[256813] Connecting to blynk.cloud:80
[275319] Connecting to blynk.cloud:8080
...

Sketch looks like this

/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID           "TMPLxxxxxxxxxxxxj"  
#define BLYNK_TEMPLATE_NAME         "Quickstart xxxxxxxxxxx"
#define BLYNK_AUTH_TOKEN            "vV6LYUGcMH00BjJg0FJoS-xxxxxxxxxxx"

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define BLYNK_HEARTBEAT 20 // defaults to 10s
#define BLYNK_TIMEOUT_MS 5000UL // defaults to 2000UL


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxxxxxxxxxxxxx";
char pass[] = "xxxxxxxxxxxxxxxx";

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  // You can also specify server:
  //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

Hardware: AZ-Delivery ESP32 DevKitC V2 , Model: ESP32-WROOM-32

Some tipps for me to solve this?

BR Parte

This isn’t exactly “very generic code”

When you go to the web console > Device > Device info screen what value do you see for “HEARTBEAT INTERVAL” in the bottom left of the data that is displayed?

Have you tried an SSL connection, using #include <BlynkSimpleEsp32_SSL.h> rather than #include <BlynkSimpleEsp32.h> ?

Are you connecting via a regular domestic router, or via some other method (Wireless hotspot, work/school wifi etc)?

Pete.

Hi Pete, thanks for help!

in the device info screen the 20 sec can be seen. (This was my first debugg attempt to decrease this value from 45 to 20 sec)

I will try the SSL thing.

Connecting via ordenary O 2 home router. (without special security settings)

Thx Parte

Same behavior with

#include <BlynkSimpleEsp32_SSL.h>

I’m wandering why the heartbeat “pings” cannot be seen in the serial monitor.

Decreasing the heartbeat interval makes things worse, not better.
This is the frequency at which the server and device perform a handshake, and if this fails it takes the device offline.
However, as you aren’t doing anything in your code that would cause it to be inactive for periods of 20 seconds then it shouldn’t be an an issue.

I am confused by the serial monitor showing it alternating between port 80 and 8080 with a non-SSL connection. What do you see with an SSL connection?

I think the first thing I’d try is rebooting the Sky router, and any other wireless access points/repeaters you have attached to it.

Do you have the 2.4 and 5GHz SSIDs set to the same SSID name?
ESP32s can only work with 2.4GHz, so having them the same may cause issues.

Pete.

[2635] Connected to WiFi
[2635] IP: xxxxxxx
[2635] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.2.0 on ESP32

 #StandWithUkraine    https://bit.ly/swua


[2645] Connecting to blynk.cloud:443
[4110] Certificate OK
[4133] Ready (ping: 22ms).
[339256] Heartbeat timeout
[344238] Connecting to blynk.cloud:443
[351042] Secure connection failed
[351042] Connecting to blynk.cloud:443
[358046] Secure connection failed
[358046] Connecting to blynk.cloud:443
[365048] Secure connection failed
[365048] Connecting to blynk.cloud:443
[372051] Secure connection failed
[372051] Connecting to blynk.cloud:443
[379054] Secure connection failed

=>ok will try to reboot, (but trying around with this issue since a while)

Yes, I could deactivate the 5 GHz part, if this could help.

Thx again!

hm unfortunatly device connection still went offline after 10 min.
including

  • 5 Ghz are deactivated within the router
  • router reboot

How are you powering your ESP32?
Have you tried a different USB cable, powering from a phone charger rather than a computer etc?

Pete.

Yes I have tried differed things

  • from laptop
  • from usb charger
  • from 5V power supply direct connected to board

Do you have a different ESP32 device you could try?

Pete.

I have tried it completly without usb cable the a 5V power supply connected directly, so I think it’s not the usb cable. I also ordered and tested a 2nd ESP to exclude a one time ESP problem.

Have you tried connecting to the internet in a different way, maybe via a mobile phone hotspot, or a friend’s WiFi network?

Pete.

the mobile hotspot did not work. I will try a different WiFi with the next opportunity. Thanks a lot for your thoughts so far. (P.S. I had an Arduino uno+ESP8266 + old blynk setup running in the past very well.)

What version of the ESP32 core do you have installed via Boards Manager in the IDE?

Pete.

Hi Pete,
in the IDE board manager there is: esp32 by Espressif Systems Version 1.0.6

At a friends WiFi network already connected and online to blynk for >20 minutes. :crazy_face:

Maybe it’s getting warmer. …?

Wow! that’s a very old version. The current release is 2.0.9

Does the Boards Manager screen allow you you to update to 2.0.9 ? If not then I suspect you might not be using the correct URL in File > Preferences > Additional Boards Manager URLs

The correct URL is:
https://espressif.github.io/arduino-esp32/package_esp32_index.json

Pete.

1 Like

Good morning!

No.

My URL is:
https://dl.espressif.com/dl/package_esp32_index.json =>I will update this :face_with_hand_over_mouth:

At a friends Wi-Fi network I was facing the same problems. (Only the first run with 2 h online was very promising but also ended in going offline) ->(still with the old core)

New core version will be tested very soon.

Thx!!!

1 Like

With updated URL and ESP core 2.0.9 it looks very promising :partying_face:
Online since 3 hours :love_you_gesture:

Thank you so much Pete! :heart:

1 Like

mh unfortunatly there are still a lot of connection interruptions, but now there is a reconnection