Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
BeagleBone Black Cookbook

You're reading from   BeagleBone Black Cookbook Over 60 recipes and solutions for inventors, makers, and budding engineers to create projects using the BeagleBone Black

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher Packt
ISBN-13 9781783982929
Length 346 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Preface 1. Setting Up for the First Time FREE CHAPTER 2. Basic Programming Recipes 3. Physical Computing Recipes Using JavaScript, the BoneScript Library, and Python 4. Exploring GNU/Linux Recipes Using Bash, Autotools, Debugger, and systemd 5. Basic Programming Recipes with the Linux Kernel 6. Run Faster, Run Real Time 7. Applied Recipes – Sound, Picture, and Video 8. The Internet of Things 9. The Black in Outer Space Index

Connectivity

We will show you the two principal recipes to get your BeagleBone Black connected:

  • Ethernet
  • Wi-Fi

Beware that there is a third way to get the BBB online, which is by tethering your board to your desktop machine and piggybacking on its network connection. This is a highly useful but occasionally tricky option.

Connectivity – Ethernet

If you have direct access to your network's router, using the Ethernet connection is pretty much Plug and Play on the BBB.

Getting ready

Here's what you need for this recipe:

  • 5V DC power supply
  • An Ethernet cable
  • A BBB connected to an HDMI monitor. For ease of use and first time connectivity, we suggest that you have your board connected to a monitor for this recipe. After you gain confidence and learn more about connectivity methods, you will be able to dispense with using an external monitor.

How to do it...

Perform the following steps for Ethernet connectivity:

  1. With your BBB powered down, plug in one end of an Ethernet cable to the BBB and the other end to your router.
  2. Power up your board via the 5V power supply.
  3. The connection should occur seamlessly, assuming your Ethernet cable is sound, your internet connection is reliable, and the BBB has no defects.
  4. At your screen's login prompts, enter your login name and password. You will be taken to the desktop.
  5. Next, we will check our connection via a terminal session. In the lower left-hand corner of your screen, click on the bird-like icon and then navigate to Accessories | LXTerminal.
  6. In the open terminal window, type the following:
    $ ping www.google.com
    

    You should be getting ping responses back that look similar to the following output:

    How to do it...

Connectivity – Wi-Fi

Since its original release in the spring of 2013, Wi-Fi on the BBB has been a bit of an Achilles Heel for the platform. Compared to the typical experience with Raspberry Pi, you could pull out your hair getting Wi-Fi to work on the BBB. If you were happy using Angstrom only for your projects, you were in luck as this distribution was (mostly) solid, given that several USB minidongles on the market worked well.

However, on Debian and Ubuntu, unless you did not mind using larger dongles with protruding antennae, connections were flaky. Alternatively, you could invest a chunk of time writing custom drivers. So much for out-of-the-box portability.

Fast forward to the (mostly) good news. With the three different Wi-Fi dongles that we tested on the current shipping version of Debian 7 Wheezy for the BBB (using 3.8.13-bone71) and on Debian 8 Jessie, we largely got positive results. The bad news? With the exception of using Debian Jessie, not all dongles were recognized by the BBB without some configuration. However, it is fairly easy to set up the hardware, and you also may get lucky with the dongle you have in your kit and get immediate connectivity.

Note

If you are using Debian 8 Jessie, skip immediately to Method Four: Debian Jessie.

Getting ready

The following are the prerequisites for Wi-Fi connectivity:

  • DC power to the BBB—the board should be powered from a 5V DC 1A minimum supply and not via USB.
  • A connected HDMI monitor.
  • Wired or wireless keyboard and mouse connected to the USB hub.
  • A powered USB hub—the Wi-Fi dongle draws more power than the BBB can deliver if you only power the board via the USB port on your client box. Instead, you need a powered hub to do the job. If you don't use a powered hub, you may be able to get away with decent stability, but you are just as likely to get poor results.
  • Wi-Fi dongle—refer to tables to test compatible versions.

We will divide this recipe into three different setup methods as some dongles are happy with one method while others prefer the second one. We will also include the setup for Debian 8.0 (Jessie) as this distribution has greatly improved and simplified the process.

