-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store multiple SSIDs ? #166
Comments
WiFiManager sets the ESP8266 SSID and password values using Espressif SDK functions. As far as I am aware there can not be multiple SSID's when done this way but it is convenient because the ESP8266 will join a WiFi network at anytime after power up that it becomes available and will rejoin if the WiFi network goes away and comes back later. WiFiManager could be written to connect to multiple SSIDs but it is complicated unless you restrict trying different SSIDs to immediately after power up and that wouldn't be a good restriction. You could also abandon WiFiManager, hard code the SSID's and switch between them in your own code. |
My first goal was simple and only during the "setup" phase of the device : store the last x successful SSID/password combinations and then at startup/power up, check which of those appears in the list of SSIDs in that place at that moment. Then try to connect to the first one found. If that doesn't work, start the AP and have the user configure the SSID/password for that place. So basically as it is today, but instead of 1 known SSID have x known SSIDs stored. A (hopefully?) small enhancement to the existing code. What you are suggesting would indeed be much much more powerful : when loosing connection, automatically reconnect to an available & known AP, but not what I suggested as it is indeed very complex to program. |
I looked into this a bit more. It turns out the device will store data for up to 5 WiFi access points. It will only use one of them rather than switch between them by itself but once one is selected it will handle the connectivity automatically. The Espressif SDK functions you would use are:-
The algorithm when you save one would be choose the next empty one to save to. If there is already 5 saved, delete number 1. Then move 2 to 1 etc to make a vacancy at 5 and store the new one at 5. I like this idea but have no intention of implementing it. Perhaps someone else will be interested. Also it will have to wait until this bug esp8266/Arduino#1997 discovered only a few hours ago is fixed in the Espressif SDK but that should be soon. |
Looks like this is not implemented in the arduino library wifimulti, it just auto selects best from a list you provide at runtime. You'd have to write your own implementation at this time. |
I wasn't aware of WiFiMulti until referred to by @tablatronix who points out
So WiFiMulti doesn't use the flash SSID array but probably should. When credentials are stored in flash the WiFi connection is maintained in the background . This leads to the advantages:-
WiFiMulti scans for an AP with the highest signal strength from a hard coded list and writes only the best one to flash. Thereafter this AP is used automatically until the ESP fails to connect at which point it repeats the process. If WiFiMulti was modified to use the SSID flash store rather than a hard coded list it could be used in WiFiManager to handle multiple SSIDs. I wonder if the ESP core team would be interested in such a modification? |
I did not even see an open issue so maybe we should create one, there was a closed issue but it was never seen by igrr and was not exactly feature request implementing this is fairly complex, as you mentioned. There is a list now, so you need add ap, remove ap, reorder ap? check already exists, connect to best ap, and all the UI necessary to perform this, it seems to be a large code complexity for such a minor feature that could be handled by another specialized library, one that stores and saves aps, and maybe even autoconnects to open aps. |
created feature request |
I have done it this way to solve my problem. It works for me. const char* ssid = "xxxxx"; // We start by connecting to a WiFi network Serial.println(); WiFi.mode(WIFI_STA); if (WiFi.status() != WL_CONNECTED) { else if (WiFi.status() != WL_CONNECTED) { // I also terminate my script with deepsleep so that it will always start by scanning the network. |
I frequently move my esp8266 between different locations. Using WifiManager I now have to reconfigure the SSID & password each time. Would it be possible to store multiple (e.g. 3?) accesspoints that are tried one after the other before starting the accesspoint ?
The text was updated successfully, but these errors were encountered: