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!
Saving WiFi credentials in the EEPROM
Re: Saving WiFi credentials in the EEPROM
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
-
- Posts: 5
- Joined: Sun Feb 11, 2018 9:24 pm
Re: Saving WiFi credentials in the EEPROM
Thank you! And great job for the documentation!
-
- Posts: 160
- Joined: Thu Jan 31, 2019 2:32 pm
Re: Saving WiFi credentials in the EEPROM
Where can I find the above mentioned "provided" WiFi API ? I am using Arduino IDE and a ESP WROOM 32.kolban wrote: ↑Tue Feb 20, 2018 1:43 amThere 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.
-
- Posts: 2
- Joined: Sat Nov 10, 2018 7:28 am
Re: Saving WiFi credentials in the EEPROM
@kolban To store multiple wifi credentials we need to store them in the flash right?kolban wrote: ↑Tue Feb 20, 2018 1:43 amThere 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.
Re: Saving WiFi credentials in the EEPROM
It has been a while for this topic, to benefit developers who have the same question, here are what need to be done for ESP32 to store last used Wi-Fi credentials automatically:
- Set CONFIG_ESP32_WIFI_NVS_ENABLED to y
- Call esp_wifi_set_storage(WIFI_STORAGE_FLASH) <-- this is actually default value, just to confirm this function is not called with different parameter
Who is online
Users browsing this forum: Bing [Bot], ESP_Sprite and 195 guests