-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Connect to AP using SSID, Password, and BSSID? How exactly? #9163
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
Comments
Yes, I know, I’ve read that…what I’m looking for is an example of the implementation in code. For example, do i use the call like… WiFi.begin(“myssid”, “mypassword”, 7, “01:02:C1:33:F1”) When I try using variables I get a type error for the bssid as the variable type doesn’t match what the method wants, and I cant figure out how to implement the MAC address as the required variable type. |
so there is no issue. ok. |
? What ? |
Running a WiFI scan sketch on the ESP8266 shows the following... 13:24:46.572 -> Starting WiFi scan... FYI the ESP shown above is a different device that is connected to the "01" AP, it is ============================================================================= In the code I've imlemented the following... // Variable definitions const char *ssid = "WIFI-24"; // Down in the conncect code bool wifiConnect() { When I run the code I get... If I change the WiFi.begin code to "WiFi.begin(ssid, password);" and So it seems to me that the issue is that the ESP is seeing three APs The methond WiFi.begin() implements things as follows as far as I Parameters: const char * ssid So I believe my basic issue is I really don't understand how to implement |
add WiFi.waitForConnectionResult() after WiFi.begin |
Ok...I'll give that a try. Thank you. But... Isn't there anyone that can actually answer the question I'm asking? What I want to learn/understand is how to implement the method as it's defined and published. The library says you should be able to pass the MAC address of the AP you want to connect with, right? But nowhere in the example code or the document is there an actual explanation of how to actually do it. Google searches, and I've done a lot of searching, doesn't turn up a single example of how these parameters can be used. |
you don't wait until it connected so you can't know if it connects to bssid or strongest or anything |
The function is actually "WiFi.waitForConnectResult()" I think...at least that's what auto complete shows...not that it makes much of a diff. But the real question is the previous one, how to implement the WiFi.begin() properly using it's defined parms... |
you have |
Code is shown above. Yes... there is a WiFi.begin(). And after adding the waitFor the wait just times out (-1 returned using 2000 as the timeout). Second loop thru it does connect (using the unique ssid), so I'll play around with the timing and see if it's the radio taking a few seconds to fire up. But, still looing for the info on how to implement the bssid parm... |
So... There was apparently some issue with timing.... I reset the router/ap to use the redundant wifi ssid, updated my code with a few delay(500) statements, added back in the bssid definition and the full bssid begin, unplugged, waited for a minute, and plugged back in, and was surprised that things apparently work now. Anyway, below is the code that seems to be working now... ` #include <ESP8266WiFi.h> // Temp sensor wires connected to D4 (GPIO2) void setup() { void loop() { // Build the MQTT message if WiFi and MQTT Connected // function to print a device address // Get a WiFi connection but don't freak if it fails // Only call if there is a WIFI connection! ` |
I guess automatic connection to remembered AP was happening parallel with setup(). use some of WiFi.setPeristent(false), WiFi.setAutoReconnect(false), WiFi.erase() |
It appears that the issue was possibly due to timing. I'd suggest that some additional examples be added to the doco that show how to use WiFi.begin(ssid,password,channel,bssid) with various options and how to define the parameters more clearly. But that's just the opinion of a relative newbie... |
Dang it! I added a bit of unrelated code and now the connection is failing again, exactly as before. I'm reopening this issue again, as I guess the connect with BSSID still is funky... |
OK, I found some other info and this may be the issue... I'm running an ASUS RT-AX86U Pro Router and that router uses "802.11ax / WiFi 6 mode" mode as its default. The info I found suggests that WiFi 6 Mode is an issue with the ESP8266 radio, so I turned off the WiFi 6 Mode and now things seem to work reliably. So, is there an issue on the ESP8266 with WiFi 6? |
Apparently there is a separate ticket open around this issue. The issues has to do with the newer board cores and the solution is to revert to core 2.5.2 and recompile without some of the newer functions (like WiFi scan). I did that and the board has been processing just fine for the last two days. And with the older core I didnt need to specific the AP MAC address as the library connects to the strongest AP just fine. |
Platform
Problem Description
I've been trying to connect to a specific AP using its SSID/Password and the MAC address of the AP. I have several APs spread around my property and most of my devices attach to the strongest AP. In my particular application I want the ESP8266 to connect to a specific AP and ignore all the others. To do this I should be able to use the "WiFi.begin(ssid, password, channel, bssid, connect)" option.
But, I've tried multiple ways to define the bssid parameter properly and none of the are working. Can someone provide an example of how exactly to do this within the Arduino IDE?
And example of the definition code and the call code would really help...
The text was updated successfully, but these errors were encountered: