Blynk with Wemos d1 R2 V2.1 (esp8266) goes online and offline repeatedly

Thank you for you help.
I have tried the code and seen the result in serial monitor.
Here is the result

"[7032] Connecting to blynk-cloud.com:80
[7303] Ready (ping: 87ms).
[902539] Heartbeat timeout
Starting reconnection timer in 30 seconds…
Attempting reconnection #1
[932840] Connecting to blynk-cloud.com:80
[933061] Ready (ping: 94ms).
Starting reconnection timer in 30 seconds…
Attempting reconnection #2
[1208664] Connecting to blynk-cloud.com:80
[1209019] Ready (ping: 166ms).
[1642136] Heartbeat timeout
Starting reconnection timer in 30 seconds…
Attempting reconnection #3
[1672437] Connecting to blynk-cloud.com:80
[1677438] Connecting to blynk-cloud.com:80
[1677665] Ready (ping: 100ms).
[1975892] Heartbeat timeout
Starting reconnection timer in 30 seconds…
Attempting reconnection #4
[2006193] Connecting to blynk-cloud.com:80
[2011194] Connecting to blynk-cloud.com:80
[2014418] Ready (ping: 141ms).
[2116728] Heartbeat timeout
Starting reconnection timer in 30 seconds…
Attempting reconnection #5
[2147029] Connecting to blynk-cloud.com:80
[2148272] Ready (ping: 180ms).
[2187558] Heartbeat timeout
Starting reconnection timer in 30 seconds…
Attempting reconnection #6
[2217859] Connecting to blynk-cloud.com:80
[2218153] Ready (ping: 96ms).
[2656357] Heartbeat timeout
Starting reconnection timer in 30 seconds…
Attempting reconnection #7
[2686658] Connecting to blynk-cloud.com:80
[2686885] Ready (ping: 126ms).
[2874698] Heartbeat timeout
Starting reconnection timer in 30 seconds…
Attempting reconnection #8
[2905227] Connecting to blynk-cloud.com:80
[2906757] Ready (ping: 100ms).
[3092044] Heartbeat timeout
Starting reconnection timer in 30 seconds…
Attempting reconnection #9
[3122345] Connecting to blynk-cloud.com:80
[3122574] Ready (ping: 116ms).
Starting reconnection timer in 30 seconds…
Attempting reconnection #10
[4138587] Connecting to blynk-cloud.com:80
[4140909] Ready (ping: 1215ms).

It has connected for 10 times in one hour.

So, now you can see that your connection isn’t stable.
You also can see that the ping is high
this is mine
Réponse de 45.55.96.146 : octets=32 temps=105 ms TTL=49
Réponse de 45.55.96.146 : octets=32 temps=105 ms TTL=49
Réponse de 45.55.96.146 : octets=32 temps=104 ms TTL=49
Réponse de 45.55.96.146 : octets=32 temps=105 ms TTL=49

Your ping times seem to vary dramatically, so I guess you might be getting dropouts on your internet connection, maybe because of a contention issue?
Or, someone else in your household may be hogging the bandwidth (a bored teenager maybe?).

Have you tried rebooting your router etc?

Pete.

1 Like

Netflix :stuck_out_tongue_winking_eye:

My router reboots every day and my families hardly use the wifi .
Is it possible that the distance between the router and arduino board is too far which causes the connection problem ? or the router is broken ?

You have to get the signal strength

    Signal = WiFi.RSSI();
    Serial.print("Signal ");
    Serial.println(Signal);

I think that I had found the problem.
I used another board with the same code and put it closer to the AP.
It worked very well and keeping connecting with the server.
Then I thought that I put my original board in the metal box and it’s about 25m to the AP.
After I opened the cover of the metal box , it works very well in these two days.

I really appreciate for your help.
Thank you!!

Yes , it’s a Faraday cage :scream:

I have to change the case to plastic material. :grin: :grin:

Yes it should be better :joy:

Or change to a D1 Mini pro with an external antenna (just don’t forget to move the zero ohm resistor).

Pete.

2 Likes

I got it ! Thank you !! :blush: :blush:

You can try that

He wasn’t kidding when he said he want an expert!
The problem is that with a metal box you really need screened (coax) cable between the board and the outside of the box, then a well designed antenna that’s going to be waterproof. Like this:

Pete.

Yes but, you can solder a coax cable too :stuck_out_tongue_winking_eye:

I have changed the Wemos R1 V2.1 to Wemos mini pro . Hoping that it can work well.

That antenna will work better if the ground connection is in contact with the metal box, the box will act as a ground plane then.
But, if you’re going to drill a hole in the box to mount the antenna then pit it on one of the sides or the bottom to stop water getting in when it rains.

Pete.

I use the antenna as the picture . Do you mean that I can use the SMA to lock on the box ? I have drilled a hole on the side of the box ! I use it indoor so there is no water problem.

Yes, there should be some locknuts and washers with the antenna. Drill a hole and pass the brass bit through it then put the locknut and antenna on. Make sure you clean-up the area around the hold so that the brass part gets good electrical contact with the box.

Pete.

Thank you , sir :blush: :blush:. I will try it.