Menu Close

ESP32


There are several modules with ESP32, the one I have is ESP-WROOM-32 made by Heltec.

Trouble connecting to WiFi

I have internet available through two routers, an older Belkin router, and a newer ZTE router that runs on both 2.4GHz and 5GHz simultaneously.

When I first programmed ESP32 to connect with the ZTE router, it didn’t connect. This router has a long ssid with spaces in it, so I thought maybe that’s the issue, or I have made some typing error. Then I tried to connect it with the Belkin router and it worked.

Later on, I tried to connect it with the ZTE router again as I needed it to be visible to other devices on that network, and this time it connected. Again, my thought was that last time I probably typed the ssid or password wrong.

After some time, programmed another unit to connect to the ZTE router but it wouldn’t. This time I knew that the ssid and password are correct as they were saved in the “sketch”. Puzzled, I connected it to the Belkin router and it connected.

As this didn’t make much sense, I searched on google if others were having similar issues, and sure enough there were many on the forums. Most of them had no response, while some had long discussions with people suggesting different things, but I didn’t see a solution. Some thought it was the router blocking these devices for some reason, and suggested whitelisting the mac address. I tried that, but the problem persisted.

Then I thought if I spoofed the mac address of the device that is working, I could confirm if it was the router blocking some devices. Examples of reading and changing the mac address are found here. That led to the solution, I had two libraries installed for ESP32, the older library didn’t work with the new router.

Solution

If you select Heltec WiFi Kit 32 board from the ESP32 Arduino list, it works, the WiFi library in it is version 1.0.6.

This WiFi Kit 32 board from Heltec ESP32 Arduino list doesn’t work, it has an older WiFi library.

If you are facing similar problems, look for a different library.

Heltec ESP-WROOM-32 WiFi Kit pinout and datasheet

Note: Pin 18, GPIO11, Flash CMD is marked as GND on the sticker that came with it. However, it’s not GND, they have mistakenly typed CMD as GND.

Datasheet from Espressif is available here.


Issue with Arduino IDE Serial Monitor

The Serial Monitor doesn’t connect automatically after you re-insert the USB cable, even if it is the same COM port that it was connected through earlier. If you select the same COM port number again in Arduino IDE which is already selected, the serial connection re-establishes.

Arduino IDE works fine with other devices, so this is probably some peculiarity of ESP32.


Access to XMLHttpRequest at “source” from origin ‘null’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource

I was getting this error in the browser on PC, while accessing a json request from ESP32. The solution is simple when you find it. If using Arduino IDE to program, call server.enableCORS(): somewhere before calling server.begin();

 1,859 total views,  5 views today

Leave a Reply

Your email address will not be published. Required fields are marked *