Adding Data After Flashing-NodeMCU

My NodeMCU Arduino project is up and running on my local network.
I have hard coded into the sketch my network name and password.
HOWEVER, I'd like to pass the unit on to a user who will use it on HIS network, of course with different credentials.

Is it possible to modify my code so that the network information can be added later?
I started out with a dialog using the Serial Monitor, but then realized that the new user will not have access to this - and even if he does, I would have to by-pass this dialog once he enters the two pieces of data correctly.

Any ideas on how I can accomplish this?

How about giving this a try?

Yes, don't hard-code it into the sketch, and let WiFiManager write it to flash.
Another option is WiFiMulti.
Leo..

Thanks VERY much for the responses!
WiFiManager seems to be the way to go - and to solve my problem.

HOWEVER - it has taken me this long (over two weeks) to get it going.

I tried everything, with the same unusable results - the Serial Monitor said that I was on the air, but I never created a discoverable site.
FINALLY, in looking at problems that others had with similar results, one of the respondents said that he had completely erased his module, started from scratch, and then it worked.

I then pulled out a brand-new, never before used module from my small stock. Lo and behold! Everything worked right from the start!

Just a comment in case any lurkers out there can be helped with this insight.

  • Matt

Hmmm... Each time you upload a sketch, it completely overwrites everything, except the part of flash memory it uses to store WiFi configuration (mode, last used SSID/password). My guess is that it was automatically reconnecting to your WiFi, using the previous SSID & password, and so WiFi manager was not kicking in. I bet if you take the old module out of range of your WiFi, so it could not connect, WiFi manager would kick in.

There is an option to erase all flash of the NodeMCU in the tools menu of the IDE.
It should stay on "Only Sketch", to not wear out the flash memory too much.
But if you're having problems, then you could set it to "All Flash Contents" once.
Make sure you set it back to "Only Sketch" after the upload.
Leo..