I met a problem in ESP32, that I have to reprogram the ESP32 everytime I changed a location, This tutorial shows how to connect ESP32 to wiFi without programming.
1. Problem I met in ESP32
In the past, I used to program ESP32 for setting or changing the wifi. Once changing the wifi, I would reprogram the ESP32. when I showed my ESP32 project elsewhere, the ESP32 was not working because of the wifi. and I must to set the ESP32 to change wifi. It was very troublesome to change the wifi.
As a member of the makerfabs, I reported this problem to my team and had found a solution.
2. How to connect ESP32 to WiFi?
First, ESP32 has to get the WiFi name and password to connect to wifi. In the past, the wifi information can be in code and programed to ESP32. How to transmit it to esp32 without programming is a difficulty.
3. Transmit wifi information to ESP32
After the development and testing by Makerfabs, the wifi information can be transmitted from the phone to ESP32. Set the working mode of ESP32 to AP mode and build wifi that the phone connects it. And the same time set ESP32 to establish the server that the phone can log in to input the wifi information. then the ESP32 can obtain the information from the server.
4. Store wifi information
One problem came when the EPS32 reboot or not power supply:the wifi information would be lost and the ESP32 couldn’t connect to wifi next power on. So the information had to be store without being affected by the restart of the ESP32. Non-volatile storage (NVS) library is designed to store key-value pairs in flash. The information would be store in the NVS as the key. now, ESP32 can be connected to the wifi with the information read from the flash when it re-start.
5. How to do
Makerfabs have been complete the program by Arduino. The program is available for the need and can be obtained from here.
Next, the following steps will show how to use:
1. The preparation: PC, phone, ESP32 board (I used the ESP32 board of the Makerfabs )
2. Open the program by the Arduino IDE, upload it to the board.
3. Use the phone to connect the wifi “makerfabs-ap” build by the esp32.
4. Enter the address “192.168.4.1” to log in the server in the browser. (notice: because of the technical difficulty, the chrome app is recommended to use and the other browsers maybe be not working.)
Below are the screenshot when setting the WiFi to ESP32:
5. Enter your wifi information on the browser page.
6. The ESP32 board connects to the wifi after seconds.
7. If want to change the wifi connected, restart the ESP32 and put the IO21 level to low in three minutes. The esp32 will set the AP mode. You can follow the above steps to change the new wifi.
6. Result
Just after downloading the program, ESP32 can be connect or changed the wifi without re-uploading the program, which is very convenient for people who have little or not Arduino and programming knowledge. It is suitable to use in the ESP32 project which will be shared with friends that his wifi is different.
7. Video Guide
If you have other solutions, you're welcome to leave us message to service@makerfabs.com.