[GH-ISSUE #1674] Issue with ESP32-S3 Using Wi-Fi ON Demand #1420

Closed
opened 2026-02-28 01:30:00 +03:00 by kerem · 9 comments
Owner

Originally created by @Fishbone69 on GitHub (Nov 13, 2023).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1674

Basic Infos

Hardware

WiFimanager Branch/Release: 2.0.16-rc.2

Esp8266/Esp32:

Hardware: esp32-S3
Core Version: 2.4.0, staging

Description

I am trying to use WiFiManager On Demand to go out and grab the time from ntp server. The following code worked great on Wemos esp32-C3 Pico but when I ported to Wemos esp32-S3 mini, it resets the chip at various places in the subroutine below. It also resets the chip on a second, custom esp32-S3 dev board I used - so I think it is an issue with esp32-S3. I am fairly new to programming microcontrollers so I'll do my best to comply with any requests for additional data on this issue. Also, I am using the PlatformIO IDE. Any help is appreciated!

Settings in IDE

Module: Wemos esp32-S3 Mini

Additional libraries:
// Include Libraries
#include <Arduino.h>
#include <ESP32Time.h>
#include "RTClib.h" //This is a local version of the Library with alarmIsEnabled();
#include <U8g2lib.h>
#include <Button2.h>
#include <WiFiManager.h>
#include <esp_sntp.h>
#include "driver/rtc_io.h"
#include "CustomFonts.h"
#include "Bitmaps.h"
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

Sketch

When a certain button is pressed the code executes the following subroutine. Including the full sketch is impossible

#BEGIN
#include <Arduino.h>
#include <WiFiManager.h>
//This is the subroutine
void startWiFi(){
int wifiTimeout = 180;
const char* ntpServer = "pool.ntp.org";
const long utcOffsetSeconds = 3600utcOffset;
sntp_sync_status_t syncStatus;
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setDrawColor(2);
WiFi.mode(WIFI_STA);
WiFiManager wm;
wm.resetSettings();
u8g2.setFont(u8g2_font_freedomSuperTiny_mf);
u8g2.setCursor(0, 15);
u8g2.print("STARTING WIFI...");
u8g2.sendBuffer();
wm.setConfigPortalTimeout(wifiTimeout);
u8g2.setCursor(0, 30);
u8g2.print("SELECT "ENCOM DW 1.0"...");
u8g2.sendBuffer();
if (!wm.startConfigPortal("ENCOM DW 1.0")) {
u8g2.setCursor(0, 45);
u8g2.print("FAILED. WIFI TIMEOUT");
u8g2.sendBuffer();
delay(3000);
}
else {
u8g2.setCursor(0,45);
u8g2.print("CONNECTED.");
u8g2.setCursor(0,60);
u8g2.print("IP "+ WiFi.localIP().toString());
u8g2.sendBuffer();
configTime(utcOffsetSeconds, 3600
dstFlag, ntpServer);
syncStatus = sntp_get_sync_status();
while (syncStatus != SNTP_SYNC_STATUS_COMPLETED) {
syncStatus = sntp_get_sync_status();
delay(100); // Adjust the delay time as per your requirements
}
rtcDS3231.adjust(DateTime(static_cast<uint16_t>(rtcESP32.getYear()), static_cast<uint8_t>(rtcESP32.getMonth()+1), static_cast<uint8_t>(rtcESP32.getDay()), static_cast<uint8_t>(rtcESP32.getHour(true)), static_cast<uint8_t>(rtcESP32.getMinute()),static_cast<uint8_t>(rtcESP32.getSecond())));
sntp_stop(); //resets syncStatus
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_freedomsmall_mf);
u8g2.setCursor(64-11*6/2,30);
u8g2.print("TIME SET!");
u8g2.drawFrame(15,15,98,20);
u8g2.drawFrame(17,17,94,16);
u8g2.sendBuffer();
messageTone();
delay (4000);
lastButtonPressedTime = millis();
}
WiFi.disconnect(true);
WiFi.mode(WIFI_OFF);
}
#END


