I wanted to connect my Raspberry Pi 0W to my wifi, but as I’d added emojis to the SSID (because I can), the linux OS wouldn’t do it via the GUI. The network showed up in the list as a series of hex codes – \xf0\x9f\x90\xb6\xf0\x9f\x8e\x85 – and clicking on it generated an error.
After some googling, I came upon the following link: https://superuser.com/questions/1075776/connect-wlan-interface-to-specific-bssid-without-knowledge-about-ssid
For me, the interfaces file in /etc/network was already pointing at the wpa_supplicant.conf file, so I didn’t need to change that. I edited my wpa_supplicant.conf file to use the BSSID of my network directly, without needing the SSID as follows:
network={ bssid=01:23:45:67:89:ab psk="MYPASSWORD" }
Obviously, use your wifi password as the psk (I hope it isn’t MYPASSWORD!). To get the BSSID I used the interactive mode of the wpa_cli. Type ‘wpa_cli’ in a terminal window, then the following:
> scan OK <3>;CTRL-EVENT-SCAN-STARTED <3>CTRL-EVENT-SCAN-RESULTS > scan_results bssid / frequency / signal level / flags / ssid a4:2b:b0:b7:91:c6 2437 -34 [WPA2-PSK-CCMP][ESS] \xf0\x9f\x90\xb6\xf0\x9f\x8e\x85 a6:2b:b0:b7:91:c4 2437 -33 [WPA2-PSK-CCMP][ESS] Fergus c0:56:27:02:14:a4 2462 -55 [WPA2-PSK-CCMP][WPS][ESS] belkin.4a4 b0:39:56:8c:ea:c6 2437 -60 [WPA2-PSK-CCMP][ESS] rW5BslTf b0:da:f9:a8:39:fd 2412 -58 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] gelinaNjanne ac:b5:7d:28:e2:b5 2437 -70 [WPA2-PSK-CCMP][WPS][ESS][P2P] DIRECT-roku-051-AF408D f8:35:dd:b5:15:47 2462 -50 [WPA2-PSK-CCMP+TKIP][WPS][ESS] 1060 c2:56:27:02:14:a5 2462 -54 [WPS][ESS] belkin.4a4.guests b0:7f:b9:ad:bc:be 2462 -74 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] Inday Guest >
The first entry is my wifi, and the bssid is the first string of hex digits. A quick reboot later and now my Pi W0 is connected to the correct wifi and I can SSH into it from my Mac!
Pro tip: If you are on a mac, and you are connected to the same wifi, you can ALT-click on the wifi icon in the upper notification tray and see all sorts of info including the BSSID to your network.