Setting up WiFi on BeagleBone Black

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.

Shell

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.

Shell

1

apt-getupdate&&apt-getinstall 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.

2. Install ConnMan Package

Now, make sure that you have the ConnMan package installed. You can check this as shown below.

Shell

1

2

3

4

5

6

root@beaglebone:~# ls -l /var/lib/

total104

drwxr-xr-x5root root4096Aug1314:04apt

drwxr-xr-x3colord colord4096Mar262016colord

drwxr-xr-x4root root4096Aug1314:59connman

drwx------2root root4096Jan12000container

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.

Shell

1

sudo apt-getinstall 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.

Shell

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,

Shell

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.

Shell

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.

Swift

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.

Shell

1

2

3

4

5

6

7

8

9

10

connmanctl>scan wifi

Scan completed forwifi

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.

Shell

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.

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.

Shell

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.

64bytes from maa03s22-in-f4.1e100.net(172.217.26.164):icmp_seq=1ttl=56time=13.3ms

64bytes from maa03s22-in-f4.1e100.net(172.217.26.164):icmp_seq=2ttl=56time=16.5ms

64bytes from maa03s22-in-f4.1e100.net(172.217.26.164):icmp_seq=3ttl=56time=13.7ms

64bytes from maa03s22-in-f4.1e100.net(172.217.26.164):icmp_seq=4ttl=56time=15.6ms

64bytes from maa03s22-in-f4.1e100.net(172.217.26.164):icmp_seq=5ttl=56time=13.2ms

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 🙂