### Debug Messages
No messages, the chip just resets.  If there is a way to  

messages here


Originally created by @Fishbone69 on GitHub (Nov 13, 2023). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1674 ### Basic Infos #### Hardware WiFimanager Branch/Release: 2.0.16-rc.2 Esp8266/Esp32: Hardware: esp32-S3 Core Version: 2.4.0, staging ### Description I am trying to use WiFiManager On Demand to go out and grab the time from ntp server. The following code worked great on Wemos esp32-C3 Pico but when I ported to Wemos esp32-S3 mini, it resets the chip at various places in the subroutine below. It also resets the chip on a second, custom esp32-S3 dev board I used - so I think it is an issue with esp32-S3. I am fairly new to programming microcontrollers so I'll do my best to comply with any requests for additional data on this issue. Also, I am using the PlatformIO IDE. Any help is appreciated! ### Settings in IDE Module: Wemos esp32-S3 Mini Additional libraries: // Include Libraries #include <Arduino.h> #include <ESP32Time.h> #include "RTClib.h" //This is a local version of the Library with alarmIsEnabled(); #include <U8g2lib.h> #include <Button2.h> #include <WiFiManager.h> #include <esp_sntp.h> #include "driver/rtc_io.h" #include "CustomFonts.h" #include "Bitmaps.h" #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif ### Sketch When a certain button is pressed the code executes the following subroutine. Including the full sketch is impossible #BEGIN #include <Arduino.h> #include <WiFiManager.h> //This is the subroutine void startWiFi(){ int wifiTimeout = 180; const char* ntpServer = "pool.ntp.org"; const long utcOffsetSeconds = 3600*utcOffset; sntp_sync_status_t syncStatus; u8g2.clearBuffer(); u8g2.setFontMode(1); u8g2.setDrawColor(2); WiFi.mode(WIFI_STA); WiFiManager wm; wm.resetSettings(); u8g2.setFont(u8g2_font_freedomSuperTiny_mf); u8g2.setCursor(0, 15); u8g2.print("STARTING WIFI..."); u8g2.sendBuffer(); wm.setConfigPortalTimeout(wifiTimeout); u8g2.setCursor(0, 30); u8g2.print("SELECT \"ENCOM DW 1.0\"..."); u8g2.sendBuffer(); if (!wm.startConfigPortal("ENCOM DW 1.0")) { u8g2.setCursor(0, 45); u8g2.print("FAILED. WIFI TIMEOUT"); u8g2.sendBuffer(); delay(3000); } else { u8g2.setCursor(0,45); u8g2.print("CONNECTED."); u8g2.setCursor(0,60); u8g2.print("IP "+ WiFi.localIP().toString()); u8g2.sendBuffer(); configTime(utcOffsetSeconds, 3600*dstFlag, ntpServer); syncStatus = sntp_get_sync_status(); while (syncStatus != SNTP_SYNC_STATUS_COMPLETED) { syncStatus = sntp_get_sync_status(); delay(100); // Adjust the delay time as per your requirements } rtcDS3231.adjust(DateTime(static_cast<uint16_t>(rtcESP32.getYear()), static_cast<uint8_t>(rtcESP32.getMonth()+1), static_cast<uint8_t>(rtcESP32.getDay()), static_cast<uint8_t>(rtcESP32.getHour(true)), static_cast<uint8_t>(rtcESP32.getMinute()),static_cast<uint8_t>(rtcESP32.getSecond()))); sntp_stop(); //resets syncStatus u8g2.clearBuffer(); u8g2.setFont(u8g2_font_freedomsmall_mf); u8g2.setCursor(64-11*6/2,30); u8g2.print("TIME SET!"); u8g2.drawFrame(15,15,98,20); u8g2.drawFrame(17,17,94,16); u8g2.sendBuffer(); messageTone(); delay (4000); lastButtonPressedTime = millis(); } WiFi.disconnect(true); WiFi.mode(WIFI_OFF); } #END ``` ### Debug Messages No messages, the chip just resets. If there is a way to ``` messages here ```
kerem 2026-02-28 01:30:00 +03:00
Author
Owner

