Chat freely about anything...

User avatar
By Fduch
#90801 Hi.
I met very weird behavior of ESP. I spent already 3 days trying to understand what's wrong, but couldn't find reason. I'm quite sure that I'm doing something wrong, that's why I need your help to figure it out :)
I have ESP-01 board with ESP8266. I'm using following sketch:
Code: Select all#define DEBUG_ESP_WIFI
#define DEBUG_ESP_PORT Serial

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti WiFiMulti;

void setup()
{
  Serial.begin(9600);
  Serial.setDebugOutput(true);
  delay(2000);

  WiFi.mode(WIFI_STA);

  WiFiMulti.addAP("my_wifi", "my_password");

  Serial.println();
  Serial.println();
  Serial.print("Wait for WiFi... ");

  while (WiFiMulti.run() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(500);
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  delay(500);
}

void loop()
{
  Serial.print("WiFi Status: ");
  Serial.print(WiFi.status());
  Serial.print("; is connected: ");
  Serial.print(WiFi.isConnected());
  Serial.println();

  delay(5000);
}

As soon as ESP connects to WiFi, WiFi becomes much slowlier. You can notice it by significantly slowlier response times of Google search, by random and significant drops in speed here https://www.speedtest.net (ex. 35 -> 4 -> 15 Mb/s). I have 2 phones and 2 laptops in WiFi. All of them, except of 1 laptop, is quite fine with this. But as soon as one laptop (let's call it "laptop X") connects to WiFi, all WiFi is ruined. Router is available by ethernet, it shows no errors in its logs, but all devices losses their connection to WiFi. Reconnection doesn't help. The only thing which helps is restart of router.
I was observing following scenarios:
1. Restart router, do NOT connect ESP and laptop X. Check WiFi speed on wireless devices - everything fine. Connect ESP. Check WiFi speed - it becomes slowlier. Connect laptop X - WiFi is down.
2. Restart router, do NOT connect ESP and laptop X. Check WiFi speed on wireless devices - everything fine. Connect ESP. Check WiFi speed - it becomes slowlier. Disconnect ESP. Wait for couple of minutes. Check WiFi speed - it is still slow. Connect laptop X - WiFi is down!
So, it seems like connection of ESP is changing something on router and further connection of laptop X triggers WiFi fall. I know, it sounds like black magic, but I still can not find reason of this behavior.
I thought problem can be in my router (old Keenetic Lite). I tried to establish Access Point from my Xiaomi phone. I connected to that AP from Samsung phone. This connection is stable, I checked for few hours. Then I connected ESP to the same AP - WiFi became slowlier, but still alive. After that in about 23-30 min WiFi falls. So, looks like ESP somehow affects even AP provided by phone. Righ now I'm looking for another router to test, but quite probable that problem is not in router.
I tried erasing entire flash on ESP-01 by ESPFlasher - issue didn't disappear.
I thought that problem can be in USB power supply (I'm using this adapter to connect ESP-01: https://www.aliexpress.com/item/3297133 ... 4c4db2jeQM). I connected adapter directly to USB charger - issue didn't disappear.

Can anyone give me any hint, what is wrong and how to fix this behavior? I would really appreciate any help.
User avatar
By urs_eppenberger
#90812 This looks strange indeed.
Let me confess: I have no clue at all what might be the problem.

Nevertheless I suggest the following tests:
1. Replace the wifiMulti with a single WiFi connection. Use one of the examples provided.
2. I do not like the delay(5000); statement in the loop section. This means that the ESP chip is blocked for 5 seconds. The WiFi stack does not like this.
You could use a timer which calls a subroutine every 5 seconds to display status information.
Or in the loop() section do something like this:
Code: Select allloop() {
   if (millis() - lastStatus > 5000) {
    // do your print stuff here
    lastStatus = mills();
  }
}



As I said above, I have no clue what the real problem is. But the above hints might get rid of problems and be one step in the right direction.
Kind regards,
Urs.
User avatar
By Fduch
#90829 urs_eppenberger, thank you, I will try it.
I managed to find another router (TP-Link) and it seems everything works fine with it. Weird.
User avatar
By Fduch
#90831 I've just tried not to use wifiMulti and delay() - it didn't help.
I'm wondering, how this issue can depend on WiFi router? I mean it works fine with all devices, except ESP. May be ESP requires some functionality from router, which is disabled by default (or not supported) by old routers?