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

ESP32 does not reconnect to Wifi #2400

Open
4 tasks done
LPG-PG opened this issue Nov 9, 2024 · 11 comments
Open
4 tasks done

ESP32 does not reconnect to Wifi #2400

LPG-PG opened this issue Nov 9, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@LPG-PG
Copy link

LPG-PG commented Nov 9, 2024

What happened?

After an indefinite period of time, the ESP32 module loses the connection to the WiFi. No new DHCP lease is obtained, so neither web, API, MQTT nor ping works.

To Reproduce Bug

It happens ramdomly between 1 and 5 days

Expected Behavior

OpenDTU has to be reboot to fix it temporary

Install Method

Pre-Compiled binary from GitHub releases

What git-hash/version of OpenDTU?

v24.10.15

What firmware variant (PIO Environment) are you using?

generic_esp32

Relevant log/trace output

No response

Anything else?

I checked some parts of the code and I'm not sure, if there is a bug in NetworkSettings.cpp -> NetworkSettingsClass::applyConfig()
line 288ff

WiFi.begin(
            Configuration.get().WiFi.Ssid,
            Configuration.get().WiFi.Password,
            WIFI_ALL_CHANNEL_SCAN);

I mean, that Wifi.begin is called with Channel 1 because the enum WIFI_ALL_CHANNEL_SCAN value is 1.

The declaration of the called function is:

wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true);

So the third paramter is the channel, which is in this case 1.

Please confirm the following

  • I believe this issue is a bug that affects all users of OpenDTU, not something specific to my installation.
  • I have already searched for relevant existing issues and discussions before opening this report.
  • I have updated the title field above with a concise description.
  • I have double checked that my inverter does not contain a W in the model name (like HMS-xxxW) as they are not supported.
@LPG-PG LPG-PG added the bug Something isn't working label Nov 9, 2024
@tbnobody tbnobody mentioned this issue Nov 29, 2024
4 tasks
@Subnum12
Copy link

I have same issue.
I did try wifi reconnect while console log was enabled. For whatever reason the console gets disconnected while wifi is disconnect. However, that's the last output even I could not recreate the issue with manual wifi reconnect.

[2094941][E][WiFiClient.cpp:429] write(): fail on fd 48, errno: 113, "Software caused connection abort"
Disconnected from MQTT.
Disconnect reason:TCP_DISCONNECTED
Network lost co˫▒ѥ▒▒5
                     Websocket: [/livedata][5] disconnect

@tbnobody
Copy link
Owner

I mean, that Wifi.begin is called with Channel 1 because the enum WIFI_ALL_CHANNEL_SCAN value is 1.

You are right. at least the setting of WIFI_ALL_CHANNEL_SCAN is wrong at this place... did you try if it works better if you remove this parameter?

@stefan123t
Copy link
Contributor

stefan123t commented Dec 19, 2024

@tbnobody I think @LPG-PG is right, we maybe somehow using the wrong signature for the WiFi.begin() method.
We should be using the WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN) separately prior calling the WiFi.begin() method.

https://github.com/espressif/arduino-esp32/blob/352705e6077de4f0575324efa234814e823b9fb8/libraries/WiFi/src/WiFiSTA.cpp#L232-L240

The actual WiFi.begin() method obviously seems to have the signature as @LPG-PG reported:

https://github.com/espressif/arduino-esp32/blob/352705e6077de4f0575324efa234814e823b9fb8/libraries/WiFi/src/WiFiSTA.cpp#L83-L93

The issue seems to be in the „new credentials… “ code path of the NetworkSettings.applyConfig() method:

void NetworkSettingsClass::applyConfig()
{
setHostname();
if (!strcmp(Configuration.get().WiFi.Ssid, "")) {
return;
}
MessageOutput.print("Configuring WiFi STA using ");
if (strcmp(WiFi.SSID().c_str(), Configuration.get().WiFi.Ssid) || strcmp(WiFi.psk().c_str(), Configuration.get().WiFi.Password)) {
MessageOutput.print("new credentials... ");
WiFi.begin(
Configuration.get().WiFi.Ssid,
Configuration.get().WiFi.Password,
WIFI_ALL_CHANNEL_SCAN);
} else {
MessageOutput.print("existing credentials... ");
WiFi.begin();
}
MessageOutput.println("done");
setStaticIp();
}

If this is the case/cause somehow that code path gets active after 2-5 days for some yet unknown reason, but it should eventually show up in the logging.

@LPG-PG
Copy link
Author

LPG-PG commented Dec 21, 2024

You are right. at least the setting of WIFI_ALL_CHANNEL_SCAN is wrong at this place... did you try if it works better if you remove this parameter?

I haven't tried it yet.

@pi-amp
Copy link

pi-amp commented Jan 7, 2025

same here for me. Really anoying when you're away from the DTU... Hope it gets fixed !

@karamo
Copy link

karamo commented Jan 9, 2025

Ich habe vor 2 Wochen von der 24.5.6 auf 24.11.7 upgedatet.
Die Folge waren permanente Abbrüche der WiFi-Verbindung.
Bin wieder zurück auf die bei mir funktionierende 24.5.6

I updated from 24.5.6 to 24.11.7 2 weeks ago.
The result was permanent lost of the WiFi connection.
I'm back to 24.5.6, which works for me.

@ms1958
Copy link

ms1958 commented Jan 17, 2025

Guten Tag,
jetzt ist ja die Version 25.1.14 draussen. ist das Problem damit behoben ?
Ich bin solange auf die v24.6.29 zurück gegangen, und hatte bis dato keine verbindungsabbrüche mehr.

@Subnum12
Copy link

Subnum12 commented Jan 17, 2025

habe mit v25.1.14 seit Mittowch keine Abbrüche mehr. -> issue can be closed.

@andreas-bulling
Copy link

I have upgraded to 25.1.14 yesterday and today OpenDTU doesn't connect to Wifi anymore. No changes otherwise, in particular I haven't moved the device or anyting.

@Subnum12
Copy link

actually after almost a week running without any issue I got same error yesterday evening again.

@andreas-bulling
Copy link

I think they must have changed something on the wifi stack - or maybe wireless transmission power? The OpenDTU device is located in the basement. No wifi connection problems whatsoever since more than a year now.

With the new firmware it didn't connect. I now brought it upstairs, closer to an AP and it connects without problems.

Back in the basement it also connects now for some reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants