BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk on wemos D1 R2 - disconnections

Hi,

I’m quite new to blynk, and hope not asking a too stupid question.
I tried to develop my first blynk app, and I’m facing heratic connections.
I saw sometimes status on my app as connected, but it’s often disconnected, saying “offline since xxx”

I can’t understand why, and any help would be appreciated.
my config is as follows

  • wemos D1 R2
  • IDE : Arduino 1.8.9
  • software based on “ESP8266_standalone_SSL” example, just modified auth, ssid & passwd
  • connection via wifi & ADSL (so quite good)
  • in Arduino IDE, I selected
    • harware (“type de carte”, in french) : Lolin (wemos) D1 R2 & mini
    • hardware driver : “esp8266 by ESP8266 Community” version 2.5.0-beta2
    • Blynk library version 0.6.1
  • I tryed 2 power supplies : USB port & 12V batteries
    My phone is an iphone running iOS 12.2
    and, to be simple, I’m using Blynk server

If needed, here is my code :

#define BLYNK_DEBUG
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266_SSL.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "[my auth]";

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

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

  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
}

Any help would be appreciated, even RTFM …

Thanks
Laurent

Try without the SSL option, the ESP8266 is not always up to handling that extra encryption.

https://examples.blynk.cc/?board=WeMos%20D1&shield=ESP8266%20WiFi&example=GettingStarted%2FBlynkBlink

Use this library instead… include <BlynkSimpleEsp8266.h>

Also, please format any posted code here as stated in the Welcome Topic (there is your RTFM part :stuck_out_tongue_winking_eye: ) … it helps it look better for easy reading. I fixed your post.

Blynk%20-%20FTFC

And in case you didn’t know… this line will drastically slow down your sketch, so comment it out when not needed.

http://docs.blynk.cc/#blynk-firmware-debugging-define-blynk_debug

Thanks, Gunner, for that fast answer
ok for the format : this is my first step on the learning curve.
I’ll try our advices this evening.
This morning, I just watched to the logs (in order to compare with your advices), after changing serial speed to 115200

08:21:44.790 -> [2575] Connected to WiFi
08:21:44.790 -> [2575] IP: 192.168.0.41
08:21:44.790 -> [2575] 
08:21:44.790 ->     ___  __          __
08:21:44.845 ->    / _ )/ /_ _____  / /__
08:21:44.845 ->   / _  / / // / _ \/  '_/
08:21:44.845 ->  /____/_/\_, /_//_/_/\_\
08:21:44.845 ->         /___/ v0.6.1 on ESP8266
08:21:44.845 -> 
08:21:49.817 -> [7598] NTP time: Tue Mar 26 07:21:46 2019
08:21:49.817 -> [7598] Connecting to blynk-cloud.com:443
08:21:50.771 -> [8559] Certificate OK
08:21:50.771 -> [8560] <[1D|00|01|00] [my auth]
08:21:50.811 -> [8590] >[00|00|01|00|C8]
08:24:55.524 -> 

Well, it worked, I got communication between my iphone and my wemos, until 08:46 AM when my Blynk app said my device went offline.
No message on Serial port after this.

So I resetted wy wemos, connection was up again, and I got more messages (strange…)

08:55:07.865 -> [4074] Connected to WiFi
08:55:07.865 -> [4075] IP: 192.168.0.41
08:55:07.865 -> [4075] 
08:55:07.865 ->     ___  __          __
08:55:07.865 ->    / _ )/ /_ _____  / /__
08:55:07.865 ->   / _  / / // / _ \/  '_/
08:55:07.968 ->  /____/_/\_, /_//_/_/\_\
08:55:07.968 ->         /___/ v0.6.1 on ESP8266
08:55:07.968 -> 
08:55:10.400 -> [6597] NTP time: Tue Mar 26 07:55:07 2019
08:55:10.400 -> [6597] Connecting to blynk-cloud.com:443
08:55:11.405 -> [7579] Certificate OK
08:55:11.405 -> [7580] <[1D|00|01|00] [my auth]
08:55:11.405 -> [7609] >[00|00|01|00|C8]
08:55:11.405 -> [7609] Ready (ping: 3ms).
08:55:11.405 -> [7609] Free RAM: 14040
08:55:11.405 -> [7609] >[14|00|01|00|14]
08:55:11.405 -> [7611] >pm[00]4[00]out[00]17[00]in[00]5[00]out
08:55:11.465 -> [7676] <[11|00|02|00]Hver[00]0.6.1[00]h-beat[00]10[00]buff-in[00]1024[00]dev[00]ESP8266[00]build[00]Mar 25 2019 23:14:59[00]
08:55:11.489 -> [7706] >[00|00|02|00|C8]
08:55:11.551 -> [7760] >[14|1E]b[00|05]
08:55:11.551 -> [7761] >ar[00]17
08:55:11.641 -> [7828] <[14|1E]b[00|09]aw[00]17[00]620
08:55:12.559 -> [8760] >[14|1E]b[00|05]
08:55:12.559 -> [8761] >ar[00]17
08:55:12.635 -> [8828] <[14|1E]b[00|09]aw[00]17[00]622
08:55:13.559 -> [9761] >[14|1E]b[00|05]
08:55:13.559 -> [9761] >ar[00]17
08:55:13.635 -> [9828] <[14|1E]b[00|09]aw[00]17[00]624

