openHASP icon indicating copy to clipboard operation
openHASP copied to clipboard

Display ESP32-4848S040 with "Guition ESP32-S3-4848S040" firmware does not work properly: can't connect to WiFi

Open tankist-git-2 opened this issue 6 months ago • 15 comments

Perform all steps below and tick them with [x]

  • [x] Check the related part of the Documentation
  • [x] Update openHASP to the latest version
  • [x] Reproduce the issue and describe all steps

Describe the bug

I have ESP32-4848S040 display. I want to install OpenHASP firmware on it. I follow all instructions from that post. But I get an issue when I reboot device after firmeare update. It doesn't connect ot WiFi router. I attached a log from the device. I tried nighly 0.7.0-rc12 build and stable 0.7.0-rc13 build with the same results.

esp-web-tools-logs.txt

To Reproduce

  1. Go to https://nightly.openhasp.com/ website
  2. Select Guition ESP32-S3-4848S040 line
  3. Click "Install" button
  4. Select the appropriate serial port
  5. Check "Erase device" checkbox
  6. Select "Next", "Install"
  7. Click "Logs and console"
  8. Follow the screen master to connect to WiFi
  9. Waiting automatic reboot

Expected behavior

After reboot I expected to see IP-address on the screen, but I see the "plate" word only. The stock demonstration firmware easily connected to WiFi so I guess the hardware is ok. I use the same power source and cable.

Screenshots or video

Image

tankist-git-2 avatar Jul 12 '25 20:07 tankist-git-2

Check the serial log, that should give you a clue about what's happening and why the connection fails.

fvanroie avatar Jul 12 '25 20:07 fvanroie

There is the UART log. It doesn't differ too much from USB log. I see 2 fails in log:

openhasp_uart_log.txt

  1. GPIO: Invalid pin 0
  2. MSGR: File not found: L:/boot.cmd

I have no idea what the file "L:/boot.cmd" is.

tankist-git-2 avatar Jul 13 '25 08:07 tankist-git-2

What is your country? It could be that the WiFi needs a country setting to configure the WiFi power.

You you have a TP-Link router?

For reference, this looks like a duplicate of #791

fvanroie avatar Jul 13 '25 15:07 fvanroie

  1. My router is not TP-Link, my router is Huawei HG8245H-256M
  2. What country settings should be changed? I didn't find any in the post you are suggested. The only thing is mentioned there was the power setting "output_power: 8.5dB". But how can I change it? I use binary firmware from here
  3. I'm quite sure this issue is not caused by WiFi output power. I placed my device as close to WiFi router as it's possible (about 5 cm) with the same result.
  4. As I mentioned before, as I write my own firmware it's connected to WiFi without any problem (in the same place, with the same power supply, to the same router)

tankist-git-2 avatar Jul 14 '25 18:07 tankist-git-2

The only issue I see in the logs is:

[      39.733][122868/133692  8][57964/58448  1] WIFI: association leave
[      39.742][122868/133992  8][57964/58448  1] WIFI: Unknown error (66)

That error lead me to the esphome thread mentioning a solution to adjust the wifi power. Several users there report that that fixes their problem. openHASP doesn't really do weird things, it mainly uses the Arduino defaults for ESP32.

  1. Good to know, there were some mentions about TP-Link issues and another user also has a TP-Link, but that could just be a coincidence... at this point it's not clear yet.
  2. I'm trying to find a pattern in order to get to the root cause of this problem. The other user is from the UK, which country are you in or what's the WiFi region configured in your router? There is no setting in openHASP yet for WiFi power or country. We need to find the root cause first before adding UI interfaces etc...
  3. You can't be sure until you test it though, at this point it is the only idea I've got. The issue happens with the Guiton 480x480, so it could be some weird combination with hardware & firmware settings. I'm no Wireless expert but I can imagine tweaking the power can yield a better result. It sure worked for the users in the esphome thread I posted, so the issue is not just in openHASP.
  4. You can compare your firmware settings with the openHASP wifi settings, maybe there is somehting I overlooked. I'm open to suggestions. Are you able to compile and test the source code locally?

