Hi all, I am having some issues with connecting to WiFi with an ESP32 board. It is very sloooooooooow. The first few times I tried, I left it alone for 20 minutes and it still wasn't able to connect. So I thought it didn't work. So I tried to use MicroPython and ESP-IDF and they both worked, although MicroPython was somewhat slow (~10-20 seconds), but ESP-IDF was instantaneous. Then I went back to Arduino and this time it eventually connected after 260 seconds (> 4 minutes). Another try took 420 seconds (7 minutes). Has anyone else seen similar issues?
What I have tried:
- Tried another board of the same model to ensure it's not defective.
- Tried a different WiFi AP with the same results.
Although MicroPython and ESP-IDF framework work fine, I am still hoping to stick with Arduino for its simplicity and my hatred for Python, but don't hold it against me if you're fond of it :-).
My board:
ESP-WROOM-32(https://www.amazon.com/gp/product/B0B764963C). In Arduino IDE, I'm choosing "ESP32-WROOM-DA Module". I have also tried "uPesy ESP32 Wroom DevKit" with the same results.
My network setup:
TP-Link EAP225, running as a dedicated AP, not a router. My router is Linksys WRT1900ACS running OpenWrt 19.07.2 r10947-65030d81f3.
The other setup I tried is a D-Link DIR-842 running as both an AP and a router, although I didn't connect the upstream port.
My code:
#include <WiFi.h>
const char* ssid = "delingtest";
const char* password = "XxxxxYyyy00";
void setup() {
Serial.begin(115200);
Serial.println(millis()); // To time the connection
Serial.print("Connecting to WiFi network ");
Serial.print(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin();
do {
Serial.print(".");
delay(5000);
} while (!WiFi.isConnected());
Serial.println("done.");
Serial.println(millis()); // To time the connection
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
}
Additional info:
- When I used MicroPython, I did it interactively. Reference: 4. Network basics — MicroPython latest documentation
- For ESP-IDF, I used sample code here: esp-idf/examples/wifi/getting_started/station at master · espressif/esp-idf · GitHub
- I checked the log on the router (running OpenWRT), the time between receiving the DHCP request and offering the IP address was quick (see below). So it's not the AP's problem. Plus, I have tons of other devices on this WiFi network and they all work fine.
Wed Mar 13 16:57:55 2024 daemon.info dnsmasq-dhcp[13394]: DHCPDISCOVER(br-lan) 40:22:d8:78:7a:38
Wed Mar 13 16:57:55 2024 daemon.info dnsmasq-dhcp[13394]: DHCPOFFER(br-lan) 192.168.1.145 40:22:d8:78:7a:38
Wed Mar 13 16:57:55 2024 daemon.info dnsmasq-dhcp[13394]: DHCPREQUEST(br-lan) 192.168.1.145 40:22:d8:78:7a:38
Wed Mar 13 16:57:55 2024 daemon.info dnsmasq-dhcp[13394]: DHCPACK(br-lan) 192.168.1.145 40:22:d8:78:7a:38 esp32-787A38