@tablatronix commented on GitHub (Nov 13, 2023):

There has to be serial exception no esp just resets itself. Try to get logs and maybe turn up esp debugging. I use the S3 all the time

<!-- gh-comment-id:1807384788 --> @tablatronix commented on GitHub (Nov 13, 2023): There has to be serial exception no esp just resets itself. Try to get logs and maybe turn up esp debugging. I use the S3 all the time
Author
Owner

@tablatronix commented on GitHub (Nov 13, 2023):

You would have to reduce this sketch alot, how are you calling this from button press?

<!-- gh-comment-id:1807385682 --> @tablatronix commented on GitHub (Nov 13, 2023): You would have to reduce this sketch alot, how are you calling this from button press?
Author
Owner

@Fishbone69 commented on GitHub (Nov 13, 2023):

@tablatronix It was surprising to me as well - especially since it worked perfectly on the esp32-C3. I'll see if I can get logs - like I said, I new to programming microcontrollers but I'll try to figure it out. As far as calling the code from the button press, I am using button2 library which uses callback functions. So I use the following code:

buttonEnter.setPressedHandler([](Button2 &btn){
            pressed(dummyButton);
            if (currentSetSave == "YES"){
            dstFlag=setDST;
            utcOffset = setUtcOffset;
            startWiFi();
            mode = 1;
            settingsMode = 0;
            setTimeMode=0;
            selectSettingField = 0;
            }
            else{
            selectSettingField = 0;  
            }
           });

However, I keep coming back to the fact that this code works on my esp32-C3 board.

I'll get you logs if I can - Thanks!

<!-- gh-comment-id:1807415997 --> @Fishbone69 commented on GitHub (Nov 13, 2023): @tablatronix It was surprising to me as well - especially since it worked perfectly on the esp32-C3. I'll see if I can get logs - like I said, I new to programming microcontrollers but I'll try to figure it out. As far as calling the code from the button press, I am using button2 library which uses callback functions. So I use the following code: ``` buttonEnter.setPressedHandler([](Button2 &btn){ pressed(dummyButton); if (currentSetSave == "YES"){ dstFlag=setDST; utcOffset = setUtcOffset; startWiFi(); mode = 1; settingsMode = 0; setTimeMode=0; selectSettingField = 0; } else{ selectSettingField = 0; } }); ``` However, I keep coming back to the fact that this code works on my esp32-C3 board. I'll get you logs if I can - Thanks!
Author
Owner

@Fishbone69 commented on GitHub (Nov 13, 2023):

I was trying to see if I could get info on the serial monitor and was actually able to run through the entire code in one instance (yes, it set the correct time from the server) although I made no significant changes to the code - just some Serial.println statements. The logs showed the following:

*wm:resetSettings 

*wm:SETTINGS ERASED 

*wm:StartAP with SSID:  ENCOM DW 1.0

*wm:AP IP address: 192.168.4.1

*wm:Starting Web Portal 

[ 42073][E][WebServer.cpp:649] _handleRequest(): request handler not found

*wm:7 networks found

*wm:Connecting to NEW AP: Beeman

*wm:connectTimeout not set, ESP waitForConnectResult... 

*wm:Connect to new AP [SUCCESS] 

*wm:Got IP Address: 

*wm:192.168.1.20 

*wm:config portal exiting 

Disconnecting

I was not able to get it to repeat that again, but if I remove power and repeat the button press, it seems to make it to different points in the startWiFi() subroutine before the esp32 restarts.

At first I was wondering if the devboard could have an emi issue with the WiFi causing a reset. But I don't think I would see that in 2 different esp32-S3 designs.

