My ESP8266s are disconnecting and not reconnecting? Only fix is to restart the router

I’ve got 4 8266s running around the house all doing different things, they’ve been running fine for months 6m+. But the last few weeks they’ve been going offline and not reconnecting.

Funny enough doing a forced restart (pulling power) doesn’t solve the issue, only restarting my router solves the issue.
The code on the ESP still seems to run but it’s just lost the wifi connection.

Which leads me to believe it’s actually a router/connection issue, I’ve flashed the latest firmware to the router and it hasn’t helped. (TP-LINK D7)

My thoughts are at this stage.

  1. Too many requests go up at once and Blynk is locking me out? (Although I use the timers in all my code, I wonder if they all send together I will get a problem?)
  2. Router issue.
  3. Someone is trying to hack my ESPs from outside and shutting them down somehow.

Does anyone have any tips on where to start diagnosing this?

I run the wemos pro boards, and code has been running for months without a hitch, all of them crash at the same time (ie last seen/offline at 5:55am)

Thanks.

Unfortunately I have often ran into similar issues as various routers I have used in the past got older (and/or my WiFi usage increased). They are basically mini computers and often require that universal “turn off and on again” :stuck_out_tongue:

image

The router is only a year or so old and it’s happening quite consistently once a day now, it’s very odd. Did you go and get another router to solve the issue?

Yes, sometimes it got so bad that I did have to replace the router (I replaced one make/model about four times on warranty).

Now I just stick with the one provided by my internet provider as it is goodish quality and i don’t have to pay for replacements… but even then it has needed to be replaced twice in the last three years due to repeating lockup issues…

The current one has been going strong for about a year, only requiring a reboot every few months or so.

Did you have any other devices hang at the same time, all my other devices seem to run fine. (phone, laptop etc)

My solution in the short term might be my Pi logging in and restarting the router when I don’t get a response from my ESPs.

Somewhat random at times… sometimes only WiFi, other times it affect wired and Wifi. Sometimes only DNS related issues while local network stuff keeps working, other times it was full network failure.

And, yes, I have even noticed one Blynk project acting up (disconnecting) while I was experimenting with another within relative close proximity (same workbench or nearby)… only to later stabilize and work alongside each other without issues.

So basicly welcome to technological equivalent of having multiple conversations in a busy nightclub… may or may not get easier as the participants get more loaded :stuck_out_tongue: (at least based on my ancient memories of such activities :smiley: )

Not Blynk specific and unlikely to be fixed with a simple update or command.

BTW, are you using the built in or external antennas?.. and if external have you done the required jumper/resistor switchover?

I agree not a Blynk issue, assuming it’s not some sort of flood issue. Although is there a way to check if I get disconnected because of a flood issue? (sometimes my sloppy code will force one).

I’m not using the external antenna, I did a range test and they are pretty good.

I only have 1 esp on battery power and that goes to sleep. I have a sneaky feeling that particular one causes issues crashing the rest of them, it has in the past when the battery died. (I think). Maybe my router doesn’t like being connected/disconnected all the time.

What were you doing trying to have a conversation in a nightclub, I also have a distant memory of reaching for the lasers.

Only way I know of is is the device is also hooked up to the Serial Monitor, then it might give a warning message via BLYNK_PRINT

That might be the case as when it wakes it will always be going through the reconnection process with the router (particularly with DHCP) and that might cause hiccups with the rest of the networking? Just a random guess.

Cuz can’t sing, can’t dance and too fat to fly :stuck_out_tongue:

Show us your code.

#define BLYNK_PRINT Serial

#include <SPI.h>


#include <OneWire.h>
#include <DallasTemperature.h>

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

#define ONE_WIRE_BUS D4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress tempSensor1 = { 0x28, 0xFF, 0x60, 0x96, 0x90, 0x15, 0x04, 0xEB }; // Temperature probe #1

int temperature1;

char auth[] = "XXXXX";

char ssid[] = "XXXXX";
char pass[] = "XXXXX";


BlynkTimer timer;

// A0 Stuff

unsigned int raw=0;
float volt=0.0;

// Time to sleep (in seconds):
#define SLEEP_LENGTH 600


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

  Blynk.begin(auth, ssid, pass);

  sensors.begin();
  sensors.setResolution(tempSensor1, 10);

  // timer.setInterval(5000L, sendSensor1);

  // timer.setInterval(5000L, voltageBatt);

  

// A0 Stuff

  pinMode(A0, INPUT);
  


}

void loop()
{
  Blynk.run();
  timer.run();
  sendSensor1();
  voltageBatt();

  ESP.deepSleep(SLEEP_LENGTH * 1000000,WAKE_RF_DEFAULT);   //try the default mode
  delay(100);
}

void sendSensor1() {
  sensors.requestTemperatures();                  // Polls the sensors
  temperature1 = sensors.getTempC(tempSensor1);   // Stores temp in F. Change getTempF to getTempC for celcius.
  Blynk.virtualWrite(1, temperature1);            // Send temp to Blynk virtual pin 10
}

void voltageBatt() {

  raw = analogRead(A0);
  raw=raw+50;
  volt=raw/1023.0;
  volt=volt*4.2;
  Blynk.virtualWrite(2, volt);
  
}

1st I had to format your code for proper viewing… use this method next time please…

Blynk - FTFC

Your code does have issues… not sure if they are causing the router to have issues as well… but probably doesn’t help :stuck_out_tongue:

Running your two function loops this way (in the void loop() ) means they would normally run hundreds of times a second… and that could cause timeouts and flooding… instead you would want them to be ran as timed functions (as it seems you did have at one time?)

… But I said normally… as the immediately following sleep command put a halt to that anyhow. And the whole process happens very quickly… I am not sure how you even get any reliable temp readings, as I found mine need a few ms to provide such.

In fact, I believe you could put all of these commands directly in the tail end of your setup() and they would have the same effect.

PS, an analog pin by design is an input… so this command is completely unnecessary.

Good points, most of my code is cut and paste hence why I have arbitrary code around.

I was under the impression when the .requestTempratures was called it ran a number of readings and averaged them to get a good accurate reading?

I think I did have timed functions at some point before I had the sleep, I didn’t want it awake any longer than necessary.

Sorry about the code, I thought it was the Preformatted Text option. Wonder why there’s no option for that in the tools panel?

You, me and everyone else wonders that as well :stuck_out_tongue_winking_eye: I think it is just a very low priority when members like me can easily fix and teach others how for the future :wink:

How up to date is your blynk firmware on the esp devices, you say it worked well for 6+ months then suddenly started hanging?

The code can’t change itself on them so either blynk libraries/server changed or your router is tired of your requests :stuck_out_tongue:

6 months is a long time in blynk since it’s constantly developed, do you use local server or the cloud? None the less, could be outdated code on the esp devices?