Description
Board
ESP32-S3
Device Description
ESP32-S3 : AI Thinker ESP-S3-12K FLASH 4Mb PSRAM 8Mb
Test has also been done (not shown) with :
ESP32-S2 : SAOLA WROVER FLASH 4Mb PSRAM 8Mb
ESP32 : LILYGO T8 V.1.7.1 4Mb PSRAM 8Mb
Hardware Configuration
Nothing is attached to development board, excepted USB cable between computer and development board (ie bare development board)
Version
v2.0.4
IDE Name
Arduino IDE
Operating System
Windows 10
Flash frequency
80 Mhz
PSRAM enabled
yes
Upload speed
115200
Description
On ESP32-S3, WIFI is KO when triggering starting (#1), stopping and (re)starting (#2) Wifi with ESPAsyncWebServer.
Same KO behaviour for ESP32-S2.
Note this issue does not occur on ESP32 : in other words, it is possible to start/stop/(re)start wifi on ESP32. Maybe there is a regression on ESP32-S3 and ESP32-S2, or the way to stop/(re)start Wifi has changed on ESP32-S3 and ESP32-S2 as compared to ESP32 ?
Such sequence is needed for project because user should be able to activate/deactivate Wifi on his/her own. Since Wifi consumes resources/battery, Wifi should be off when/if user does not need it. Project relies on batteries for power.
On ESP32-S3 (and ESP32-S2), the only way to reactivate Wifi after (re)start #2 is to reboot, which is not user friendly.
Tests have also been done with Wifi Station (not shown) : same KO behaviour for ESP32-S3 and ESP32-S2, and OK behaviour for ESP32. So it seems that issue is not due to Wifi Access Point vs Wifi Station (since same issue occurs) but to ESP32-S3 and ESP32-S2.
Sketch
See sketch and html page below
------
SKETCH
------
// Wifi issue "start stop start", esp32s3 ko, esp32s2 ko, esp32 ok, Sep 19 2022
// Debugging
char* TAG = "TEST";
// LittleFS
// ========
#include <LittleFS.h>
// STORAGE
// =======
#define STORAGE LittleFS // file system to use for Web static files (html, png, ...) : SD, LittleFS, SPIFFS, ...
// Wifi & Web Server Espressif
// ===========================
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h> // includes Wifi.h : #ifdef ESP32 #include <WiFi.h>
// Web Server
// ==========
// Set IP addresses
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
IPAddress ipAccessPoint; // IP adress for Wifi Access Point, usually 192.168.4.1, retrieved with softAPIP()
// Access point
const char* ssid_accesspoint = "ESP32_AP";
const char* password = "password_";
// Create AsyncWebServer "server" on port 80 https://github.com/me-no-dev/ESPAsyncWebServer#the-async-web-server
AsyncWebServer server(80);
// Create AsyncWebSocket "ws" https://github.com/me-no-dev/ESPAsyncWebServer#async-websocket-plugin
AsyncWebSocket ws("/ws");
// Setting up the server
// ---------------------
// https://github.com/me-no-dev/ESPAsyncWebServer#setting-up-the-server
void onRequest(AsyncWebServerRequest *request){
//Handle Unknown Request
request->send(404);
}
// Send asynchroneous message to brower(s) using web socket, usually for notifying error message (displayed in javascript popup window)
void notifyClients(String state) {
ws.textAll(state);
}
// Parse web socket message parameters and trigger action accordingly
void handleWebSocketMessage(void *arg, uint8_t *data, size_t len) {
AwsFrameInfo *info = (AwsFrameInfo*)arg;
char * data_tok; // local variable to split data by token ":"
if (info->final && info->index == 0 && info->len == len && info->opcode == WS_TEXT) {
data[len] = 0;
// ... not needed for test
}
}
void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type,
void *arg, uint8_t *data, size_t len) {
switch (type) {
case WS_EVT_CONNECT:
ESP_LOGI(TAG,"WebSocket client #%u connected from %s", client->id(), client->remoteIP().toString().c_str());
break;
case WS_EVT_DISCONNECT:
ESP_LOGI(TAG,"WebSocket client #%u disconnected", client->id());
break;
case WS_EVT_DATA:
ESP_LOGI(TAG,"handleWebSocketMessage(arg, data, len) id %s len %d", data, len);
handleWebSocketMessage(arg, data, len);
break;
case WS_EVT_PONG:
ESP_LOGI(TAG,"WebSocket client PONG");
break;
case WS_EVT_ERROR:
ESP_LOGI(TAG,"WebSocket client EVTERROR");
break;
}
}
void notFound(AsyncWebServerRequest *request) {
String logmessage = "Client:" + request->client()->remoteIP().toString() + " " + request->url();
ESP_LOGE(TAG, "ERROR notFound %s", logmessage.c_str());
request->send(404, "text/plain", "Not found");
}
void wifiStart() { // init Wifi, set preferences and play sound accordingly
WiFi.softAP(ssid_accesspoint, password);
ipAccessPoint = WiFi.softAPIP();
WiFi.mode(WIFI_MODE_AP); // set mode to Access Point
// attach AsyncWebSocket
ws.onEvent(onEvent);
server.addHandler(&ws);
// Route for web pages
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(STORAGE, "/home.html", "text/html", false);
});
server.on("/home", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(STORAGE, "/home.html", "text/html", false);
});
// attach file system root at url /
server.serveStatic("/", STORAGE, "/");
// Catch-All Handlers
// Any request that can not find a Handler that canHandle it ends in the callbacks below.
server.onNotFound(onRequest);
//server.onFileUpload(onUpload);
// server.onRequestBody(onBody);
// Start server
server.begin(); // class of server is "AsyncWebServer", defined in "ESPAsyncWebServer.h"
ESP_LOGD(TAG,"Wifi : Init OK");
if (WiFi.getMode()==WIFI_MODE_AP) { // Access point
ESP_LOGI(TAG,"softAPSSID: %s",ssid_accesspoint);
ESP_LOGI(TAG,"softAPIP: %s", ipAccessPoint.toString().c_str());
ESP_LOGI(TAG,"mode: %d", WiFi.getMode());
}
} // end wifiStart
// =======================================================================
// setup
// =======================================================================
void setup()
{ Serial.begin(115200);
// LittleFS
// ======
if (!LittleFS.begin(true)) ESP_LOGE(TAG, "ERROR : An error has occurred while mounting LittleFS");
} // end setup()
// =======================================================================
// loop
// =======================================================================
void loop() {
ESP_LOGD(TAG,"Wifi : Setting AP (Access Point) %s",ssid_accesspoint);
// Wifi start #1
wifiStart();
ESP_LOGI(TAG,"----------------- :-) ------------------->");
ESP_LOGD(TAG,"After Wifi start #1, NO ISSUE : Web page is reachable on Wifi Access Point for ESP32-S3");
ESP_LOGD(TAG,"See screenshot #1");
ESP_LOGD(TAG,"Not shown : Web page is also reachable on Wifi Access Point for ESP32-S2 and ESP32");
ESP_LOGD(TAG,"Not shown : Same OK behaviour with Wifi Station");
ESP_LOGI(TAG,"----------------------------------------->");
vTaskDelay(60000 / portTICK_PERIOD_MS);
// Wifi stop
WiFi.disconnect(true); // Disconnect from the network
WiFi.mode(WIFI_OFF); // Switch WiFi off
vTaskDelay(30000 / portTICK_PERIOD_MS);
// Wifi Start #2
wifiStart();
ESP_LOGI(TAG,"----------------- :-/ ------------------->");
ESP_LOGD(TAG,"After Wifi start #2, ISSUE : Web page is no longer reachable on Wifi Access Point for ESP32-S3 (Wifi network no longer visible)");
ESP_LOGD(TAG,"See screenshot #2");
ESP_LOGD(TAG,"Not shown : ESP32-S2 is also KO, but ESP32 is OK");
ESP_LOGD(TAG,"Not shown : Same issue with Wifi Station");
ESP_LOGI(TAG,"----------------------------------------->");
// endless loop
while (true) {
ESP_LOGD(TAG,"loop ...");
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
} // end loop
----
HTML
----
<!DOCTYPE html>
<html>
<head>
<title>TEST</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Hello World :-) </h1>
</body>
</html>
Debug Message
See serial output below (verbose)
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x43c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2a3c
SHA-256 comparison failed:
Calculated: 3611f330726ad4edf64f62982b0568332a5800bc59425cab90be5379db92c108
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x403c98d8
[ 1062][I][esp32-hal-psram.c:96] psramInit(): PSRAM enabled
[ 1073][D][ESP32-S3_wifistartstopstart_test.ino:144] loop(): [TEST] Wifi : Setting AP (Access Point) ESP32_AP
[ 1081][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 1116][V][WiFiGeneric.cpp:390] _arduino_event_cb(): AP Started
[ 1116][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 10 - AP_START
[ 1118][D][ESP32-S3_wifistartstopstart_test.ino:119] wifiStart(): [TEST] Wifi : Init OK
[ 1126][I][ESP32-S3_wifistartstopstart_test.ino:121] wifiStart(): [TEST] softAPSSID: ESP32_AP
[ 1134][I][ESP32-S3_wifistartstopstart_test.ino:122] wifiStart(): [TEST] softAPIP: 192.168.4.1
[ 1142][I][ESP32-S3_wifistartstopstart_test.ino:123] wifiStart(): [TEST] mode: 2
[ 1150][I][ESP32-S3_wifistartstopstart_test.ino:148] loop(): [TEST] ----------------- :-) ------------------->
[ 1159][D][ESP32-S3_wifistartstopstart_test.ino:149] loop(): [TEST] After Wifi start #1, NO ISSUE : Web page is reachable on Wifi Access Point for ESP32-S3
[ 1173][D][ESP32-S3_wifistartstopstart_test.ino:150] loop(): [TEST] See screenshot #1
[ 1181][D][ESP32-S3_wifistartstopstart_test.ino:151] loop(): [TEST] Not shown : Web page is also reachable on Wifi Access Point for ESP32-S2 and ESP32
[ 1194][D][ESP32-S3_wifistartstopstart_test.ino:152] loop(): [TEST] Not shown : Same OK behaviour with Wifi Station
[ 1204][I][ESP32-S3_wifistartstopstart_test.ino:153] loop(): [TEST] ----------------------------------------->
[ 8273][V][WiFiGeneric.cpp:405] _arduino_event_cb(): AP Station Connected: MAC: 8c:c6:81:ef:1e:7e, AID: 1
[ 8274][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 12 - AP_STACONNECTED
[ 8294][V][WiFiGeneric.cpp:419] _arduino_event_cb(): AP Station IP Assigned:192.168.4.2
[ 8294][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 14 - AP_STAIPASSIGNED
[ 61216][V][WiFiGeneric.cpp:412] _arduino_event_cb(): AP Station Disconnected: MAC: 8c:c6:81:ef:1e:7e, AID: 1
[ 61216][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 13 - AP_STADISCONNECTED
[ 61216][V][WiFiGeneric.cpp:393] _arduino_event_cb(): AP Stopped
[ 61228][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 11 - AP_STOP
[ 91274][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 91284][V][WiFiGeneric.cpp:390] _arduino_event_cb(): AP Started
[ 91284][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 10 - AP_START
[ 91286][D][ESP32-S3_wifistartstopstart_test.ino:119] wifiStart(): [TEST] Wifi : Init OK
[ 91294][I][ESP32-S3_wifistartstopstart_test.ino:121] wifiStart(): [TEST] softAPSSID: ESP32_AP
[ 91302][I][ESP32-S3_wifistartstopstart_test.ino:122] wifiStart(): [TEST] softAPIP: 192.168.4.1
[ 91310][I][ESP32-S3_wifistartstopstart_test.ino:123] wifiStart(): [TEST] mode: 2
[ 91318][I][ESP32-S3_wifistartstopstart_test.ino:163] loop(): [TEST] ----------------- :-/ ------------------->
[ 91327][D][ESP32-S3_wifistartstopstart_test.ino:164] loop(): [TEST] After Wifi start #2, ISSUE : Web page is no longer reachable on Wifi Access Point for ESP32-S3 (Wifi network no longer visible)
[ 91345][D][ESP32-S3_wifistartstopstart_test.ino:165] loop(): [TEST] See screenshot #2
[ 91352][D][ESP32-S3_wifistartstopstart_test.ino:166] loop(): [TEST] Not shown : ESP32-S2 is also KO, but ESP32 is OK
[ 91363][D][ESP32-S3_wifistartstopstart_test.ino:167] loop(): [TEST] Not shown : Same issue with Wifi Station
[ 91372][I][ESP32-S3_wifistartstopstart_test.ino:168] loop(): [TEST] ----------------------------------------->
[ 91382][D][ESP32-S3_wifistartstopstart_test.ino:171] loop(): [TEST] loop ...
[ 96389][D][ESP32-S3_wifistartstopstart_test.ino:171] loop(): [TEST] loop ...
[101389][D][ESP32-S3_wifistartstopstart_test.ino:171] loop(): [TEST] loop ...
Other Steps to Reproduce
As stated above, issue :
- does not occur with ESP32
- occurs also with Wifi Station
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.