As I'm not able to recreate the specific circumstances that cause this issue, it's hard to anticipate a solution. So far the country and/or power settings are the only lead that might be related to the behavior described.

If you can't compile locally I could push some test settings (guesses) for you to test, but that will be a trial and error. Let me know what you think.

fvanroie avatar Jul 14 '25 21:07 fvanroie

Let's break this down a bit.

  1. I'm from Belarus. There are settings from my router (I hope you meant them):
Image
  1. Let's try your tests.
  2. I'm not novice to embedded development, especially for the ESP32 platform, but I'm not very familiar with Home Assistant. If you provide a link to the build description, I'll try to build the project from the source.

tankist-git-2 avatar Jul 14 '25 22:07 tankist-git-2

You can compile the firmware locally or with GitPod. Home Assistant is not required.

I was thinking of something like WiFi.setTxPower(WIFI_POWER_8_5dBm) from Arduino or esp_wifi_set_max_tx_power() or esp_wifi_set_country_code() function from the ESP-IDF framework.

fvanroie avatar Jul 15 '25 12:07 fvanroie

I've got some news. I found the immediate cause of the problem but you should fix it yourself because I I am not closely familiar with the whole project.

I added some extra log in project and what I saw:

ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x18 (SPI_FAST_FLASH_BOOT) Saved PC:0x420fd39e SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3808,len:0x128 load:0x403c9700,len:0xb90 load:0x403cc700,len:0x28cc entry 0x403c98b8

    open____ _____ _____ _____
      |  |  |  _  |   __|  _  |
      |     |     |__   |   __|
      |__|__|__|__|_____|__|
    Home Automation Switch Plate
    Open Hardware edition v0.7.0-rc15