Some of the setup instructions are derived from http://elinux.org/BBBWiFiConfigs.

The micro USB dongle models

The universe of low-cost Wi-Fi dongles available on the market is fairly large, the following table being a very small subset. The mini dongles we used in these recipes have been historically problematic with the BBB but are now more reliable with the current Debian distribution. Your best results, however, may be with a standard-sized (nonmicro) dongle that also comes accompanied by an antenna.

The following table shows the tested and working models of micro USB dongles for our recipes. Note that the first three models use Method Two for setup and the last two use Method Three. All dongles are priced around USD $10.00-12.00:

Method Two

Product Name

Supplier

Manufacturer

Chipset

Power requirements

NOTES

Ourlink

Adafruit

Realtek

RTL8188CUS

powered USB

This is the same product as #2

802.11b

Adafruit

Realtek

RTL8188CUS

none

This is sold by Adafruit as the same product as #1; however, there seems to be some difference since a powered USB is not required.

Trendnet TEW648UBM

B&H

Realtek

RTL8188CUS

powered USB

The board may freeze up without using a powered USB. May also need to reboot and run. Use the reset (S1) button to get a connection.

Method Three

UWN100

Logic Supply

Ralink/MediaTek

MT7601

powered USB

 

UWN200

Logic Supply

Ralink/MediaTek

MT7601

powered USB

This uses antennae.

Note

UWN200 is not tested by the author but cited by the BBB Google forum posters as a compatible dongle with possibly superior performance given the antenna addition.

How to do it...

Method one: Graphical desktop application

In lieu of the command line, the current distribution of Debian 7 (3.8.13-bone71, Wheezy) includes a handy graphical tool—Wicd Network Manager—to set up Wi-Fi. This recipe is quite simple:

  1. Power up your BBB via 5V DC.
  2. Log in to a desktop session.
  3. In the lower left-hand corner of your screen, click on the bird-like icon and then navigate to Internet | Wicd Network Manager.
  4. In the newly opened window of the application, click on the Switch On Wi-Fi button. The dongle will now begin scanning for accessible networks.
    How to do it...
  5. Choose your local network. Enter your password in the popup window according to the type of encryption your network uses. Then, click on OK. After a few moments, your dongle will be connected.
  6. Check the connection with the ping command:
    $ ping www.google.com
    

    If all is well, you will be getting solid pingback messages.

Although the preceding steps are straightforward, you might find that your dongle will not work with this recipe or that you are using a different version of the kernel and easy connectivity eludes you. If so, here are other recipes to get connected.

Method Two: command line option 1

Consult the table at the beginning of this section for the tested models that use Method Two. Note that they all use the same RTL8188CUS chipset. This means that you will likely be able to use other dongles with the following steps as long as they use the aforementioned chipset. Now to the steps:

  1. From your BBB's desktop, open up LXTerminal.
  2. In the command prompt window, open the file in the directory specified in the following path:
    $ sudo nano /etc/network/interfaces
    

    Among other settings, you should see the following lines in the file's open window:

    ## WiFi Example
    #auto wlan0
    #iface wlan0 inet dhcp
    #   wpa-ssid "mynetworkname"
    #   wpa-psk  "mypassphrase"
    
  3. With the exception of the first explanatory line, uncomment (which means remove) the # sign at the beginning of each line. To clarify, it should look similar to this:
    ## WiFi Example
    auto wlan0
    iface wlan0 inet dhcp
       wpa-ssid "mynetworkname"
       wpa-psk  "mypassphrase"
    
  4. Change mynetworkname to your Wi-Fi network's name, and mypassphrase to your Wi-Fi password.

    Note

    If your network name uses spaces or other odd characters, some dongles may not recognize the name and establish a connection.

  5. Close the file by pressing Ctrl + x; when prompted, type y for yes and then press the return (Enter) key.
  6. Power down the BBB in the terminal window with the following command:
    $ sudo poweroff
    
  7. Power up the board again and log in to your BBB desktop.
  8. You will now get a solid Wi-Fi connection. Test it via the command shell with this command:
    $ ping www.google.com
    

    If all went well, you should see a steady screen output from the ping.

