ESP8266 weird wifi issues

I’ve been playing around with some ESP8266 modules and esphomelib/esphomeyaml (brilliant btw. check it out here: https://esphomelib.com/ @OttoWinter did some great work) to make some custom sensors to report using MQTT with autodiscovery.

The boards seem to keep disconnecting my wifi, but the weird thing is if I use my laptop to keep pinging the boards they work just fine. As soon as I stop the boards are ether stable or starts to disconnect/reconnect again.

I don’t have any issues with other devices on my wifi network (Ubiquiti Unifi) and I’m in the dark regarding why it happens.

Does anyone have similar issues with these boards? I don’t think its software related.

I had similar issues, mine were caused by the “smart connect” band steering of my Asus AP’s.
Maybe you can try to setup a separate 2.4Ghz network and make sure it’s set to a static channel and try to put it on 20Mhz instead of 20/40 auto and see how that works.

Best regards,
Michael

I have separate 2.4/5ghz networks and 2.4ghz is setup for slow/old network stuff with max compatibility with HT20.
Channel is set to auto, but never seem to change. I have 2 AP’s.
I suspect the ESP8266 modules might be defective and will try to change the hardware in near future with higher quaility boards.

I had similar issues using ESPEasy it turned out all the disconnects and lack of web server connection was duplicated ID number between one ESP and another, im not to sure how esphomelib asks for an ID or if it does at all but maybe there is something similar.

Have you tried with just one ESP on the network.

Thanks

@frank451 That’s probably not it (esphomelib makes sure hostnames are unique automatically).

I spent a few hours yesterday trying to debug the issue with different debug levels, mqtt configurations and WiFi sniffers and from what I could tell the issue seems to be very low-level somewhere in the (lightweight) IP stack. Using https://github.com/platformio/platform-espressif8266.git as esphomeyaml: platform: has helped me improve the reliability considerably, but I’m still not 100% sure what might be the cause.

1 Like

I’ve swapped 2 modules with some expensive Adafruit stuff that where in stock - could not wait :slight_smile:
One 1½ hour ago and it’s still stable (I’m checking with “binary_sensor platform status”) the other one just now.
I’ll report back in a few days and will probably add another one in the meantime.

Esphomelib&yaml is good stuff :blush:

Looking good so far:

Esp1 (workshop) - a few disconnects but way better than before:
esp1

Esp2 (shed outside) - way better:
esp2

Esp3 (bedroom - new) - some disconnects but I suspect wifi coverage is not that good where it’s currently placed:
esp3

Reliability is still a bit on/off. Some modules are stable for some time and then freak out etc. without any good reason and the other way around.
I’ve found an article with esp8266 troubleshooting and in the comments some mention mounting capacitors different places.
Have anyone had success with that?

Btw. I’m powering my modules via a USB adaptor.

Good to see that the better modules are making such a difference.

Personally, I’ve also had this issue with ~10 disconnects per day and I don’t really worry about it that much. The “status” that’s shown in the front-end is triggered even when the ESP disconnects for a mere second from WiFi. Even if it reconnects within a second. Of course such frequent reconnects as you were previously seeing are not good and might lead to some data not being published/lost.

On the other hand, I mean even on my phone and laptop that have a dedicated WiFi chipsets and are highly optimized, I’m still seeing reconnects a few times a day. Usually you won’t notice these reconnects, but if you’re developing android root stuff and looking at the logs often, you would be surprised how often this happens. So I think even with the best setup, 100% connection times are impossible.

The problem I have with this setup is consistency.

If the modules always lost connection every 2-3 minuttes fine, but when I don’t change anything other than ether reboot the module (power off-on) or just ping them all the time and they are suddenly stable that a bit annoying. It could also be the other way around.

I don’t expect them to run 24/7 without some disconnects as long as I can expect them to keep working that way.

Here’s an example of a module that where power-cycled yesterday. No network settings or anything where changed:
1

Here’s an example of the stability I would expect from a module (disconnects can be a bit hard to see - there’s 6-8):
2

1 Like

Yes, good point on the consistency.

Hmmm, the fact that they work fine with constant pings is quite interesting. Maybe (I don’t know enough about the internal architecture) the WiFi module just goes into a sleep state after a while and stops working. I guess I could create artificial load on the WiFi module by just ICMP pinging our assigned WiFi IP address every few seconds.

I’ll try that, if it works I’ll put it into esphomelib.

What are you guys using to determine if the device is connected or not? I have seen at times where the device will jump in pings and possibly drop a few as it is busy doing other things. I’ll have to check a few of my logs on things to see if I can see some of mine dropping out.

It’s the MQTT last will message feature. Basically, you tell the server: publish this message if I disconnect. In the testing I’ve seen this has always been because of a socket connection error/reset due to a network hickup.

The networking stack handling other things should not really cause the last will to be published, since there’s a timeout of about 15 seconds. A socket reset however will immediately trigger the last will message to be published.

I’ve set up 2 esp32’s yesterday.

One was a replacement for an esp8266 that where unstable.
The other one a new module/sensor.
(And both seem to be stable)

I’ve noticed a different behavior with the esphomelib/esphomeyaml “status sensor” on the esp32 compared to the esp8266.
When I do an OTA update on a esp8266 all the sensors are unavailable when duing OTA as one would expect, but not on the esp32 where all sensors are still availiable even when the esp32 is rebooting (takes about 5 seconds to reconnect).
It’s not a problem, but odd. Is there a difference in how the 2 types of modules handle OTA updates or why is this? A difference in the libaries being used maybe?

I think it might be due to the reboot process of the boards. AFAIK the ESP8266 performs a full reset of the chip on a successful OTA update and closes all network sockets. I think the ESP32 does something different where it doesn’t close any sockets and just lets them time out. Ultimately, there are probably several things at play here and I don’t know enough about the underlying architecture to say something definitive.

Adding WiFi.setSleepMode(WIFI_NONE_SLEEP) into wifi_component.cpp helped me with D1M wifi instalability

1 Like

My primary issue was/is actually a bug in my wifi setup (Ubiquiti Unifi).
I’ve enabled fast roaming on 1 of my 3 networks.
Eventhough my esp modules is not connected to this network it made the connection unstable and i’ve disabled the option.
I haven’t had any major instability issues after this.

1 Like

@OttoWinter I’ve recently hooked up an ESP8266 and am also experiencing frequent disconnects repeatably every 5 minutes. My esphome yaml config is v1.10.1, any ideas?

Also referencing - ESP8266 weird wifi issues

SNAG-0000-20190119 SNAG-0002-20190119 SNAG-0003-20190119 SNAG-0004-20190119

After self diagnosing the issue, it appears as though the use of the Native API for esphomelib cannot be used in conjunction with MQTT. It may or may not be related to the warning posted here after step 9 - https://esphomelib.com/esphomeyaml/components/api.html#migrating-from-mqtt-to-native-api-setup-in-home-assistant

In my case the 5 minute recurring disconnects were the NodeMCU restarting every 5 minutes due to not detecting a connection to the Native API. So I ended up ditching MQTT and used the Native API.