Blynk.connected() randomly throws false

I am using ESP8266 chip. Everything worked successfully for a month but all of sudden Blynk.connected() started giving false randomly.

I tried all possible ways to restart ESP, turn off and on power connection but returns false randomly.

I purchased brand new ESP8266 and everything works fine there. I am failing to understand why is it throwing false randomly after a month.

Need urgent help on this one if anyone has faced this problem.

Can you show your code to look in detail?
Are you using local or cloud server?

What does your serial monitor say?
What does adding #define BLYNK_DEBUG give you?

Pete.

#include <SimpleTimer.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

SimpleTimer timer;
char auth[] = "XXX";
char ssid[] = "XXX";
char pass[] = "XXX";

void restartESP(){
  delay(3000);
  ESP.restart(); 
  delay(5000);  
}


void checkBlynkConnection() {
  if (WiFi.status() == WL_CONNECTED){      
    if(!Blynk.connected()){
        Blynk.connect(); 
    }
  }else{
    restartESP();
  }
}


void setup()
{
  Blynk.begin(auth, ssid, pass); 
  timer.setInterval(60000L, checkBlynkConnection); //check every minute
}

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

Unfortunately, not able to view serially unlike test NodeMCU as I have connected to other board - Kind of production ESP8266. I have given code above.

Any other way to view logs directly - may be store something remotely on cloud?

What happens if you put the code on a regular NodeMCU and take your production device offline?

Does it connect?
If not, what does the serial monitor say?

Pete.

With NodeMCU everything is working fine. Only few ESPs are giving such issues.
As shown in snapshot started two ESP8266 with same code but different token for comparison - Testing 4.1 remains very unstable and keeps restarting while Testing 6.1 is very stable and works perfectly fine.

Have you checked power supplies and RSSI values that the boards are reporting?
What happens if you swap the boards so that 4.1 becomes 6.1 and vice versa, is it the actual board itself?
Have you examined them under a magnifier or microscope for physical problems?

Other issues could be network related, a lack of available DHCP IP addresses or reaching the maximum number of Wi-Fi connections for your router.
If you have multiple access points are all devices connecting to the same access point, or different ones?

Pete.

Thank you so much for helping on this one.

Have you checked power supplies and RSSI values that the boards are reporting?
[Vishal] - No haven’t checked that. But both have similar power supply. No difference technically which rules out this issue, I think.

What happens if you swap the boards so that 4.1 becomes 6.1 and vice versa, is it the actual board itself?
[Vishal] - I will try this out. Good simple suggestion.

Have you examined them under a magnifier or microscope for physical problems?
[Vishal] - No.

Other issues could be network related, a lack of available DHCP IP addresses or reaching the maximum number of Wi-Fi connections for your router.
[Vishal] - I have investigated router but this not the problem. I have very good huawei 2.4 Ghz router

If you have multiple access points are all devices connecting to the same access point, or different ones?
[Vishal] - I have one access point. Testing at home :slight_smile:

I’m not suggesting that your router isn’t good, but if it’s been configured to use a small DCHP address pool then it it could quickly reach a point where it has too many connected devices, especially if addressed within that pool have been reserved for certain devices where you want them to have fixed IP addresses.
Believe me, some Blynkers have spent days trying to figure out why a device won’t connect in some circumstances, only to realise that they ran out of DHCP assigned IP addresses in some situations (when the wife and kids were come and their phones & tablets all connected to the network for example).

Pete.

I have HG630 V2 Home Gateway. I did check WLAN Settings but that’s not the issue in my case.