Saving WiFi credentials in the EEPROM

mattia22500
Posts: 5
Joined: Sun Feb 11, 2018 9:24 pm

Saving WiFi credentials in the EEPROM

Postby mattia22500 » Mon Feb 19, 2018 10:33 pm

Hi guys I just got an ESP32 and I was wondering how to save the wifi ssid and password in the EEPROM, so at every boot of the device I don't have to insert it from serial. Just correct me if my concept is wrong.

1) I could save each character of the SSID and PSW in the EEPROM:
e.g:
SSID = myRouter
EEPROM address 0 -> m
EEPROM address 1 -> y
EEPROM address 2 -> R
eccetera...
but how to define when the SSID is done?

2) Is there a way to do avoiding the EEPROM with AT commands? (I'm a newbie, I don't know what AT commands are or how to use them, I've just heard of them).

Thank you!

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Saving WiFi credentials in the EEPROM

Postby kolban » Tue Feb 20, 2018 1:43 am

There is a subsystem in the ESP32 ESP-IDF called "Non Volatile Storage" (NVS) which allows one to save arbitrary data in named locations. Once saved, they can be restored/read on a subsequent boot. This would be the easiest way to explicitly save and subsequently restore values. However, it is my understanding that there is a WiFi API provided by the ESP32 that saves the last used credentials (SSID and password) in flash automatically and will attempt to use them upon next boot.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

mattia22500
Posts: 5
Joined: Sun Feb 11, 2018 9:24 pm

Re: Saving WiFi credentials in the EEPROM

Postby mattia22500 » Tue Feb 20, 2018 1:52 pm

Thank you! And great job for the documentation!

Who is online

Users browsing this forum: Bing [Bot], boarchuz, carlosmilon and 12 guests