[ 0.092][212980/248784 14][ 0/ 0 0] DBUG: Started @ 115200 bps #[ 0.101][212980/248784 14][ 0/ 0 0] DBUG: Environment: esp32-s3-4848s040_16MB #[ 0.111][212980/248784 14][ 0/ 0 0] UART: Started #[ 0.118][212980/248784 14][ 0/ 0 0] UART: Client login from serial #[ 0.140][212980/248684 14][ 0/ 0 0] CONF: SPI flash FS mounted Prompt > [ 0.163][212980/248684 14][ 0/ 0 0] CONF: Loading /config.json Prompt > [ 0.173][212980/247916 14][ 0/ 0 0] CONF: Loaded /config.json Prompt > [ 0.182][212980/248748 14][ 0/ 0 0] DBUG: Loading debug settings Prompt > [ 0.192][212980/248748 14][ 0/ 0 0] GPIO: Loading GUI settings Prompt > [ 0.202][212980/248748 14][ 0/ 0 0] GUI : First Touch Calibration enabled Prompt > [ 0.213][212980/248748 14][ 0/ 0 0] HASP: Loading HASP settings Prompt > [ 0.222][212980/248748 14][ 0/ 0 0] WIFI: Loading WiFi settings Prompt > [ 0.249][212980/246824 13][ 0/ 0 0] MQTT: Loading MQTT settings Prompt > [ 0.265][212980/246824 13][ 0/ 0 0] TELN: Loading Telnet settings Prompt > [ 0.275][212980/246824 13][ 0/ 0 0] MDNS: Loading MDNS settings Prompt > [ 0.284][212980/246824 13][ 0/ 0 0] HTTP: Loading HTTP settings Prompt > [ 0.294][212980/246824 13][ 0/ 0 0] GPIO: Loading GPIO settings Prompt > [ 0.304][212980/246824 13][ 0/ 0 0] CONF: Settings loaded Prompt > [ 0.313][212980/248888 14][ 0/ 0 0] WIFI: [T] ENTER_WIFI_SETUP Prompt > [ 0.325][212980/248888 14][ 0/ 0 0] WIFI: [T] ENTER_WIFI_ARCH_ESP32 Prompt > [ 0.349][212980/248768 14][ 0/ 0 0] WIFI: [T] WIFI PASS = ******** Prompt > [ 0.359][212980/248840 14][ 0/ 0 0] WIFI: [T] called wifiReconnect() Prompt > [ 0.377][204788/218780 6][ 0/ 0 0] WIFI: [T] called wifi_callback() with event = 0 Prompt > [ 0.422][204788/218048 6][ 0/ 0 0] WIFI: [T] called wifi_callback() with event = 2 Prompt > [ 0.435][204788/217904 6][ 0/ 0 0] WIFI: Connecting to WiFiRouter Prompt > [ 0.445][204788/217864 6][ 0/ 0 0] MSGR: Starting... Prompt > [ 0.454][204788/217864 6][ 0/ 0 0] MSGR: Started Prompt > [ 0.462][204788/217864 6][ 0/ 0 0] TFT : Starting... Prompt > [ 0.471][204788/217840 5][ 0/ 0 0] TFT : Starting... Prompt > [ 0.733][204788/215692 5][ 0/ 0 0] TFT : Started Prompt > [ 0.760][204788/215692 5][ 0/ 0 0] TFT : Started Prompt > [ 0.851][204788/215692 5][ 0/ 0 0] LVGL: Starting... Prompt > [ 0.864][155636/166324 6][62608/62832 1] LVGL: LV_FS_PC ready Prompt > [ 0.874][131060/141152 7][61908/61956 1] GUI : Initialize Cursor Prompt > [ 1.386][131060/140384 6][61816/61840 1] DRVR: GT911 Started (480x480) Prompt > [ 1.401][131060/140384 6][61816/61840 1] DRVR: * Found device 0x5d Prompt > [ 1.414][131060/140284 6][61576/61592 1] LVGL: Started Prompt > [ 1.431][131060/140284 6][59116/59756 2] HASP: Custom theme loaded Prompt > [ 1.454][131060/140284 6][58564/58568 1] HASP: Loading /pages.jsonl Prompt > [ 1.480][131060/140284 6][58448/58452 1] HASP: Loaded /pages.jsonl Prompt > [ 1.489][131060/140284 6][58448/58452 1] HASP: Changing page to 1 Prompt > [ 1.499][131060/140284 6][58288/58292 1] GPIO: Starting... Prompt > [ 1.508][131060/140284 6][58288/58292 1] GPIO: Reboot counter 0 Prompt > [ 1.517][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.526][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.535][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.544][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.552][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.561][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.570][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.579][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.588][131060/140284 6][58288/58292 1] GPIO: Started Prompt > [ 1.598][126964/135848 6][58288/58292 1] HTTP: Started Prompt > [ 1.607][126964/135280 6][58288/58292 1] TELN: Telnet console started Prompt > [ 1.617][126964/135280 6][58288/58292 1] FTP : Starting... Prompt > [ 1.626][126964/135280 6][58288/58292 1] FTP : Disabled Prompt > [ 1.656][126964/135280 6][58288/58292 1] MSGR: File not found: L:/boot.cmd Prompt > [ 1.669][122868/134208 8][58288/58292 1] MQTT: hasp/plate/LWT Prompt > [ 1.679][122868/134160 8][58288/58292 1] MQTT: hasp/plate/LWT Prompt > [ 1.688][122868/134380 8][58288/58292 1] MQTT: Broker not configured Prompt > [ 3.425][122868/134024 8][57964/58448 1] WIFI: [T] called wifi_callback() with event = 4 $\color{green}Prompt > [ 3.437][122868/134084 8][57964/58448 1] \space WIFI: \space [T] \space called \space wifiSsidConnected()$ Prompt > [ 3.447][122868/134084 8][57964/58448 1] WIFI: Connected to WiFiRouter, requesting IP... $\color{red}Prompt > [ 4.726][122868/134244 8][57964/58448 1] \space WIFI: \space No \space Connection... retry 0$ $\color{red}Prompt > [ 4.736][122868/134244 8][57964/58448 1] \space WIFI: \space [T] \space called \space wifiReconnect()$ Prompt > [ 4.748][122868/134160 8][57964/58448 1] WIFI: [T] called wifi_callback() with event = 5 Prompt > [ 4.759][122868/134136 8][57964/58448 1] WIFI: [T] called wifiDisconnected() with reason = 8 Prompt > [ 4.771][122868/134280 8][57964/58448 1] WIFI: association leave Prompt > [ 4.780][122868/134440 8][57964/58448 1] WIFI: [T] called wifi_callback() with event = 3 Prompt > [ 4.791][122868/134440 8][57964/58448 1] WIFI: [T] called wifiDisconnected() with reason = 66

