ESP32 WIFI Connection Guide
Using ESP32, the most commonly used feature is its WIFI functionality. esptutorial (esptutorial.com) shares how to connect ESP32 to WIFI (join a WIFI access point/wireless router), and after a successful connection, obtain the IP address and check the WIFI strength.
Program Highlights
The steps to connect ESP32 to WIFI are roughly as follows:
First, use WiFi.mode() to configure the ESP32 WIFI mode. Note that in most programs, the WIFI mode is set first, so it is defined as a priority. However, in this example, the WIFI mode is not set, and it can still connect to the WIFI access point. After a successful connection, the WIFI mode is WIFI_STA.
Start connecting to the WIFI access point using WiFi.begin(ssid, pwd), where the WIFI name (SSID) and WIFI password are configured.
Determine the WIFI connection status by checking the return value of WiFi.status() and wait for a successful connection.
After a successful connection, you can use WiFi.localIP() to check the IP address.
After a successful connection, you can use WiFi.RSSI() to check the WIFI strength.
Reference for Wifi methods:
https://lingshunlab.com/book/esp32/esp32-wifi-reference
Program Code
1 | // welcome to lingshunlab.com |
After uploading the program, open the serial monitor to view the following information: