# Force NetworkManager to connect to 2.4Ghz

**URL:** <https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156>\
**Category:** balenaOS\
**Tags:** balenafin\
**Created:** [April 2, 2021, 7:38pm UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156 "2021-04-02T19:38:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [April 2, 2021, 7:38pm UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/1 "2021-04-02T19:38:33Z")

</div>

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.

1. `apt-get update`
2. `apt install wavemon`
3. `wavemon`

 ![Screen Shot 2021-04-02 at 3.30.32 PM](https://global.discourse-cdn.com/balena/original/2X/f/f7f4bf345f33f9cdd3110411eb2741ed3f6782ea.png)

![2021-04-02 15.29.53](https://global.discourse-cdn.com/balena/original/2X/0/0d21a2bb3407eb4c77126e0780e9b9cec9dbe09c.gif)

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [April 2, 2021, 10:51pm UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/3 "2021-04-02T22:51:53Z")

</div>

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.

1. `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.

1. `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 ☹

---

<div class="post-metadata">

**Author:** ![dtischler](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dtischler/32/2483_2.png) [@dtischler](https://forums.balena.io/u/dtischler)\
**Post date:** [April 2, 2021, 11:19pm UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/4 "2021-04-02T23:19:07Z")

</div>

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](https://www.balena.io/docs/reference/OS/network/2.x/#wifi-setup)

The trick would be to figure out which is the right field to use, likely from one of these:

- [802-11-wireless: NetworkManager Reference Manual](https://developer.gnome.org/NetworkManager/stable/settings-802-11-wireless.html)
- [connection: NetworkManager Reference Manual](https://developer.gnome.org/NetworkManager/stable/settings-connection.html)

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [April 3, 2021, 12:36am UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/6 "2021-04-03T00:36:59Z")

</div>

> [@dtischler](#):
>
> I have to wonder if it could be controlled by a file in the /system-connections folder

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

```

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [April 3, 2021, 1:14am UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/7 "2021-04-03T01:14:09Z")

</div>

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?? 🤞

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [April 3, 2021, 3:10am UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/8 "2021-04-03T03:10:29Z")

</div>

> [@barryjump](#):
>
> 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

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.

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [April 5, 2021, 1:08am UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/9 "2021-04-05T01:08:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dtischler](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dtischler/32/2483_2.png) [@dtischler](https://forums.balena.io/u/dtischler)\
**Post date:** [April 5, 2021, 5:05pm UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/10 "2021-04-05T17:05:52Z")

</div>

Just catching up on the thread, great job researching and documenting it @barryjump !

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [April 5, 2021, 8:42pm UTC](https://forums.balena.io/t/force-networkmanager-to-connect-to-2-4ghz/282156/12 "2021-04-05T20:42:10Z")

</div>

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
