WiFi on BeagleBoneBlack

Almost all of the New Media exhibits at the Exploratorium feature a Mac Mini, and if we need it to interface with the physical world, we hook an Arduino to it. To me, that feels extremely wasteful, and in this point of time, just over complicated. True, we have a method of doing things, and it does work, but I feel like it’s time for a new system, and working with BeagleBones seems to me like an excellent solution.

The only thing that is holding me back (that I know of) is connecting the BB to our hidden wireless network, and giving the board a static IP address. However – I think I finally got it. Here goes:

Step 1: create /etc/wpa_supplicant/wpa_supplicant.conf

wpa_supplicant, if I understand this correctly, is a programs that negotiates the authentication of the computer on the network. wpa_supplicant.conf configures this program. Create this file and edit to look like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
  ssid="Network Name"
  scan_ssid=1
  psk="PasswordGoesHere"
  proto=RSN
  key_mgmt=WPA-PSK
  pairwise=CCMP
  auth_alg=OPEN
}

Step 2: modify /etc/networks/interfaces

This file configures the behaviors of the network interfaces. We need to tell it what IP address we want. and also to ask wpa_supplicant to deal with authentication. Some tutorials will have a wpa-roam. This does not work for static addresses. Use wpa-conf.

wlan0
allow-hotplug wlan0
iface wlan0 inet static
  wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  address 10.120.103.x # replace this with a unique address
  netmask 255.255.255.0 # replace this mask, if necessary
  gateway 10.120.100.1 # replace with your gateway

Step 3: create route.sh

Our next task is to make sure the default gateway for any outgoing traffic is the one referred to by the wireless interface. This script stops the ethernet interface from functioning as the default, and enables the wireless interface.

ip route del default dev eth0
ip route add default via 10.120.100.1 dev wlan0

Step 4: launch script on reboot

Although there are ways to launch commands and scripts after an interface connects to the network, none of them worked for me. My solution was to run the route.sh script from crontab.

sudo crontab -e brings the crontab editing tool. Add this line at the end:
@reboot sleep 60; /home/person/route.sh
This will run the script 60 seconds after boot, giving enough time for network adapters to understand what the hell just happened to them.

That’s it!

Make sure all your programs start after that route.sh or can handle unavailability of the network.

Leave a Reply

Your email address will not be published. Required fields are marked *