mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #166] Store multiple SSIDs ? #132
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#132
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 @RudolfLapie on GitHub (May 9, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/166
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 ?
@kentaylor commented on GitHub (May 10, 2016):
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.
@RudolfLapie commented on GitHub (May 10, 2016):
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.
@kentaylor commented on GitHub (May 10, 2016):
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:-
See function definitions in sedctions 3.4.10 - 3.4.12 at http://www.mikrocontroller.net/attachment/245197/2C-SDK-Espressif_IoT_SDK_Programming_Guide_v0.9.5.pdf .
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.
At startup, scan for WiFi networks then change to the one from the scan list with the strongest signal that matches the SSID of one of the stored ones.
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 https://github.com/esp8266/Arduino/issues/1997 discovered only a few hours ago is fixed in the Espressif SDK but that should be soon.
@tablatronix commented on GitHub (Nov 19, 2016):
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.
@kentaylor commented on GitHub (Nov 19, 2016):
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?
@tablatronix commented on GitHub (Nov 19, 2016):
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.
@tablatronix commented on GitHub (Nov 19, 2016):
created feature request
@Bergum commented on GitHub (Mar 6, 2017):
I have done it this way to solve my problem. It works for me.
const char* ssid = "xxxxx";
const char* password = "xxxxx";
const char* ssid2 = "yyyyyy";
const char* password2 = "yyyyyy";
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
digitalWrite(LedYellow_1, HIGH); // To give it indication of status
Serial.println("LedYellow_1 On");
delay(30000); // I give it 30 sec to connect, if it fails, try next
if (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid2, password2);
digitalWrite(LedYellow_2, HIGH); // To give it indication of status
digitalWrite(LedYellow_1, LOW);
Serial.println("LedYellow_2 On");
delay(30000); // I give it 30 sec to connect, if it fails.....
}
else if (WiFi.status() != WL_CONNECTED) {
Serial.print("Going DeepSleep");
ESP.deepSleep(sleepTimeS * 1000000); // go deepsleep for 10 min and try all over again
}
// I also terminate my script with deepsleep so that it will always start by scanning the network.
// My use is to trigger the heater in my car at work or at home...