Some of the links in this post are affiliate links and if you go through them to make a purchase I will earn a commission. Keep in mind that I link these companies and their products because of their quality and not because of the commission I receive from your purchases. The decision is yours, and whether or not you decide to buy something is completely up to you. Read more
ESP32 development board can be used as WiFi router/repeater with NAT(Network Address Translation), thanks to martin-ger, who developed this great firmware for that purpose.
For Linux /dev/ttyUSB0 is the name of the serial port, make sure that you specify the name of the serial port to which ESP32 is connected. While for Windows, serial ports are named something like COM1, COM2 and so on.
After first power up, your new ESP32 router will create an open WiFi network with SSID “ESP32_NAT_Router”.
Now, you can configure your ESP32 router, either using simple web interface or via the serial console.
Configuration via web interface
Connect your PC or smartphone to the open WiFi network “ESP32_NAT_Router”.
Open your browser and go to “http://192.168.4.1“. Subsequently, you should have the following page on your screen:
At first, enter the correct values for the uplink WiFi network, in the STA Settings section. For open networks, leave the password field blank. Then, press Connect. After that, the ESP32 will reboot and connect to your WiFi AP.
Now, you reconnect and reload the page again, then you modify the AP Settings. So, you enter a new SSID and password for your ESP32 router. Then, click Set, the ESP32 will reboot again and its ready to forward traffic over the newly configured AP. If you want to make further changes, you need to connect to the newly configured AP.
Because the web interface is not secure and not protected with a password, anyone can open it and modify the settings. To get around that, the web interface can be disabled via the command line interface by the following commands:
Connect your ESP32 to the USB port of your computer.
Open the serial port to which your ESP32 is connected, using Putty or any other serial terminal with baud rate set to 115200 bps.
After successful connection, type the following command, replacing <ssid> and <password> with your uplink WiFi network SSID and password respectively.
esp32>set_sta <ssid> <password>
Now, using the “set_ap” command, you set your ESP32 access point SSID and password.
esp32>set_ap <ssid> <password>
Finally, type “restart” to reboot the ESP32 with your new configurations.
During configuration, If you want to enter non-ASCII or special characters (such as ‘ ‘) within your SSID or password, you have to use HTTP-style hex encoding (e.g. “Access%20Point” results in a string “Access Point”).
If you made a mistake and you can’t communicate with the ESP32 anymore, you can use the serial console to reconfigure it. The parameter settings are stored in NVS(Non Volatile Storage), which will not be erased by re-flashing the binaries. However, you can wipe it out, by this command esptool.py -p /dev/ttyUSB0 erase_flash
In the serial console, if you want to show the current configurations use show command. And you can type help to get the full list of available commands.