I’m using a Fin with an 5dB external antenna with the external antenna switch ON. But the antenna is only only spec’d for 2.4ghz . My router broadcasts the same SSID in both 5ghz and 2.4ghz and by default the Fin always wants to connect to the 5ghz. Is there a way to force NetworkManager to connect the a specific frequency? I wasn’t able to find the answer elsewhere on the web.
Side note, I’ve been trying to attach WiFi network stats to Datadog for a while and in seaching stumbled upon wavemon
which can be installed to provide some useful real-time wifi information.
apt-get update
apt install wavemon
wavemon
Update, for anyone else interested in doing the same I managed to figure it out.
Ask NetworkManager to scan for all the available APs and include the BSSID, Frequency and signal quality info in the list.
nmcli -f in-use,ssid,bssid,freq,signal,bars dev wifi
Your router broadcasts 2.4ghz and 5ghz under the same SSID, so what you want is to connect to the 2.4ghz specific BSSID.
nmcli d wifi connect XX:XX:XX:XX:XX:XX
All set.
I haven’t figured out how to make that preference persist across reboots though
I have to wonder if it could be controlled by a file in the /system-connections folder, as documented here: Network Setup on balenaOS 2.x - Balena Documentation
The trick would be to figure out which is the right field to use, likely from one of these:
I wondered the same thing and just assumed all the example config files I saw were as much customization as is available. But now I think that may not be the case… You might be right:
From the docs:
bssid
byte array
If specified, directs the device to only associate with the given access point. This capability is highly driver dependent and not supported by all devices. Note: this property does not control the BSSID used when creating an Ad-Hoc network and is unlikely to in the future.
I guess I could try something like this - the only problem being you’d have to know the BSSID beforehand which a bit more challenging than knowing the SSID beforehand.
[connection]
id=balena-wifi
type=wifi
[wifi]
hidden=true
mode=infrastructure
bssid=AB:CD:ED:GH:12:34:56
[ipv4]
method=auto
[ipv6]
addr-gen-mode=stable-privacy
method=auto
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=super_secret_wifi_password
Update, unfortunately specifying a specific bssid in the connection profile doesn’t work.
[wifi]
hidden=true
mode=infrastructure
bssid=AB:CD:ED:GH:12:34:56
Took my device offline completely.
I noticed also that using the ad-hoc command nmcli d wifi connect XX:XX:XX:XX:XX:XX
as I mentioned above to connect to the 2.4ghz version works, but only for a short while. Eventually (10-15 minutes in my case) it jumps ship and switches back to the 5ghz connection.
Its hard to imagine the only way to force a 2.4ghz connection is to have a router that only broadcasts in that range. There’s gotta be a way to do on the device side??
Update, it seems that if you first manually remove the connection profile from /etc/NetworkManager/system-connections
it will keep the connection to a specific BSSID from above command persistent.
I manually removed both profiles from both locations
rm /mnt/boot/system-connections/your-wifi-profile
AND
rm /etc/NetworkManager/system-connections/your-wifi-profile
And it seems to have kept the connection to 2.4ghz defined using the nmcli d wifi connect XX:XX:XX:XX:XX:XX
by creating a new profile called Mywifi.nmconnection
.
That profile persisted across a hard reboot, which is encouraging.
root@7f09eff:/etc/NetworkManager/system-connections# ls
Mywifi.nmconnection README.ignore gsm resin-sample.ignore
root@7f09eff:/etc/NetworkManager/system-connections# cat Mywifi.nmconnection
[connection]
id=Mywifi
uuid=3550e1b4-12bd-4d7e-a9cd-0b90ef5389e9
type=wifi
interface-name=wlan0
permissions=
[wifi]
mac-address-blacklist=
mode=infrastructure
ssid=Mywifi
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=my-secret-password
[ipv4]
dns-search=
method=auto
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
[proxy]
Now if only we could figure out a way to define this at first boot in the flashed img and avoid the manual SSH and CLI work.
Update, it’s been 2 days and I can confirm the steps above (deleting the connection profiles created during img config from etc and mnt folders) has kept the device connected to 2.4ghz
Haven’t been able to find a way to do this during initial setup of the img, but at least this workaround seems to work.
1 Like
Just catching up on the thread, great job researching and documenting it @barryjump !
1 Like
Looking back now I should have (and eventually did) just order a 2.4/5ghz antenna instead.
But it is a bit odd because on paper 2.4ghz seems to be a much better solution for most IoT applications considering the tradeoff of lower bandwidth isn’t typically isn’t an issue in IoT.
2.4 GHz overview
-
Pros: Larger coverage area; better at penetrating solid objects
-
Cons : Lower data rate; more prone to interference; usually more devices using this frequency
-
Max connection speed : ~150 Mbps
-
Max signal range from router : ~410 ft
5 GHz overview
-
Pros : Higher data rate; less prone to interference; usually fewer devices using this frequency
-
Cons : Smaller coverage area; worse at penetrating solid objects
-
Max connection speed : ~1 Gbps
-
Max signal range from router : ~410 ft amplified