Posted on Fri 28 June 2019
In Общие вопросы.
tags: setup programming robotics
Often the development boards for robotic platform (I mean Raspberry Pi, Aaeon Up Board, Arietta, BeagleBone and so on) do not hold a wireless interface.
The users of the boards have to use different wireless/WiFi usb modules, like RT5370 Wireless Adapters. Sometimes, even if the module is recognized by the system correctly, the corresponding network interface is not active. Let's fix it!
We are supposing we use Ubuntu 16.04 LTS (there would be no difference for 18.04 too), and noname Chinese wifi module with RT5370 chipset.
First of all, you have to get your board up, and get an access to it. Then check if the module is visible by the system:
lsusb
You are supposed to see something like this:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 0424:2530 Standard Microsystems Corp.
Bus 001 Device 005: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 004: ID 0424:4603 Standard Microsystems Corp.
Bus 001 Device 003: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 001 Device 002: ID 03e7:2150
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Our module is Ralink Technology, Corp. RT5370 Wireless Adapter. Ok, the system "sees" it.
Let's check if the corresponding network interface is up:
ifconfig
In my case the output is
enp1s0 Link encap:Ethernet HWaddr 00:07:32:3f:c7:21
inet addr:192.168.0.103 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::207:32ff:fe3f:c721/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5560 errors:0 dropped:0 overruns:0 frame:0
TX packets:3212 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7719135 (7.7 MB) TX bytes:288886 (288.8 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:353 errors:0 dropped:0 overruns:0 frame:0
TX packets:353 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:71577 (71.5 KB) TX bytes:71577 (71.5 KB)
Oops! No wireless interface. Let's check if it is present at all:
ifconfig -a
The output is
enp1s0 Link encap:Ethernet HWaddr 00:07:32:3f:c7:21
inet addr:192.168.0.103 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::207:32ff:fe3f:c721/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5654 errors:0 dropped:0 overruns:0 frame:0
TX packets:3255 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7739577 (7.7 MB) TX bytes:295428 (295.4 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:402 errors:0 dropped:0 overruns:0 frame:0
TX packets:402 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:89121 (89.1 KB) TX bytes:89121 (89.1 KB)
wlx008732748025 Link encap:Ethernet HWaddr 00:87:32:74:80:25
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Hooray! The wifi interface (wlx008732748025) is here, but not active at the moment.
We suppose the name f the interface here is wlx008732748025, but for your board the name definitely would be different. Please note wlx008732748025 has to be replaced with the name of your interface.
Let's get it up:
ifup wlx008732748025
Oops again! No such network interface? How's that?
The ip command will help us:
sudo ip link set wlx008732748025 up
Now it is active.
It's time to check for the available wireless networks around here:
sudo iw dev wlx008732748025 scan
A lot of information, if you are to see only networks' SSIDs, just add some grep:
sudo iw dev wlx008732748025 scan | grep SSID
Now you have just SSIDs of the networks.
Well, we are almost there. Now we have to connect to our network. It takes a few additional steps.
First, you have to install wpasupplicant
:
sudo apt-get install wpasupplicant
Then we should generate the hash of our psk passphrase:
wpa_passphrase Home as71djddhwyf
Here we suppose that our network's SSID is Home and the passphrase is as71djddhwyf (which is not my passphrase, of course ;) )The output would look like this:
network={
ssid="Home"
#psk="as71djddhwyf"
psk=86219a4c225a32beafe899a2b80f887b9f6140a40a50eb9850b9593f7898a890
}
Now add the following lines to the /etc/network/interfaces:
auto wlx008732748025
iface wlx008732748025 inet dhcp
wpa-ssid Home
wpa-psk 86219a4c225a32beafe899a2b80f887b9f6140a40a50eb9850b9593f7898a890
Now save the file and restart the interface:
sudo ifdown wlx008732748025 && sudo ifup -v wlx008732748025
Now check the interfaces again:
ifconfig
The output now have to show you connected status with IP address for your wlx008732748025 interface.
15 Useful “ifconfig” Commands to Configure Network Interface in Linux
Linux IPv6 HOWTO (en) Chapter 5. Configuring interfaces
How can I display the list of available WiFi networks?