I was wondering, is there a way to have the Photon scan for nearby WiFi networks?
Let me explain, I’m interfacing a touchscreen with a Photon. I would like this touchscreen to display nearby WiFi networks (scanned by the Photon), allow someone to select the one they want, and then type in the password and boom… they are connected. At this current moment I am only caring about the Photon aspect of this build and that’s what brings me here. All the documentation I have stumbled upon hasn’t given me what I’m looking for (or maybe it has and I just overlooked it).
I looked at other threads and none of them seemed to line up with what I am looking for.
Okay, so ‘scan()’ shows, say 5 networks. How can I choose the one I want? ‘WiFi.connect()’ doesn’t take an argument. (Let me restate that: the doc for ‘WiFi.connect()’ doesn’t show it taking any arguments.)
Which leads to a closely related question: I have several Photons, each with credentials for two networks. The two networks usually aren’t on at the same time, but sometimes they are. How does the firmware choose one? (And how can I force it to one or the other?)
Attempts to connect to the Wi-Fi network. If there are no credentials stored, this will enter listening mode. If there are credentials stored, this will try the available credentials until connection is successful.
To use that, you'll need to have credentials stored, which in can try. Use the above mentioned docs to set those.
Thank you both. I’ve looked for an API for this and had pretty much concluded that it didn’t exist. But it’s good to have it confirmed that it’s not there. As for the ‘scan’ + ‘setCredentials’: very clever.
So the scan() and setCredentials() used together is a very cleaver way of doing this. When looking at the documentation for scan() it states we provide the array WiFiAccessPoints. Is this basically saying that we set up a structure that will contain the scanned information. Kind of like this:
Now going with this (this question is more directed toward @ScruffR) whats the best route to take to move this data (at least the SSIDs) into buffers to be able to set the text on the Nextion to be displayed?
Once I can get this to work I will be working on making it so a user can select the ap they want to connect to (or at least add to the credentials) by using an on-screen keyboard and setCredentials()
thinking about this more, is there a way to use the WiFi.scan to not only scan for the SSID with the strongest RSSI but also take the value that it returns with, presumably the negative int closest to zero, and then pipe that to a WiFi.connect?
The photon will try SSID2 and move on to SSID1 if it can’t find the first, regardless of signal strength. The Core behaves differently, however.
@MarkyD if you want to do that, you need to clear creds with WiFi.clearCredentials() then add the network you prefer to connect with using WiFi.setCredentials( ... )
From what I’m guessing on the OP’s post, the photon is being used to identify new SSIDs which may not be stored in memory. It makes sense that after a scan it would connect to the strongest one (if this is the default action) as you can have a WiFi.setCredentials with a default username and password over x number of wifi networks.
However, if the OPs project is scanning and then attempting to connect to unknown wifi networks then the WiFi.scan > strongestRSSI > WiFi.connect might be the best way??
I can only think that you could specify a WiFi.setCredentials(password) as a generic login to all SSIDs or authenticating through MAC. This would mean manually creating an account or allowing via MAC address.