ESP32 softAP troubles - can't connect
Posted: Wed Sep 28, 2022 9:34 am
Hi. I want esp32 to start own access point with fixed IP in setup mode and start web server. So I write a code:
And yes - this activates wifi access point but I just can't connect to it. Windows 10 OS show error "Can't connect to this network" and its eventlog say "This network in inaccessible / RSSI: 255". Android phone connects silently buy ip address is wrong and device webserver can't be riched. Sometimes (VERY RARE) windows is able to connect and after connect all works and webserver is available.
I'm using vscode with platformio and added "build_flags = -DCORE_DEBUG_LEVEL=10". Sometimes I can see some ap related lines in serial output:
This is a log from vscode uploading a filesystem image:
And plaitformio.ini:
Espressif 32 version: 5.1.1+sha.4901957
Also I tried another esp32 module with builtin antenna and result was same.
In normal (non-setup) mode device connects to AP (fast and reliable), receive ip and is able to send/receive data
What i'm doing wrong ?
Code: Select all
void start_board_webserver() {
IPAddress local_ip(192, 168, 4, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.persistent(false);
WiFi.softAPConfig(local_ip, local_ip, subnet, IPAddress(192, 168, 4, 100));
WiFi.softAP("FCOLLECTOR");
delay(2000);
IPAddress myIP = WiFi.softAPIP();
Serial.println("WIFI AP started for setup on " + myIP.toString());
server.on("/", webHandleRoot);
server.serveStatic("/css", LittleFS, "/css", "max-age=43200");
server.onNotFound(webHandleNotFound);
server.begin();
Serial.println("Setup webserver started on port 80");
}
void start_board_sensors_setup() {
while (true) {
esp_task_wdt_reset();
server.handleClient();
// return to normal mode if jumper removed
pinMode(BOARD_SETUP_PIN, INPUT_PULLUP);
if (digitalRead(BOARD_SETUP_PIN) == HIGH) {
device_deep_sleep();
}
pinMode(BOARD_SETUP_PIN, INPUT);
}
}
void setup() {
......
pinMode(BOARD_SETUP_PIN, INPUT_PULLUP);
sleep(1);
if (digitalRead(BOARD_SETUP_PIN) != HIGH) {
indicate_setup_mode();
start_board_webserver();
start_board_sensors_setup();
}
pinMode(BOARD_SETUP_PIN, INPUT);
......
}
I'm using vscode with platformio and added "build_flags = -DCORE_DEBUG_LEVEL=10". Sometimes I can see some ap related lines in serial output:
Code: Select all
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
onfigsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00hd_drv:0x00,w_r:0x00
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,en:3036
entry 0x4008054
[ 2][V][WiFiServer.h:42] WiFiServer(): WiFiServer::WiFiServer(port=80, ...)
[ 3][V][WebServer.cpp:85] WebServer(): WebServer::Webserver(port=80)
[ 9][D][esp32-hal-cpu.c:214] setCpuFrequencyMhz(): PLL: 320 / 4 = 80 Mhz, APB: 80000000 Hz
E (1347) psram: PSRAM ID read error: 0xffffffff
[ 17][W][esp32-hal-psram.c:71] psramInit(): PSRAM init failed!
[ 2194][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 2317][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring SoftAP static IP: 192.168.4.1, MASK: 255.255.255.0, GW: 192.168.4.1
[ 2317][V][WiFiGeneric.cpp:390] _arduino_event_cb(): AP Started
[ 2324][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 10 - AP_START
[ 2331][V][WiFiGeneric.cpp:143] set_esp_interface_ip(): SoftAP: 192.168.4.1 | Gateway: 192.168.4.1 | DHCP Start: 192.168.4.100 | Netmask: 255.255.255.0
[ 2344][V][WiFiGeneric.cpp:190] set_esp_interface_ip(): DHCP Server Range: 192.168.4.100 to 192.168.4.110
[ 2356][V][WiFiGeneric.cpp:393] _arduino_event_cb(): AP Stopped
[ 2359][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 11 - AP_STOP
[ 2360][V][WiFiGeneric.cpp:390] _arduino_event_cb(): AP Started
[ 2372][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 10 - AP_START
WIFI AP started for setup on 192.168.4.1
[ 4383][V][RequestHandlersImpl.h:73] StaticRequestHandler(): StaticRequestHandler: path=/css uri=/css isFile=0, cache_header=max-age=43200
Setup webserver started on port 80
ADC analog value = 4.198
Battery level 100
Code: Select all
Serial port COM4
Connecting....
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 10:97:bd:12:5f:fc
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00210000 to 0x003fffff...
Compressed 2031616 bytes to 7847...
Writing at 0x00210000... (100 %)
Wrote 2031616 bytes (7847 compressed) at 0x00210000 in 11.5 seconds (effective 1408.9 kbit/s)...
Hash of data verified.
Code: Select all
[platformio]
[env:upstream_develop]
platform = espressif32
board = denky32
framework = arduino
lib_deps =
danilopinotti/Battery_18650_Stats@^1.0.0
pstolarz/OneWireNg@^0.12.0
board_build.f_cpu = 80000000L
board_build.f_flash = 40000000L
board_build.partitions = no_ota.csv
board_build.filesystem = littlefs
build_flags = -DCORE_DEBUG_LEVEL=10
upload_port = COM4
Also I tried another esp32 module with builtin antenna and result was same.
In normal (non-setup) mode device connects to AP (fast and reliable), receive ip and is able to send/receive data
What i'm doing wrong ?