2

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.

The core version is "esp32 by Espressif Systems" 2.0.11.

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(ssid, password);

  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:

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

Edit:

I added some code to do a ping to the gateway after establishing the connection:

  IPAddress ip (192, 168, 1, 1);
  bool ret = Ping.ping(ip);

And timed it. Every ping took about 4-5 seconds. So, it's not just slow to connect to the WiFi network, it's also very slow do ping, and probably to do everything else.

Edit on edit: After turning on verbose logging, I realized that what ping actually does is to the effect of ping -c 5, with 1 second between pings. So, it does take 4ish seconds no matter what. Originally I thought it only sent one ping per call.

5
  • Got it. Thanks. It's "esp32 by Espressif Systems" 2.0.11
    – Deling Ren
    Mar 14 at 22:32
  • Welcome to SE/Arduino! Please take the tour to learn how this site works, and read some pages of the help center. Is your comment the solution to your issue? If so, please write an actual answer and mark it as accepted. This is not a forum. Mar 15 at 6:47
  • @thebusybee "Is your comment the solution to your issue?" Comments were deleted that would have made it easier for you to see that it isn't an answer to their question. It is a response to being asked for the core version they used, and then having that question about core version explained to them, which is what they then understood ("got it") and then replied with ("2.0.11").
    – timemage
    Mar 15 at 18:11
  • @timemage Then now, after I added this information to the question, where it belongs, that misleading comment can be deleted, too. Mar 15 at 18:32
  • That probably should have been done by whoever deleted the comments. Mostly I just didn't want them fighting a re-open over the confusion.
    – timemage
    Mar 15 at 18:37

1 Answer 1

4

Huh, I just tried a 3rd board and I think I have found the root cause. If the board is inserted in a breadboard. It's slooooooow, or even impossible to connect. But if I pull it out, it seems to connect in a few seconds. So, I guess the problem really is the breadboard interfering with the on-board antenna. I'll probably need to get a 32U with an external antenna connector for the final product.

2
  • that's very good troubleshooting ... if the final product does not contain a large metal part, then the external antenna may not be required
    – jsotola
    Mar 15 at 23:35
  • Thanks. I'm working on a garage opener, so it'll need to close to the motor which is mounted on the ceiling with angle beams. And the WiFi signal is probably not the best in the house. I'll get the software part figured out first. We'll see.
    – Deling Ren
    Mar 17 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.