Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFi disconnects after 48h-20min but reconnects again after 48h-20min #9987

Open
1 task done
AndyKoder opened this issue Jul 4, 2024 · 9 comments
Open
1 task done
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@AndyKoder
Copy link

AndyKoder commented Jul 4, 2024

Board

ESP32-Wroom32 (ESP32 Dev Module)

Device Description

Module on breadboard

Hardware Configuration

DHT20

Version

v3.0.1

IDE Name

Arduino IDE

Operating System

ubuntu linux

Flash frequency

80Mhz

PSRAM enabled

no

Upload speed

115200

Description

WiFi connects, but after 48h - ~20mins it disconnects and could not reconnect.
But after another 48h - ~20mins (without connection) it suddenly is able to reconnect again.
It is otherwise fully working, serial console shows normal output of wifi status, temp every 60s
(this does not happen with 1.0.6)
I don't see a reason anywhere, in the WiFi AP/router log i see only lots of "esp32-xxxx connects/disconnects"

Sketch

Basically this example
(changed only ssid+pass, some debug msgs every 60s, dht20 temp, everything working, but wifi is disconnected)

void printWifiStatus() {
   Serial.printf("WiFi.getHostname[%s]\n", WiFi.getHostname());
   Serial.printf("MAC WiFi.macAddress() [%s]\n", WiFi.macAddress().c_str());
   Serial.printf("SSID[%s] IP[%s] RSSI[%ld dBm]\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str(), (long)WiFi.RSSI());
Serial.printf("Status[%d]\n", WiFi.status());
}

Debug Message

WiFi.status() gets 0 that is WL_IDLE_STATUS

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@AndyKoder AndyKoder added the Status: Awaiting triage Issue is waiting for triage label Jul 4, 2024
@me-no-dev
Copy link
Member

Please enable core debug level to verbose and let's see what reason the WiFi gives for disconnecting. 2900 minutes is oddly specific and in no way around some 32 bit overflow (or similar)

@AndyKoder
Copy link
Author

[168428788][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 14 - STA_DISCONNECTED
[168428797][V][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 14 - STA_DISCONNECTED
[168428805][W][STA.cpp:135] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE

@me-no-dev
Copy link
Member

And what reason does it give when it fails to reconnect after that?

@AndyKoder
Copy link
Author

Compiled the same code with 1.0.6, runs for a week now.
In the router log i see 3 disconnects after 42h, 47h and 53h,
but it ALWAYS reconnected right after the disconnect.
So maybe it's normal that it disconnects from time to time, but the reconnect part in the 3.0.x doesn't work for some reason...
btw: how would i get the Reason 8 ASSOC_LEAVE error from inside the esp32, so i could log that without using serial console?

@TD-er
Copy link
Contributor

TD-er commented Jul 13, 2024

Do you have "band steering" enabled on your access point?
If so, try disabling it.
Of try to connect you ESP with forced 802.11g mode (not 802.11n)

@AndyKoder
Copy link
Author

And what reason does it give when it fails to reconnect after that?

[486788][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 13 - STA_CONNECTED
[486795][V][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 13 - STA_CONNECTED

and then after a couple of seconds again

[546732][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 14 - STA_DISCONNECTED
[546740][V][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 14 - STA_DISCONNECTED
[546748][W][STA.cpp:135] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE

@AndyKoder
Copy link
Author

AndyKoder commented Aug 19, 2024

Do you have "band steering" enabled on your access point? If so, try disabling it. Of try to connect you ESP with forced 802.11g mode (not 802.11n)

I do not see any "band steering" on the router.
How would i tell the ESP32 to use 802.11g?

@TD-er
Copy link
Contributor

TD-er commented Aug 19, 2024

uint8_t protocol = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G; // Default to BG
esp_wifi_set_protocol(WIFI_IF_STA, protocol);

N.B. you need to set these before you make the connection

@lbernstone
Copy link
Contributor

lbernstone commented Aug 19, 2024

This sounds a lot like the router is refusing to allocate a DHCP address. Can you try a manual IP assignment and see if it has the same issue? This will help identify what the router is having a problem with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

4 participants