mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 17:15:53 +03:00
[GH-ISSUE #142] how to erase previous credentials? #110
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#110
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hixfield on GitHub (Mar 28, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/142
I have a button on my ESP, that is (via an interrupt service routine) ment to restore factory settings.
How can I clear the existing WIFI credentials, so that after reset WIFIManager "sees" no credentials and starts-up the AP for setting them?
failed
I found a reference to ESP.eraseConfig here https://github.com/esp8266/Arduino/issues/1494 to but that just completely blocks the ESP and I needed to re-flash it! So I guess that is not the way to go...
@hixfield commented on GitHub (Mar 28, 2016):
I think I figured out a solution.
When the button is pressed I set a flag, and in the loop the flag is checked and then just a simple WiFi.disconnect() seams to push the WIFIManager in AP mode.
By the way, I found both the ESP.reset and ESP.restart to be unreliable, so I connected GPIO16 to the ESP RST pin, and using "software" I do a hardware reset like this. Yes... I am working with a flag, because the ESP seams to crash when I put the WiFi.disconnect() in the ISR itself...
This is part of my code:
@tzapu commented on GitHub (Mar 28, 2016):
hi,
as a general rule of thumb, don t do anything in interrupt callbacks except setting a flag, and process it in the loop. asking for trouble otherwise
WiFi.disconnect() will erase ssid/password
i use ESP.reset() sucessfully in a lot of projects, the key may be to add a delay(1000) after it. (also, not in a callback)
i hope this helps, cheers
@baruch commented on GitHub (Apr 6, 2016):
This ticket can probably be closed, maybe document it somewhere in the readme or provide an example.
@electron1979 commented on GitHub (Jan 2, 2018):
Only WiFi.disconnect(); worked for me!
Worked here too!
@trungkiendt9 commented on GitHub (Mar 16, 2018):
With button reset. It's done.
if (reset_level >500) {
WiFi.disconnect(true);
delay(2000);
ESP.reset();
}
@yo2lts commented on GitHub (Dec 5, 2018):
I have a Heltec esp wifi lora 32 I tried to delete the saved SSID settings but it does not work. I tried all the variants read above. I use the PIO with Atom but also on the Arduino IDE do the same. Can anyone help me how to make factorw reset? Thank you!
@electron1979 commented on GitHub (Dec 5, 2018):
@yo2lts, I think something like what follows may work in Arduino IDE:
@tablatronix commented on GitHub (Dec 5, 2018):
For factory reset you need to use esptool to erase flash also the arduino ide now has erase capability
@yo2lts commented on GitHub (Dec 5, 2018):
Multumesc, cred ca am reusit.
What is yield() ?
Thank You! Work!
@a-c-sreedhar-reddy commented on GitHub (Feb 22, 2019):
WiFi.disconnect(false,true);This erases existing AP credentials.
@angus-grant commented on GitHub (Oct 23, 2019):
None of that stuff worked. I searched for so long across so many resources.
I ended up digging around in the ESP code base and happened upon this little nugget
ESP_ERROR_CHECK(nvs_flash_erase());
nvs_flash_init();
This seems to have cleared my "AUTH_EXPIRE" credentials and got my WiFi working again. One caution is that it clears everything in flash. So if you are using preferences library, etc, it all gets wiped.
@tablatronix commented on GitHub (Oct 23, 2019):
You should not have to nvs erase to clear credentials, your memory was probably corrupt or changed from an upgrade.
@angus-grant commented on GitHub (Oct 23, 2019):
Well after a month and delayed shipping of product, I'll take any solution. :-|
The strange thing is that values I was saving with the preferences library would save into flash, and be re-loaded after next reboot. It was the WiFi which would simply not connect always giving AUTH_EXPIRE exception. So I think it was related to a WiFi problem and nor corrupt memory. But maybe the corruption was just with the WiFi details that were saved.
@tablatronix commented on GitHub (Oct 23, 2019):
Yes if your partition is corrupt your wifi gets corrupted as things write into its memory space, so it might seem to work but some part of it is broken and messed up connections, I wish there was some kind of parity check here, also there was no protection for wifi struct schema when it was changed, I think there is now so upgrades wont break it as much. I always do a full erase if moving to a new version of sdk or lib.
@angus-grant commented on GitHub (Oct 23, 2019):
Your info is interesting and something I'll remember when doing sdk or library upgrades..
But I changed nothing. One day it was working, the next day it wasn't...
Oh well, problem worked around/solved.
Thanks for your comments!
@qlalfdu commented on GitHub (Dec 17, 2019):
WiFi.mode(WIFI_STA);
WiFi.disconnect(true,true);
@tablatronix commented on GitHub (Feb 20, 2020):
Lol it says it right there in the code
//reset saved settings
//wifiManager.resetSettings();
@lloydrichards commented on GitHub (Mar 9, 2020):
I'm having a similar problem. wifiManager.resetSettings() does not reset the credentials.. I'm literally running the base example:
And its still giving me this in console:
*WM: Connection result: *WM: 3 *WM: IP Address: *WM: 192.168.1.178 connected...yeey :)Either something is wrong with the function or its still storing the creds somewhere else?
@tablatronix commented on GitHub (Mar 10, 2020):
esp8266?
Do you have serial logs?
@lloydrichards commented on GitHub (Mar 10, 2020):
on ESP32 Dev Module. The serial logs are at the bottom there:
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.1.178
connected...yeey :)
My workaround currently is to set up a manual config for the AP and attach to a button, but this means having to connect everytime which is frustrating
@litamin commented on GitHub (Mar 11, 2020):
Having same issue as lloydrichards here, running on a ESP32 Doit-devkit-v1.
wifiManager.resetSettings() does not do what it is supposed to do (to reset wifi credentials).
Should mention that I'm using https://github.com/zhouhan0126/WIFIMANAGER-ESP32 library, because to my understanding the original Tzapu library cannot run on ESP32?
@Daemach commented on GitHub (Mar 11, 2020):
I run it on ESP32
On Wed, Mar 11, 2020 at 1:39 PM shazman-visuals notifications@github.com
wrote:
@tablatronix commented on GitHub (Mar 12, 2020):
Development branch does
@litamin commented on GitHub (Mar 12, 2020):
Cool, so is there a way to reset Wifi credentials or not?
wifiManager.resetSettings() is not doing the job.
@tablatronix commented on GitHub (Mar 12, 2020):
I have not had time to look into it, could be a bug, try erase flash also
@lloydrichards commented on GitHub (Mar 12, 2020):
If it helps for debugging, I was finding that even when I flashed a new program and the went back to something including the wifimanager it would still have my credentials saved when using wifiManager.autoConnect(). This doesn't seem to affect wifiManager.startConfigPortal(), but i'm guessing that cause its just overwriting the credentials. Might give some experimenting to calling wifiManager.autoConnect() to start and then wifiManager.startConfigPortal() when i need to override
@tablatronix commented on GitHub (Mar 12, 2020):
the ESP saves your credentials not WM
@tablatronix commented on GitHub (Mar 13, 2020):
Works for me
@tablatronix commented on GitHub (Mar 13, 2020):
Let me try esp32
@tablatronix commented on GitHub (Mar 13, 2020):
Also works
@tablatronix commented on GitHub (Mar 13, 2020):
I cannot reproduce, I need you to erase flash, and try again and I will need more information
@rodrigok1 commented on GitHub (Jun 3, 2020):
How to get the saved SSID and password?
@peperoca116 commented on GitHub (Nov 20, 2020):
To get the credentials you need the following:
WiFi.begin(); // Mandatory
delay(1000);
String TEMP_Ssid = WiFi.SSID();
String TEMP_Pass = WiFi.psk();
Done! You get credentials without the need to store them neither in spiffs nor in EEPROM
@neklauss commented on GitHub (Mar 26, 2021):
The libraries built in WifiManager::erase() method did the trick for me.
@CplSyx commented on GitHub (Feb 9, 2023):
wifiManager.resetSettings() was not working for me (ESP8266) as autoConnect would recover the credentials - however erasing the flash via the IDE has solved the issue.
@tablatronix commented on GitHub (Feb 9, 2023):
Interesting, it should erase them, but maybe there was an esp bug in some version you were using