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!
}
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)?
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.
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.
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.)
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
My URL is: https://dl.espressif.com/dl/package_esp32_index.json =>I will update this
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)