ESP project, ideas on how to make SSID / password configurable externally

Hey all,

I've got several IoT experiments going on, but it just occured to me today that there is a major elephant in the room that I need to address.

The ESP needs to connect to wifi to transmit data. And if I am to ever give or sell one of these things to someone else, they will need to configure it with their own SSID / password to make it work, without needing to access the code.

For the past few weeks, I was thinking "yeah sure, I'll make a config page online where they can enter their SSID / password". I now realize the enourmous flaw in that logic. :stuck_out_tongue:

... so anyway, moving on, I'm thinking, I can store the SSID / password on an SD card, which they can remove and edit themselves. That seems to be the simplest solution, but it is a bit clunky.

I thought maybe I can add some kind of circuit to allow people to access the SD card from a USB port. Either from the one on the ESP, or a separate one. Not sure how difficult either option would be.

Or perhaps I can add a dipswitch to make the device boot in AP mode, allowing users to connect to it and configure it wirelessly.

Or perhaps I'm making this way more complicated than it needs to be, and I can just use WPS. I just looked into it now while typing this, and it's literally like 2 lines of code. I guess I can do this, and then also store it on an SD card, for extra redundancy, since not all routers have WPS support.

I guess I just want to know what kind of methods you guys use? Is there anything I'm overlooking perhaps?

Any guidance would be appreciated. Cheers!

see the WiFiManager library

Or perhaps I can add a dipswitch to make the device boot in AP mode, allowing users to connect to it and configure it wireless

wisest approach

Maybe you can store SSID & Pwd in non-volatile EEPROM, no need for SD Card.

When the device wakes up, if no data is stored in the pre-defined (by you!) EEPROM locations, it enters AP mode. It receives the SSID & Pwd data from user, store them in EEPROM, and next time it boots is ready to rock!

Regards.

tpbertu:
Maybe you can store SSID & Pwd in non-volatile EEPROM, no need for SD Card.

When the device wakes up, if no data is stored in the pre-defined (by you!) EEPROM locations, it enters AP mode. It receives the SSID & Pwd data from user, store them in EEPROM, and next time it boots is ready to rock!

Regards.

the esp8266 stores the ssid and password. there is no need to care about that. and the rest does the WiFiManager library. no need to reinvent the wheel

Juraj:
see the WiFiManager library

Looks good! It doesn't look all that complicated to set up the AP myself, but this library could definitely save me some time.

tpbertu:
Maybe you can store SSID & Pwd in non-volatile EEPROM, no need for SD Card.

The main point of the SD card idea is that the user can physically remove the card, and edit the contents. If the setup is to be only done by AP mode, then yep, EEPROM would be better.

obuw:
Looks good! It doesn't look all that complicated to set up the AP myself, but this library could definitely save me some time.

The main point of the SD card idea is that the user can physically remove the card, and edit the contents. If the setup is to be only done by AP mode, then yep, EEPROM would be better.

esp8266 doesn't have EEPROM.

this sketch does the essential of what WiFiManager does:

Juraj:
esp8266 doesn't have EEPROM.

Are you sure about that?
https://www.google.com/search?q=ESP8266+EEPROM

tpbertu:
Are you sure about that?
ESP8266 EEPROM - Google Search

sure. the EEPROM library is an emulation. it stores data to flash memory

SPIFFS.

Non-volatile storage library

see ESP32 API: API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation

Idahowalker:
SPIFFS.

Non-volatile storage library

see ESP32 API: API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation

what for?

I don't want to hijeck the thread, but can you bluetooth your credentials in?
I would think you could sign in and add data, or select a connection.

OK, we can forget the dispute as to whether it is EEPROM or "flash" - the ESP8266 has it. Not a problem.

This problem has already been solved. You buy a WiFi device (such as a repeater), it has - among other things - a "reset" button. In "factory" state, it has a default ID and password, when you first start it, you (are supposed to) log on to it and set your own secure password and change the network ID as needed. These are stored in the device's flash.

If something goes wrong - you forget the password - then you hold the reset (obscured) button for a certain time or whilst powering up, and it resets its identity to the factory default. You log on to that again and repeat the configuration process. The security is based - as it always is - on physical possession of the device.

That's it - done! :grinning: