There are several solutions available like Espressifs Smartconfig or WiFiManager.
My approach is not to use WiFi to configure the WiFi credentials of an ESP32 module, but to do it over Bluetooth Low Energy (BLE).
To achieve this, the code includes a BLE server that is advertising a custom service. An Android phone or tablet (sorry, I cannot write apps for Iphones) then can connect to this BLE server and the user can setup the WiFi configuration of the phone.
How does it work?
When the ESP32 is powered up it starts a BLE server and advertises a custom service to setup, check or erase the WiFi credentials. The Android app will find the ESP32 BLE server:
In case you want to use two AP settings, the switch button “Enable two AP” will show the edit boxes for the second AP:
The small text field at the bottom will show some debug messages during the process.
- Full project description: ESP32 WiFi setup over BLE (ESP32 code)
- Source code for ESP32 code: ESP32_WiFi_BLE_ANDROID
- Source code for Android code: ESP32_WiFi_BLE_ESP32
- Google Play link for the Android app: ESP32 WiFi setup over BLE