Let's see what was happened. Connection to router was done successfully (we can see this as wifiSsidConnected() function was called). But after we can see immediately reconnect to WiFi !!!! (by calling wifiReconnect() function). What is the reason for that? Let's see what was the source of the log "No Connection... retry". As I found out it was done by wifiEvery5Seconds() function. As we can see from the name this function should be called every 5 seconds. So there is a problem: it lasts 5 seconds since WiFi connection done but IP address still not received. WiFi router can't handle so fast reconnections and system entered into infinite loop.

Ok, let's test that everything is ok without this check. Let's comment out some lines in wifiEvery5Seconds() function:

 bool wifiEvery5Seconds()
 {
 #if defined(STM32F4xx)
     if(wifiShowAP()) { // no ssid is set yet wait for user on-screen input
         return false;
     }
 #else
     if(WiFi.getMode() == WIFI_AP || WiFi.getMode() == WIFI_AP_STA) {
         LOG_DEBUG(TAG_WIFI, F("5sec mode AP %d"), WiFi.getMode());
         return false;
     }
 #endif

    if(WiFi.status() == WL_CONNECTED && WiFi.localIP() > 0) {
        return true;
    }

   //if(wifiEnabled) {
   //     LOG_WARNING(TAG_WIFI, F("No Connection... retry %d"), network_reconnect_counter);
   //     wifiReconnect();
   //}
  
  return false;
 }

I commented out if(wifi Enabled) condition. Let's see the boot log after that:

ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x18 (SPI_FAST_FLASH_BOOT) Saved PC:0x420fd352 SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3808,len:0x128 load:0x403c9700,len:0xb90 load:0x403cc700,len:0x28cc entry 0x403c98b8

    open____ _____ _____ _____
      |  |  |  _  |   __|  _  |
      |     |     |__   |   __|
      |__|__|__|__|_____|__|
    Home Automation Switch Plate
    Open Hardware edition v0.7.0-rc15

