How to make dynamic wifi setup with ESP8266

Hello All,

Is it possible to program EP8266 and variants like ESP01/ NodeMcu/WeMos D1 to provide an interface to enter wifi credentials and save?

Example: Assume that I have a WeMos D1 with my Wifi credentials inside the code. Now if i want to demonstrate at a different place, with different Wifi connection, how can i do it [without uploading code again with new credentials]?

I am looking for dynamic way. Please suggest

thanks

Build a captive portal with Webserver + DNSserver. Use either a button to switch from station to ap mode or check if you can connect in a decent time (e.g. 15 seconds) and switch to ap if unseccessful. save ssid+password in eeprom.

The thing I currently work saves SSID + password in EEPROM, BSSID + IP + gateway is stored in RTC RAM. BSSID is never stored in EEPROM. First connection after poweron takes ~ 7 seconds to connect with DHCP, successive connections after deepsleep take 2 seconds. Don't think I can reduce that 2 seconds, but it's kind of ok.

there is also this solution: https://github.com/tzapu/WiFiManager

6v6gt: there is also this solution: https://github.com/tzapu/WiFiManager

Many Thanks. Can I ask you to confirm - . Install and Include WifiManager library . include the provided headers . initialize WiFiManager wifiManager; . add below in setup //first parameter is name of access point, second is the password wifiManager.autoConnect("AP-NAME", "AP-PASSWORD");

I am assuming that AP-NAME and AP-* are the values, entered in Autoconnect AP page

but I dont know whether to issue save config or not. I do power off the device, most of the time.

I found the below -

https://community.mydevices.com/t/esp8266-wifi-and-cayenne-credential-configurator/6748

https://github.com/DJayDeee/Cayenne_Connect

I think I need make hybrid of these two, as I use cayenne button as trigger

I can’t say too much about it because I use my own development for setting wifi credentials, which I already had before this solution emerged. It does appear to be popular though. Also, the documentation and the folder “examples” on that Github site seem to be quite extensive.

thanks. was able to get Wifi Manager and connect to wifi. But how can I get IP address [ without Serial Monitor]

You want to see the IP address which has been assigned to your ESP device (by your router via DHCP etc.) or you want to set a static IP address or what ?

6v6gt: You want to see the IP address which has been assigned to your ESP device (by your router via DHCP etc.)

Yes. the IP address of ESP, to access via webpage

"Yes. the IP address of ESP, to access via webpage"

Assuming you have already worked out having the ESP log into the network, you might try the softAP setup (both network station and AP). The ESP would log into the network and save the assigned IP address as a variable. Then you might log into the AP side of the softAP setup with your cell phone and make a client request for the saved IP address.

Or if you have not got that far, look at the example here: https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/readme.html to see the method to obtain the IP address when your ESP is a client of your wlan. Hopefully, your application has a screen to display it at start up, or on demand. If not you also have the option of setting a fixed (static) IP address so you always know what it is, or logging into your router to see what it has assigned to your ESP.

wifiManager default IP when it cannot connect to a know network is 192.168.4.1 and once it has connected then (in my example) I can access it using http://esp-2bad4b.lan/ or its IP address. The host name will/should be different for each ESP module but once you know it it stays the same for that device.