Hi again,
tonight, I tried to disable SSL (but keep #define BLYNK_DEBUG : one change at a time)
it worked for 1 minute, then disconnected

20:33:30.914 -> [5074] Connected to WiFi
20:33:30.914 -> [5074] IP: 192.168.0.41
20:33:30.914 -> [5075] 
20:33:30.914 ->     ___  __          __
20:33:30.914 ->    / _ )/ /_ _____  / /__
20:33:30.914 ->   / _  / / // / _ \/  '_/
20:33:30.914 ->  /____/_/\_, /_//_/_/\_\
20:33:30.914 ->         /___/ v0.6.1 on ESP8266
20:33:30.914 -> 
20:33:30.914 -> [5081] Connecting to blynk-cloud.com:80
20:33:30.960 -> [5119] <[1D|00|01|00] [my auth]
20:33:33.841 -> [8001] >[00|00|01|00|C8]
20:33:33.841 -> [8001] Ready (ping: 2880ms).
20:33:33.841 -> [8001] Free RAM: 46832
20:33:33.841 -> [8002] >[14|00|01|00|14]
20:33:33.841 -> [8002] >pm[00]4[00]out[00]17[00]in[00]5[00]out
20:33:33.926 -> [8068] <[11|00|02|00]Hver[00]0.6.1[00]h-beat[00]10[00]buff-in[00]1024[00]dev[00]ESP8266[00]build[00]Mar 26 2019 20:29:45[00]
20:33:34.346 -> [8525] >[14|1E]b[00|05]
20:33:34.346 -> [8526] >ar[00]17
20:33:34.442 -> [8593] <[14|1E]b[00|09]aw[00]17[00]453
20:33:35.372 -> [9528] >[14|1E]b[00|05]
20:33:35.372 -> [9528] >ar[00]17
20:33:35.408 -> [9595] <[14|1E]b[00|09]aw[00]17[00]454
...
20:33:40.367 -> [14524] >[14|1E]b[00|05]
20:33:40.367 -> [14524] >ar[00]17
20:33:40.406 -> [14591] <[14|1E]b[00|09]aw[00]17[00]454
20:33:40.836 -> [14990] >[14]z[B3|00|06]
20:33:40.836 -> [14990] >dw[00]4[00]0
20:33:41.358 -> [15524] >[14|1E]b[00|05]
20:33:41.358 -> [15524] >ar[00]17
20:33:41.406 -> [15591] <[14|1E]b[00|09]aw[00]17[00]454
20:33:42.681 -> [16851] >[14|1E]b[00|05]
20:33:42.681 -> [16851] >ar[00]17
20:33:42.763 -> [16918] <[14|1E]b[00|09]aw[00]17[00]454
20:33:43.232 -> [17409] >[14]g[D8|00|06]
20:33:43.232 -> [17409] >dw[00]4[00]1
20:33:43.354 -> [17523] >[14|1E]b[00|05]
20:33:43.354 -> [17523] >ar[00]17
20:33:43.450 -> [17590] <[14|1E]b[00|09]aw[00]17[00]456
20:33:53.370 -> [27524] <[06|00|03|00|00]
20:33:56.338 -> [30525] <[06|00|04|00|00]
20:33:59.342 -> [33526] <[06|00|05|00|00]
20:34:02.362 -> [36524] Heartbeat timeout: 36524, 17523, 33526
20:34:04.368 -> [38527] Connecting to blynk-cloud.com:80
20:34:04.402 -> [38563] <[1D|00|01|00] [my auth]
20:34:07.379 -> [41566] Login timeout
20:34:09.377 -> [43566] Connecting to blynk-cloud.com:80
20:34:09.415 -> [43593] <[1D|00|01|00] [my auth]
20:34:12.408 -> [46595] Login timeout
etc

the important message seems to be “Heartbeat timeout” …

again, still without SSL, and now without debug
result is the same, with less text

20:41:49.082 -> [10025] Connected to WiFi
20:41:49.082 -> [10026] IP: 192.168.0.41
20:41:49.082 -> [10026] 
20:41:49.082 ->     ___  __          __
20:41:49.082 ->    / _ )/ /_ _____  / /__
20:41:49.082 ->   / _  / / // / _ \/  '_/
20:41:49.082 ->  /____/_/\_, /_//_/_/\_\
20:41:49.122 ->         /___/ v0.6.1 on ESP8266
20:41:49.122 -> 
20:41:49.122 -> [10032] Connecting to blynk-cloud.com:80
20:41:51.943 -> [12866] Ready (ping: 2801ms).
20:42:12.341 -> [33297] Heartbeat timeout
20:42:14.374 -> [35300] Connecting to blynk-cloud.com:80
20:42:17.378 -> [38325] Login timeout
20:42:19.386 -> [40325] Connecting to blynk-cloud.com:80
20:42:22.405 -> [43353] Login timeout
20:42:24.413 -> [45353] Connecting to blynk-cloud.com:80
20:42:27.432 -> [48378] Login timeout
20:42:29.459 -> [50378] Connecting to blynk-cloud.com:80
20:42:32.452 -> [53403] Login timeout

