Using a USB wifi antenna

Hi, I’m trying to use a USB wifi antenna to allow me to connect my device to a wifi signal at longer range.

My issue is that I can’t work out if the Pi is using the built-in wifi adapter, or using the antenna. I’ve tried running ifconfig but I can only see WLAN0 and not WLAN1.

Can anyone point me in the right direction?

Hi @GregorR1, let me share couple of links first. Here’s our networking documentation that might help you: https://www.balena.io/docs/reference/OS/network/2.x/#networking-on-balenaos-2x

Then here’s non-exhaustive list of supported wifi dongles – in case you have the option to try these out:

Next, I’d suggest using NetworkManager on the device to scan and inspect the wifi adapter. The nmcli command, on its own, will show all interfaces and the connections they have. nmcli c provides a connection summary, showing all known connection files with the connected ones highlighted. nmcli d displays all network interfaces (devices).
Another useful place to look for NetworkManager information is in the journalctl logs:

journalctl -fn 100 -u NetworkManager  

Let us know how your investigation goes and if we could help out further.

Hi gelbal,

Thanks for the links. I tried running the nmcli command and it returned this:

wlp1s0u1u1: connected to resin-wifi-01
        "Ralink n"
        wifi (rt2800usb), 98:3F:9F:19:0C:27, hw, mtu 1500
        ip4 default
        inet4 192.168.1.105/24
        route4 0.0.0.0/0
        route4 192.168.1.0/24
        inet6 fe80::3b0a:7d22:ad9d:cbaf/64
        route6 fe80::/64
        route6 ff00::/8

supervisor0: connected to supervisor0
        "supervisor0"
        bridge, 02:42:8C:E7:56:7C, sw, mtu 1500
        inet4 10.114.104.1/25
        route4 10.114.104.0/25
        inet6 fe80::42:8cff:fee7:567c/64
        route6 fe80::/64
        route6 ff00::/8

wlan0: disconnected
        "wlan0"
        1 connection available
        wifi (brcmfmac), 3A:BD:75:BA:CF:09, hw, mtu 1500

eth0: unavailable
        "eth0"
        ethernet (bcmgenet), DC:A6:32:2F:9C:A6, hw, mtu 1500

As you can see, it says that wlan0 is disconnected, however the device is using a wireless connection as the device is online and there is no ethernet plugged in. I’m not sure what I’m looking for regarding the logs.

Hi, can you paste the NetworkManager logs to see if anything stands out there e.g. journalctl -n 200 -u NetworkManager. Also, if you enable support access and send us the device UUID we can also take a look at the device for you.

Hi Gareth,

I’ve enabled support access on the device with the USB dongle installed. The UUID is 945f7f8a2e99218efddae054005ccbcb

I just want to make sure that it is using the external wifi dongle, as opposed to the built in one as the distance to the router is too far for the built in wifi chip to handle.

Edit: The built in wifi chip on the pi is enough to connect it when the pi boots but it is not reliable and drops out a lot. it then is a hit or a miss whether it reconnects and sometimes has to be restarted. So we have remote access for now, but the device may go offline at any point. We do have someone on site tomorrow that would be able to restart the device in this case. But moving forwards we need to ensure that the pi is always using the USB dongle.

Thanks,
Gregor

Hi Gregor,

The second interface name is called wlp1s0u1u3. It is not wlan1 because it is renamed by the systemd/udev on boot: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

You may bind connection to this interface by adding interface-name=wlp1s0u1u3 to [connection] section of the NetworkManager connection profile for this connection. In this case it is /mnt/boot/resin-wifi-01. You may modify it with vi from a host OS terminal.

Here is some more documentation about setting up the connection profiles:
https://www.balena.io/docs/reference/OS/network/2.x/
https://developer.gnome.org/NetworkManager/stable/nm-settings.html

Please let us know if you have further questions.

Thanks,
Zahari

Hi Majorz,

Thanks for the reply. So if I understand correctly the wlp1s0u1u3 is the external dongle? When I use “nmcli d” it is showing as disconnected.

I’ll try to bind the connection to resin-wifi-01. I’m concerned that the device goes offline and we don’t have access again until tomorrow. Hopefully, this all goes to plan and solves the issue.

Edit: I cant seem to find the right file in the /mnt/boot/ directory.

Thanks,
Gregor

Hi Gregor,

Sorry it is /mnt/boot/system-connections/resin-wifi-01.

It is shown as disconnected because the other interface is currently connected to the network. Once the switch is done it will be the opposite.

You may indeed loose connectivity when you do the switch if something goes wrong, so it will be better if you have access to the device.

Good luck!
Zahari

Hi Majorz,

I had literally just found it when I saw your reply. Can you remind me how I edit the file?

Also, if it goes wrong - do I just need to get someone to remove the USB wifi adapter so it will revert to the built in one?

Thanks,
Gregor

You may open a host OS terminal and then do vi /mnt/boot/system-connections/resin-wifi-01. You will need some basic vim skills. Pressing i enters insert mode. Pressing ESC exits it. And then typing :wq will write the file and exit vim.

It will not revert to the built-in WiFi once this is applied. Also please note that WiFi drivers on Linux in general are quite unstable. If you rely on WiFi connection only you may or may not run into driver issues where your connection is lost, etc. This is depending on the dongle/driver quality. It is a trial and error scenario unfortunately.

Thanks,
Zahari

Hi Zahari,

Thanks for the reply, I think I’ve managed to implement the changes to the file. Do I just restart the device to make it change to the new adaptor?

I assume that the adaptor name will never change?

Thanks,
Gregor

You need to restart the device indeed.

The name will not change unless it is plugged into another USB port.

Thanks,
Zahari

Okay brilliant. I’ll try that now and if it doesn’t work I can always get someone on site tomorrow to have a look at it.

Thanks,
Gregor

I restarted the device, and ran the nmcli d command but its saying the wlan0 is still the adaptor in use. I checked the resin-wifi-01 file and it still has the interface-name=wlp1s0u1u3 line in it.

I’m not sure where I’ve gone wrong.

Thanks,
Gregor

Can you enable support access again so that I can take a peek at the device?

That should be the support access granted again now.

Thanks,
Gregor

You probably have not rebooted the device, is that so?

My apologies, I must’ve got confused between reboot and restart.

No problem, let’s see how that goes…

That seems to have solved it! Thanks for all of your help!