Wi-Fi Smart Configuration on ESP32 controller

Previously inĀ “Scanning of WiFi on ESP32 controller”, we used WiFi class to connect to a WiFi network “WiFi.begin(ssid, password)”. Here we use “hard-coded” ssid and password. It is really inconvenient when we bring our ESP32 to another WiFi network, we have to modify ssid and password according to the new network, recompile and flash new code. So in this tutorial, “Wi-Fi Smart Configuration on ESP32 controller” there is a technique to overcome this called “SmartConfiguration”. In order to do SmartConfiguration, you need a smartphone or tablet (Android or iOS) that is connected to WiFi network (which you want ESP32 to connect to). Installed a special application like ESP8266 SmartConfig” (this is for ESP8266 but you can use it for ESP32):

The library to use will be:

#include "WiFi.h"

Set ESP32 to Station mode (To run SmartConfig it must be set to Station mode) and start smart configuration.

WiFi.mode(WIFI_AP_STA);
WiFi.beginSmartConfig();

Waiting for smart configuration packet from mobile and Checking smart configuration done or not.

while (!WiFi.smartConfigDone())

Then wait for the wifi to connect to AP.

while (WiFi.status() != WL_CONNECTED)

From smartphone (connected to WiFi) do:
Open the application (ESP8266 SmartConfig)-> fill ssid and password and then press the Confirm button.

Wi-Fi Smart Configuration on ESP32 controller

Load Arduino project WiFiSmartConfig,

Wi-Fi Smart Configuration on ESP32 controller1

 

From Terminal SmartConfig done, ESP32 join WIFi network with IP address