WiFi STA (Station) mode refers to the operating mode of a WiFi-enabled device, such as a microcontroller or IoT device, when it acts as a client that connects to an existing wireless network. In this mode, the device functions as a WiFi station or client and can communicate with other devices on the network or access resources available on the internet.
When an ESP32 or similar device is set to WiFi STA mode, it can connect to an access point (AP) by providing the SSID (network name) and password. Once connected, it obtains an IP address from the AP and can send and receive data over the network.
You have the option to manually specify the IP configuration for the ESP32. Alternatively, the ESP32 can obtain the IP configuration from the DHCP service provided by the Wireless Access Point (WAP). However, in the case of an ESP32 powered by a battery, it is advisable to use manual IP configuration as it helps conserve power.
The follolwing methods are used in the sample code.
WiFi.config() | Set Manual IP Configuration |
WiFi.begin() | Start Wifi Connection in Non-Blocked Mode |
WiFi.status() | Get Current WIFI Status |
WiFi.localIP() | ESP32's Local IP Address |
WiFi.macAddress() | ESP32's Mac Address |
WiFi.subnetMask() | ESP32's Subnet Address |
WiFi.gatewayIP() | ESP32's Getway IP Address |
WiFi.dnsIP() | ESP32's DNS IP Address |
WiFi.SSID() | Wireless AP's name |
WiFi.BSSIDstr() | Wireless AP's Mac Address |
WiFi.channel() | Wireless Channel |
WiFi.RSSI() | Wireless Signal Strength |
To switch to DHCP instead, simply modify the #define STATIC_IP 0
line to #define STATIC_IP 1
.