[ 0.092][212980/248784 14][ 0/ 0 0] DBUG: Started @ 115200 bps #[ 0.101][212980/248784 14][ 0/ 0 0] DBUG: Environment: esp32-s3-4848s040_16MB #[ 0.111][212980/248784 14][ 0/ 0 0] UART: Started #[ 0.118][212980/248784 14][ 0/ 0 0] UART: Client login from serial #[ 0.140][212980/248684 14][ 0/ 0 0] CONF: SPI flash FS mounted Prompt > [ 0.163][212980/248684 14][ 0/ 0 0] CONF: Loading /config.json Prompt > [ 0.173][212980/247916 14][ 0/ 0 0] CONF: Loaded /config.json Prompt > [ 0.182][212980/248748 14][ 0/ 0 0] DBUG: Loading debug settings Prompt > [ 0.192][212980/248748 14][ 0/ 0 0] GPIO: Loading GUI settings Prompt > [ 0.202][212980/248748 14][ 0/ 0 0] GUI : First Touch Calibration enabled Prompt > [ 0.213][212980/248748 14][ 0/ 0 0] HASP: Loading HASP settings Prompt > [ 0.222][212980/248748 14][ 0/ 0 0] WIFI: Loading WiFi settings Prompt > [ 0.249][212980/246824 13][ 0/ 0 0] MQTT: Loading MQTT settings Prompt > [ 0.265][212980/246824 13][ 0/ 0 0] TELN: Loading Telnet settings Prompt > [ 0.275][212980/246824 13][ 0/ 0 0] MDNS: Loading MDNS settings Prompt > [ 0.284][212980/246824 13][ 0/ 0 0] HTTP: Loading HTTP settings Prompt > [ 0.294][212980/246824 13][ 0/ 0 0] GPIO: Loading GPIO settings Prompt > [ 0.304][212980/246824 13][ 0/ 0 0] CONF: Settings loaded Prompt > [ 0.313][212980/248888 14][ 0/ 0 0] WIFI: [T] ENTER_WIFI_SETUP Prompt > [ 0.325][212980/248888 14][ 0/ 0 0] WIFI: [T] ENTER_WIFI_ARCH_ESP32 Prompt > [ 0.338][212980/248840 14][ 0/ 0 0] WIFI: [T] called wifiReconnect() Prompt > [ 0.356][204788/218780 6][ 0/ 0 0] WIFI: [T] called wifi_callback() with event = 0 Prompt > [ 0.402][204788/218048 6][ 0/ 0 0] WIFI: [T] called wifi_callback() with event = 2 Prompt > [ 0.428][204788/218096 6][ 0/ 0 0] WIFI: Connecting to WiFiRouter Prompt > [ 0.439][204788/217864 6][ 0/ 0 0] MSGR: Starting... Prompt > [ 0.447][204788/217864 6][ 0/ 0 0] MSGR: Started Prompt > [ 0.456][204788/217864 6][ 0/ 0 0] TFT : Starting... Prompt > [ 0.464][204788/217840 5][ 0/ 0 0] TFT : Starting... Prompt > [ 0.727][204788/215692 5][ 0/ 0 0] TFT : Started Prompt > [ 0.754][204788/215692 5][ 0/ 0 0] TFT : Started Prompt > [ 0.845][204788/215692 5][ 0/ 0 0] LVGL: Starting... Prompt > [ 0.858][155636/166324 6][62608/62832 1] LVGL: LV_FS_PC ready Prompt > [ 0.868][131060/141152 7][61908/61956 1] GUI : Initialize Cursor Prompt > [ 1.380][131060/140384 6][61816/61840 1] DRVR: GT911 Started (480x480) Prompt > [ 1.395][131060/140384 6][61816/61840 1] DRVR: * Found device 0x5d Prompt > [ 1.408][131060/140284 6][61576/61592 1] LVGL: Started Prompt > [ 1.425][131060/140284 6][59116/59756 2] HASP: Custom theme loaded Prompt > [ 1.448][131060/140284 6][58564/58568 1] HASP: Loading /pages.jsonl Prompt > [ 1.474][131060/140284 6][58448/58452 1] HASP: Loaded /pages.jsonl Prompt > [ 1.483][131060/140284 6][58448/58452 1] HASP: Changing page to 1 Prompt > [ 1.493][131060/140284 6][58288/58292 1] GPIO: Starting... Prompt > [ 1.502][131060/140284 6][58288/58292 1] GPIO: Reboot counter 0 Prompt > [ 1.511][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.520][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.529][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.537][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.546][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.555][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.564][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.573][131060/140284 6][58288/58292 1] GPIO: Invalid pin 0 Prompt > [ 1.582][131060/140284 6][58288/58292 1] GPIO: Started Prompt > [ 1.592][126964/135848 6][58288/58292 1] HTTP: Started Prompt > [ 1.601][126964/135280 6][58288/58292 1] TELN: Telnet console started Prompt > [ 1.611][126964/135280 6][58288/58292 1] FTP : Starting... Prompt > [ 1.620][126964/135280 6][58288/58292 1] FTP : Disabled Prompt > [ 1.651][126964/135280 6][58288/58292 1] MSGR: File not found: L:/boot.cmd Prompt > [ 1.664][122868/134208 8][58288/58292 1] MQTT: hasp/plate/LWT Prompt > [ 1.674][122868/134160 8][58288/58292 1] MQTT: hasp/plate/LWT Prompt > [ 1.683][122868/134380 8][58288/58292 1] MQTT: Broker not configured Prompt > [ 3.402][122868/133976 8][57964/58448 1] WIFI: [T] called wifi_callback() with event = 4 Prompt > [ 3.414][122868/134084 8][57964/58448 1] WIFI: [T] called wifiSsidConnected() Prompt > [ 3.424][122868/134084 8][57964/58448 1] WIFI: Connected to WiFiRouter, requesting IP... Prompt > [ 8.366][122868/133920 8][57964/58448 1] WIFI: [T] called wifi_callback() with event = 7 Prompt > [ 8.377][122868/134116 8][57964/58448 1] WIFI: [T] called wifiConnected() $\color{green}Prompt > [ 8.387][122868/134116 8][57964/58448 1] \space WIFI: \space Received \space IP \space address \space 192.168.100.32$ Prompt > [ 9.740][122868/134276 8][57964/58448 1] MSGR: Loading L:/online.cmd Prompt > [ 9.762][118772/128180 7][57964/58448 1] MSGR: jsonl={"page":0,"id":239,"obj":"msgbox","text":"%ip%","auto_close":20000} Prompt > [ 9.810][122868/133204 7][57836/57876 1] MSGR: Loaded L:/online.cmd Prompt > [ 9.820][122868/133800 8][57836/57876 1] HTTP: Started @ http://192.168.100.32 Prompt > [ 9.831][122868/133848 8][57836/57876 1] MDNS: Starting... Prompt > [ 9.862][114676/126464 9][57836/57876 1] MDNS: Started