<!-- gh-comment-id:1807440727 --> @Fishbone69 commented on GitHub (Nov 13, 2023): I was trying to see if I could get info on the serial monitor and was actually able to run through the entire code in one instance (yes, it set the correct time from the server) although I made no significant changes to the code - just some Serial.println statements. The logs showed the following: ``` *wm:resetSettings *wm:SETTINGS ERASED *wm:StartAP with SSID: ENCOM DW 1.0 *wm:AP IP address: 192.168.4.1 *wm:Starting Web Portal [ 42073][E][WebServer.cpp:649] _handleRequest(): request handler not found *wm:7 networks found *wm:Connecting to NEW AP: Beeman *wm:connectTimeout not set, ESP waitForConnectResult... *wm:Connect to new AP [SUCCESS] *wm:Got IP Address: *wm:192.168.1.20 *wm:config portal exiting Disconnecting ``` I was not able to get it to repeat that again, but if I remove power and repeat the button press, it seems to make it to different points in the startWiFi() subroutine before the esp32 restarts. At first I was wondering if the devboard could have an emi issue with the WiFi causing a reset. But I don't think I would see that in 2 different esp32-S3 designs.
Author
Owner

@Fishbone69 commented on GitHub (Nov 13, 2023):

If I put the esp32-S3 in deep sleep then awaken it between attempts, I can get to the point where I can see the esp32-S3 on my android device - but upon trying to connect, it resets. Subsequent attempts cause it to reset immediately. Almost like an initialization issue. I dunno.

Finally, when building the code, I do get the following:

In file included from src/main.cpp:19:
.pio/libdeps/lolin_s3_mini/WiFiManager/WiFiManager.h:55:2: warning: #warning "WM_NOTEMP" [-Wcpp]
 #warning "WM_NOTEMP"
<!-- gh-comment-id:1807450717 --> @Fishbone69 commented on GitHub (Nov 13, 2023): If I put the esp32-S3 in deep sleep then awaken it between attempts, I can get to the point where I can see the esp32-S3 on my android device - but upon trying to connect, it resets. Subsequent attempts cause it to reset immediately. Almost like an initialization issue. I dunno. Finally, when building the code, I do get the following: ``` In file included from src/main.cpp:19: .pio/libdeps/lolin_s3_mini/WiFiManager/WiFiManager.h:55:2: warning: #warning "WM_NOTEMP" [-Wcpp] #warning "WM_NOTEMP" ```
Author
Owner

@tablatronix commented on GitHub (Nov 16, 2023):

Is this buttonEnter.setPressedHandler([] firing inside an interrupt?

<!-- gh-comment-id:1813698856 --> @tablatronix commented on GitHub (Nov 16, 2023): Is this `buttonEnter.setPressedHandler([]` firing inside an interrupt?
Author
Owner

@Fishbone69 commented on GitHub (Nov 16, 2023):

No, that is not

Is this buttonEnter.setPressedHandler([] firing inside an interrupt?

No. That is not inside an interrupt. I am still looking into this but got sidetracked a bit.

<!-- gh-comment-id:1814336463 --> @Fishbone69 commented on GitHub (Nov 16, 2023): No, that is not > Is this `buttonEnter.setPressedHandler([]` firing inside an interrupt? No. That is not inside an interrupt. I am still looking into this but got sidetracked a bit.
Author
Owner

@Fishbone69 commented on GitHub (Nov 18, 2023):

I apologize to this community for bothering you. It is a known problem with this series of boards:

https://esp32.com/viewtopic.php?t=28506

I will try to do more homework next time before starting an issue.

Again, apologies.

<!-- gh-comment-id:1817312651 --> @Fishbone69 commented on GitHub (Nov 18, 2023): I apologize to this community for bothering you. It is a known problem with this series of boards: [https://esp32.com/viewtopic.php?t=28506](https://esp32.com/viewtopic.php?t=28506) I will try to do more homework next time before starting an issue. Again, apologies.
Author
Owner

@tablatronix commented on GitHub (Nov 18, 2023):

#1478

<!-- gh-comment-id:1817368345 --> @tablatronix commented on GitHub (Nov 18, 2023): #1478
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1420
No description provided.