Erasing WiFi credentials from NVS with code

Posts: 2
Joined: Thu Feb 15, 2018 8:57 am

Erasing WiFi credentials from NVS with code

Postby ankitdaf » Thu Feb 15, 2018 9:01 am


I have saved WiFi Credentials to NVS by choosing WiFi storage as NVS configuration.

Is there a way to erase the WiFi config from NVS with code, and not by doing "make erase_flash" ?
I tried to create a wifi_config_t configuration by setting a null ssid and password but it does not seem to work, and the device auto connects on reboot with the older credentials.

Any suggestions ?


Posts: 1
Joined: Sun Feb 18, 2018 6:03 pm

Re: Erasing WiFi credentials from NVS with code

Postby espknn » Sun Feb 18, 2018 6:10 pm

you can try from linux or esptool.exe from windows. use option erase_region . you can get the address of the data from partition table at the time of booting. I assume that you dont have any other user data in the partition table nvs :)

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

Re: Erasing WiFi credentials from NVS with code

Postby kolban » Sun Mar 25, 2018 7:57 pm

At a quick guess, maybe the API esp_wifi_set_auto_connect() may be what you need. My loose thinking is that when the WiFi subsystem starts up, this flag is consulted. If we are flagged to "not" auto connect, then thats the end of the story. If we are flagged to auto-connect then the SSID/password would only then be sourced. Perhaps you could change your logic to change the flag such that when you have no valid credentials, then auto connect is off?
Free book on ESP32 available here:
Available for ESP32 consulting.

Who is online

Users browsing this forum: Google [Bot] and 1 guest