Method Three: command line option 2

Consult the table for the tested models that use the following steps. The main difference between these steps and the previous recipe is that the drivers in these dongles require a different interface—a wireless supplicant—with the BBB to function properly. Before starting the steps, be sure to remove any Wi-Fi dongles you may have inserted into the USB hub:

  1. We need to create a .conf file for wpa_supplicant, a tool that comes preloaded on the current Debian distribution. The following command line will be useful for this:
    $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
    
  2. Paste in the open file the following information:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    network={
     ssid="my-ssid"
     scan_ssid=1
     psk="my-psk"
     proto=RSN
     key_mgmt=WPA-PSK
     pairwise=CCMP
     auth_alg=OPEN
    }
    
  3. Two things need to be modified (just as in Method Two): my-ssid, which you will replace with your network's name, and my-psk, which will be your network's password.
  4. We now need to figure out the Wi-Fi dongle's interface name. To do this, we will first examine which interfaces are present using the following command:
    $ ifconfig -a
    

    This command outputs the currently active interfaces, which may include eth0, lo, and usb0.

  5. Reboot your board.
  6. Plug in your dongle and run the same command again:
    $ ifconfig -a
    

    The output should now show the new device's interface name, which could be ra0, wlan0, or so on.

  7. Open the file in the directory specified in the following path:
    $ sudo nano /etc/network/interfaces
    
  8. At the top of the file, paste the following code, replacing interfacename with the name that appeared in Step 6:
    allow-hotplug ra0
    iface interfacename inet manual
      wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet dhcp
    
  9. Close the file by pressing Ctrl + x; when prompted, type y for yes, then press the return (Enter) key.
  10. Assuming your dongle is still plugged in, run a command that brings up the interface:
    $ ifup interfacename
    
  11. Power down the BBB by running this:
    $ sudo poweroff
    
  12. Make sure your Wi-Fi dongle is plugged into a powered USB hub with the hub's USB cable inserted into the BBB's USB port.
  13. Restart the board; this time, plug into the DC power supply.
  14. You will now get a solid Wi-Fi connection. Test it via the command shell using the following command:
    $ ping www.google.com
    

    If all went well, you should see a steady screen output from the ping.

    Note

    Sometimes you may need to power off, unplug the 5V input, and then plug in again as the dongle isn't always recognized through the S1 (Reset) or the S3 (Power) buttons.

Method Four: Debian Jessie

Using Jessie is the easiest and fastest route to a reliable Wi-Fi connection. Here is how to do this:

  1. Plug an Ethernet cable connected to your router into the BBB's Ethernet port.
  2. Boot up and log in to your BBB connected to a monitor.
  3. Open a terminal window and log in as root with the following command:
    $sudo -i
    #
    
  4. Install the package network manager. Before installing a new package, always begin by updating your repositories as follows:
    # apt-get update
    # apt-get install network-manager
    
  5. Now, open up the new package with this command:
    # nmtui
    

    A rudimentary interface should open up in the terminal window, similar to the following image:

    How to do it...
  6. Select Activate a connection.
  7. In the next window, select your network, and you will be prompted for the password.
  8. Quit the network manager screen after putting in your password. Then, check to verify that your dongle now has an IP address in the wlanX interface with this command:
    # ifconfig -a
    
  9. Now, power down, remove the Ethernet cable, and reboot using this command:
    # reboot
    
  10. Run the magical ping command to check how we did:
    $ ping www.google.com
    

    Voila! Your BBB should now be connected wirelessly.

There's more…

Some users report that the board can interfere with a Wi-Fi dongle's USB signal. So, if you do not get a reliable connection, position your powered USB device containing the Wi-Fi dongle a few feet away from the BBB.

See also

Take a look at a list of other compatible dongles here at http://elinux.org/Beagleboard:BeagleBoneBlack#WIFI_Adapters.

You have been reading a chapter from
BeagleBone Black Cookbook
Published in: Nov 2015
Publisher: Packt
ISBN-13: 9781783982929
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image