This was the day I decided to go wireless with my Beaglebone Black(BBB) so that I could log into my BBB wirelessly. This will also be helpful for projects that require internet connectivity using WiFi.
This post describes the procedure to setup the WiFi for the below kernel version.
1 2 |
root@beaglebone:~# uname -r 4.1.18-ti-r53 |
1. Install the Firmware for the WiFi USB Adapter
If you are using kernel 3.8, then the procedure will differ, and hence I would suggest you look at the article shared by Adafruit.
I am using a Samsung-WIS12ABGNX USB adapter to connect the BeagleBone to the WiFi. So, let’s get started.
First, update your OS and install the drivers for the WiFi adapter on your BBB as shown below.
1 |
apt-get update && apt-get install firmware-ralink |
Power down your BBB, connect the WiFi adapter to its USB port and then power on the BBB. Now the BBB should be able to recognize the WiFI adapter and load the drivers on start up. This can be checked using the ‘dmesg’ command as shown below.
1 2 3 4 5 6 7 8 9 |
root@beaglebone:~# dmesg [ 3.823081] usb 1-1: New USB device found, idVendor=148f, idProduct=3572 [ 3.823102] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 3.823111] usb 1-1: Product: 802.11 n WLAN [ 3.823120] usb 1-1: Manufacturer: Ralink [ 3.823129] usb 1-1: SerialNumber: 1.0 [ 8.366435] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 3572, rev 0223 detected [ 8.381349] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 0009 detected [ 8.399067] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht' |
2. Install ConnMan Package
Now, make sure that you have the ConnMan package installed. You can check this as shown below.
1 2 3 4 5 6 |
root@beaglebone:~# ls -l /var/lib/ total 104 drwxr-xr-x 5 root root 4096 Aug 13 14:04 apt drwxr-xr-x 3 colord colord 4096 Mar 26 2016 colord drwxr-xr-x 4 root root 4096 Aug 13 14:59 connman drwx------ 2 root root 4096 Jan 1 2000 container |
If you cannot see the connman package as shown above, then you haven’t installed it. Hence, I’d suggest you install it by using the below command. And make sure you are connected to the internet through ethernet. After installing the connman package, unplug the ethernet cable and use USB cable to ssh into the BeagleBone.
1 |
sudo apt-get install connman |
Once the installation completes reboot your BBB and you should be able to find the connman package in the lib directory as well. Now you have the connman package installed, let us proceed with configuring the WiFi adapter connected to the BBB and connect to the WiFi.
3. Setup WiFi on BBB
First, let us check the available services and their properties as shown below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@beaglebone:~# connmanctl technologies /net/connman/technology/gadget Name = Gadget Type = gadget Powered = True Connected = False Tethering = False /net/connman/technology/ethernet Name = Wired Type = ethernet Powered = True Connected = False Tethering = False /net/connman/technology/wifi Name = WiFi Type = wifi Powered = False Connected = False Tethering = False |
You can see above, that WiFi service is available since the WiFI adapter being connected, however, the properties shows that the WiFi adapter is not powered on and is not connected to the router.
Now, go into an interactive mode for executing further connman commands as shown below, if you’re not as root then use sudo,
1 2 |
root@beaglebone:~# connmanctl connmanctl> |
This is just to show you that, we are not connected to the internet yet. As you can see below, I tried to ping the google server, but it fails.
1 2 |
root@beaglebone:~# ping www.google.com ping: unknown host www.google.com |
Ok, coming back to the configuration, let’s go ahead and enable the WiFi as shown below.
1 2 |
connmanctl> enable wifi Enabled wifi |
4. Scan and Connect to the Access Point
Perform a scan (wait for the scan to complete and then check for services) to view available access points to connect to as shown below.
1 2 3 4 5 6 7 8 9 10 |
connmanctl> scan wifi Scan completed for wifi connmanctl> services *AO Vinay1990 wifi_78abbb9bd6ac_56696e617931393930_managed_psk restobar wifi_78abbb9bd6ac_726573746f626172_managed_psk MGMNT wifi_78abbb9bd6ac_4d474d4e54_managed_wep RazanRasheed wifi_78abbb9bd6ac_52617a616e52617368656564_managed_psk Jeeval wifi_78abbb9bd6ac_4a656576616c_managed_psk AVAOA wifi_78abbb9bd6ac_4156414f41_managed_psk Wired gadget_000000000000_usb |
From the above, It can be seen that “Vinay1990” is my home router and I will connect to it after enabling the wireless agent by running the command as shown below.
1 2 |
connmanctl> agent on Agent registered |
Let’s connect to the access point using the commands shown below, if this is the first time, then it will prompt for a password.
1 2 |
connmanctl> connect wifi_78abbb9bd6ac_56696e617931393930_managed_psk connected wifi_78abbb9bd6ac_56696e617931393930_managed_psk |
Configure a static IP for your BeagleBone as shown below.
1 2 |
connmanctl> config wifi_78abbb9bd6ac_56696e617931393930_managed_psk --ipv4 manual 192.168.1.123 255.255.255.0 192.168.1.1 --nameservers 8.8.8.8 connmanctl> |
In the above, 192.168.1.123 is the static IP assigned to the BBB and the 192.168.1.1 is the gateway IP address. Let’s go out of the interactive mode and check if we are connected to the internet by pinging the google server as shown below.
1 2 3 4 5 6 7 8 |
connmanctl> quit root@beaglebone:~# ping www.google.com PING www.google.com (172.217.26.164) 56(84) bytes of data. 64 bytes from maa03s22-in-f4.1e100.net (172.217.26.164): icmp_seq=1 ttl=56 time=13.3 ms 64 bytes from maa03s22-in-f4.1e100.net (172.217.26.164): icmp_seq=2 ttl=56 time=16.5 ms 64 bytes from maa03s22-in-f4.1e100.net (172.217.26.164): icmp_seq=3 ttl=56 time=13.7 ms 64 bytes from maa03s22-in-f4.1e100.net (172.217.26.164): icmp_seq=4 ttl=56 time=15.6 ms 64 bytes from maa03s22-in-f4.1e100.net (172.217.26.164): icmp_seq=5 ttl=56 time=13.2 ms |
From above, It can be seen that we have successfully connected to the internet and able to reach the google server. For more information on the usage of the connmanctl command, you can check out the connmanctl command manual page. You can now go ahead and start building wireless or IoT applications on your BBB. Enjoy 🙂