Dynamic Configure wifi ssid and pwd

I have recently bought NodeMCU and have been successful in doing basic projects of controlling LEDs remotely using browser. I have hard-coded the Wifi SSID and Pwd in my code. This actually restricts me to use it in my friends home.

Could you please suggest, how can i set the wifi n/w SSID and pwd by prompting user in the browser for wifi details first time. Post which have my program executed.

I am using Arduino IDE to do the programming.

Request your help.

There seems to a be a few solutions in this area of the initial configuration of the ESP8266.
Here is one example: WiFiManager with ESP8266 - Autoconnect, Custom Parameter and Manage your SSID and Password | Random Nerd Tutorials

If you find a solution which works for you, post the details. I for one would also be interested.

removed dead links

Seems obvious but the device can't connect to the wifi if it does not know the network.

So in order to solve this, your "device" needs to create its own wifi network (this is called Access Point mode) and you first connect your computer's wifi to this wifi network and then the device needs to be able to present a form where you enter the information (SSID, PWD). this information will be saved in your device.

Once this is done your device needs to reset the wifi connection to use the station mode (a client of another wifi network) and use the saved values to connect.

there is a mode where both station and access point are activated, that's also an option you can envision.

You can read all about modes here

I am thinking more from a perspective if i want to produce such products in scale and volumes. I will not be able to sell it as-is. Each and every device has to have the n/w credentials hard coded.

We will not be able to make it as a product, wherein you buy the programmed device and the user just plugs in and get started after setting their own wifi credentials.

I am sure this is a query which others may have faced and got around it.

Thoughts ?

well there are many strategies for this depending on the device. if this is something for the consumer market then:

  • use Bluetooth for configuration: your device needs to have a BT interface and be able to pair with an App on a mobile phone; use the mobile phone app to set up your device.

  • use the station + access point approach highlighted above. have a physical button on your unit which makes it into a "programmable mode" --> that when it goes in Access point mode and build its own wifi network. offer an app on mobile phones asking end user to switch wifi to your wifi and leverage the app to enter pwd/SSID. if you don't want to write an app for mobile devices, then have your device answer HTTP requests and present a basic form to capture the SSID and PWD.

Once you have received that info, reboot, exit the configuration mode to be just in client mode (safer to have client mode only so that only the owner of the device can decide to change the configuration by physically pressing a button on the device to go to that mode).

if you are kind to your end users once your device is in their network, leverage Zero Configuration Networking and Service discovery techniques to advertise extra capabilities.

Thanks JML. This really helped to get the direction.

I managed to set the wifi configuration using the browser. I had used the WifiManager library which has lot of example programs which gives the guidance and direction.

I am now trying to see how can i merge my program and the auto wifi config program. This would help me to bundle it and do it for each device without touching the code.

Thanks !!!

The best is really to have a button that triggers a timeout period. Wien that button has been pressed in the main loop you only run the code to be your own AP and wait for a connexion. When the timeout expires or the end user has entered a configuration setting you no longer execute that code and just focus on your standard service. Issue a reset to the wifi chip - set the ssid and pwd in the flash memory of the wifi chip and connect.

Don't try to always listen to possible configure changes that's a security risk

Thanks JML for your support. It helps.

I have now been able to merge my code and the dynamic wifi config. It is working absolutely fine.

For your Reset button suggestion, I tried to have a Reset button on my web page which when pressed it calls


This would help me to get to the default Access Point (AP) view. And do the required config again.

Would this be the right way to do it ? I have not been successful in doing this.

Or do you have any other suggestion that is a better option to reset the wif settings. If you could point me to any responses for the same.

take care

If you dont mind will you please share the code with me?

Hi, my name is Logan.

I working on a very similar project :slight_smile:
I'd love to share some knowledge and if at all possible avoid reinventing the wheel.

Are you still working on this project?
Feel free to reply here or email me at

Looks like @sandipk is no longer around, did not post anything in the past 3 years. You should open a new topic, post what you have tried (read forum rules for posting) and describe what works and what doesn’t

Some stuff happened as well in 3 years, have a look at ESP8266 WiFi Connection manager with fallback web configuration portal as an example (never tried).
There are many similar ideas in various forms out there.