Unlike the Arduino AVR based controllers, the ESP8266 does not have a dedicated EEPROM. We can however use a bit of flash memory as a emulated EEPROM, and we can use the Arduino EEPROM library to do it. Using the Arduino Put and Get code samples as they are doesn’t work. However a simple
EEPROM.begin(1024); // both the put and get code
EEPROM.commit(); // only on the put code
after it makes everything work.
In the linked code samples below, I’m saving 2 strings of text (wifi ssid and password) to the EEPROM in the put code, and retrieving them in the get code. If you put a slide switch in your project, and run the two pieces of code depending on the switch position, you can reset the credentials from a built in web form. I will cover that ability soon.
Become the Maker you were born to be. Try Arduino Academy for FREE!
Fore more info, see:
Why constrain yourself to the small size defined for eeprom in flash when you can use SPIFFS filesystem that also is stored in flash – this is much bigger and more versatile.
for just saving a ssid and password, I found the get and put easier to accomplish. I'll be doing a tutorial soon using SPIFFS and JSON for more intense data retrieval.