As you can see IP-address successfully received since 8.5 seconds. After that everything looks fine: I can see IP-address on the screen, I can control my device via browser etc.

So as you can see this is obviously a bug and it's not rely to any routers and wifi settings. I make a test firmware just to proove if it helpes and it does. So you need to find out why chek period so small and fix that.

tankist-git-2 avatar Jul 17 '25 13:07 tankist-git-2

have the same plate, mine is working fine.

Holle88 avatar Jul 27 '25 08:07 Holle88

Obviously, the issue is how quickly the router issues an IP address. But since this time is not specified by the standards, the firmware must support operation in any case, i.e. this is a bug.

tankist-git-2 avatar Jul 27 '25 19:07 tankist-git-2

This has been fixed in the commit above. Have you been able to test it? Can you confirm this is resolved? Re connection is now handled by the Arduino/ESP-IDF framework instead of the every_5_seconds callback.

fvanroie avatar Jul 27 '25 20:07 fvanroie

I built the last commit and now everything works. I rebooted the device several times and each time the connection to the router was successful.

There is a problem with reconnection to WiFi router. After I turned off the router, the message "Offline" appeared on the device screen. But when I turned on the router, the device did not connect automatically. I guess this behavior is unusual.

tankist-git-2 avatar Jul 28 '25 20:07 tankist-git-2

Could you try also setting WiFi.persistent(true); ?

fvanroie avatar Jul 28 '25 22:07 fvanroie

It didn't help. However, I did some research online to see how other developers handle this. The options I found were based on constantly polling the WiFi status and restarting when no connection was detected. So, it can be concluded that the original version of polling the WiFi status is valid. I modified the wifiEvery5Seconds() function to make the waiting period after WiFi disconnection was not 5 seconds, but 30 seconds. I compiled the firmware and uploaded it to my device to test it. In my case, it works well: the initial connection is no problem, and the restart after WiFi disconnection also works well. Here's how I did it:

bool wifiEvery5Seconds()
{
	static uint32_t disconnectionPeriod = 0;	// WiFi disconnection period counter

#if defined(STM32F4xx)
	if(wifiShowAP()) { // no ssid is set yet wait for user on-screen input
		return false;
	}
#else
	if(WiFi.getMode() == WIFI_AP || WiFi.getMode() == WIFI_AP_STA) {
		LOG_DEBUG(TAG_WIFI, F("5sec mode AP %d"), WiFi.getMode());
		return false;
	}
#endif

	if(WiFi.status() == WL_CONNECTED && WiFi.localIP() > 0) {
		disconnectionPeriod = 0;		// Reset the counter if connection was established
		return true;
	}

	if(WiFi.status() != WL_CONNECTED) {		// If WiFi disconnected...
		if(++disconnectionPeriod >= 6) { 	// If 30 seconds have passed since the disconnection...
			disconnectionPeriod = 0;	// Restart timeout period
			wifiReconnect();		// Reconnect to WiFi
		}
	}
	return false;
}

tankist-git-2 avatar Jul 29 '25 19:07 tankist-git-2

Thanks for testing and sharing your solution. I think this is an elegant fix and allows more time for the connection to succeed before retrying.

fvanroie avatar Jul 29 '25 20:07 fvanroie