These are some significant ping times (except the first one, which seems unrealistically low if using Blynk cloud).

What sort of results do you get if you ping blynk-cloud.com from your PC?

Dipping into the admin screens for your user ID shows that you (or at least your ISP) are located in Paris, so you’re in a relatively civilized (at least from a technology point of view :grinning:) part of the world.

I’m in London and ping times from my PC vary a bit, but something like is fairly normal:

Pinging blynk-cloud.com [139.59.206.133] with 32 bytes of data:
Reply from 139.59.206.133: bytes=32 time=37ms TTL=55
Reply from 139.59.206.133: bytes=32 time=36ms TTL=55
Reply from 139.59.206.133: bytes=32 time=37ms TTL=55
Reply from 139.59.206.133: bytes=32 time=36ms TTL=55

Ping statistics for 139.59.206.133:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 36ms, Maximum = 37ms, Average = 36ms

We’ll both be hitting the same Blynk cloud server in Frankfurt, so I’d expect something similar for you.

I wonder if you’re seeing issues like those described in this topic:

Pete.

1 Like

Heartbeat timeout
Login timeout
High ping

My own symptoms, solved by changing routers. You can try doing hotspots with your mobile phone, it’s a simple and quick test, you never know.

Now I’m testing with all devices, before I had continuous disconnections.

I hope you solve the problem easily. Good luck

1 Like

Thanks Pete and Saddys,
I confirm that ping values on serial are strange, and 2ms is a non-sense (I’m not on a local server)
I use the same wifi network for all my home devices (PC, tablet, mobile phones, and wemos).
Here is the ping on my PC, which seems quite normal :

Envoi d’une requête 'ping' sur blynk-cloud.com [139.59.206.133] avec 32 octets de données :
Réponse de 139.59.206.133 : octets=32 temps=22 ms TTL=53
Réponse de 139.59.206.133 : octets=32 temps=24 ms TTL=53
Réponse de 139.59.206.133 : octets=32 temps=28 ms TTL=53
Réponse de 139.59.206.133 : octets=32 temps=22 ms TTL=53

See that Paris is better than London :wink:

This morning, I added some code, which should have no link with connection, keeping in my config SSL enabled, and blynk_debug disabled. my mewos connected during 1h20min, then discnnected and reconnected automatically, and is stil up, which is my personal record.

8:10:01.124 -> [11837] Connected to WiFi
08:10:01.124 -> [11837] IP: 192.168.0.41
08:10:01.124 -> [11837] 
08:10:01.124 ->     ___  __          __
08:10:01.124 ->    / _ )/ /_ _____  / /__
08:10:01.124 ->   / _  / / // / _ \/  '_/
08:10:01.124 ->  /____/_/\_, /_//_/_/\_\
08:10:01.124 ->         /___/ v0.6.1 on ESP8266
08:10:01.124 -> 
08:10:02.149 -> [12859] NTP time: Wed Mar 27 07:09:57 2019
08:10:02.149 -> [12859] Connecting to blynk-cloud.com:443
08:10:03.018 -> [13761] Certificate OK
08:10:03.068 -> [13787] Ready (ping: 2ms).
09:32:55.473 -> [4986270] Heartbeat timeout
09:32:57.476 -> [4988274] NTP time: Wed Mar 27 08:32:52 2019
09:32:57.476 -> [4988274] Connecting to blynk-cloud.com:443
09:32:58.622 -> [4989419] Certificate OK
09:32:58.656 -> [4989451] Ready (ping: 2ms).

Nevertheless, I’ll try with my mobile phone hotspot, after next crash.

My code modification is just to make a led blink, in order to see after next disconnect if it is a connection issue (the led should go on blinking) or a harware crash (I expect the led would not blink anymore)

Here is my code :

//#define BLYNK_DEBUG
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "[my auth]"; // test wemos

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

BlynkTimer timer; // Announcing the timer
int LedStatus = false;
int LedPin    = D0;

void setup()
{
  // Debug console
  Serial.begin(115200);
  pinMode( LedPin, OUTPUT );

  timer.setInterval(1000L, LedSwitch ); //timer will run every sec 
  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
  timer.run();        // run timer every second
}

void LedSwitch()
{
  LedStatus = (LedStatus==false);       // switching led status
  digitalWrite( LedPin, LedStatus );
}

:rofl::rofl::rofl:

Maybe @GunnerTechTools should get one of these devices, he’s a cat lover :grin:

It sounds like you have a plan for taking this forward. Bear in mind that it could just be a faulty Wemos (Mewos) device that has a problem with the Wi-Fi part of the chip.

Pete.

2 Likes

he’s a cat lover :grin:

Well, I guess I wrote that before morning coffee :sleeping: !

1 Like

A quick update : Finally, it started working.
Just a few disconnections and automatic reconnection, from time to time.
I can’t understand why, which is quite frustrating, but the important thing is that I can continue exploring Blynk.
Thanks for your help