Please select an option to see content specific to your location and shop online.

Project

Getting Started With The BeagleBone Black Wireless

Scroll down

If you’re anything like me, at some point you get asked to use a brand new board for a project. This can be for a variety of reasons, and it comes with a variety of feelings – including one that reigns supreme “YES! Let’s do this!”. When it comes to starting down the path of a new board, you may feel overwhelmed, but have no fear you are in good hands. Relax, and enjoy the easy way to BeagleBone exploration.

The first part is now the easiest thanks to OKDo. Go to okdo.com and order your BeagleBone Black Wireless. Same great BeagleBone Black that users have been loving for years, now with Wifi, Bluetooth and more!

Once you place the order wait for that shiny box to show up! Also make sure you have an SD Card on hand for updating your OS.

Choose An Image

Go to https://beagleboard.org/latest-images and download the latest Debian Images. The images themselves list their compatibility. Currently the BeagleBone Black Wireless is included in all of the main ones. The major difference is between the IOT build which lacks a GUI and is more for behind the scenes headless server interface., and the LXQT image which includes a full GUI experience and common tools. Both will work for our needs, and I played with both but found the LXQT quite easy to use.

Once you have it downloaded be sure to unzip the image so its ready for our next step.

Flash Your SD Card

Get a program to flash your Image
Now that you have the image we have to get it on that SD Card you have waiting. To do this we will use a handy flashing program based on our OS. Currently I’m using a Mac, so I have found that Etcher (now from balena) is a great program for writing the images (https://www.balena.io/etcher/ ).

On Windows I’ve found Rufus to be a great choice, as well as Win32DiskImager.

https://rufus.ie
https://sourceforge.net/projects/win32diskimager/

Download the appropriate program and install it.

Click on “Select image”
After starting Etcher you will click on Select Image to get started.

Choose your Image
In our case we are picking the LXQT image and then clicking “Open”. Make sure your image is unzipped and ready to be written.

Choose your SD Card
Use the “Change” option under the Storage Media Column to select the SD Card you want to use.

Click on “Continue”
After making sure you have chosen the proper SD Card (MAKE SURE YOU PICK THE RIGHT ONE – THIS WILL ERASE THE CARD! ) choose “Continue”.

Click on “Flash! I”
This will begin the official flashing process. Feel free to go for a brief stroll or grab yourself a cup of the all important coffee.

Just in case!
You may see this message when it starts to flash, meaning it needs permission to make the changes to your disk. Simply enter your password for the currently logged in user and click “OK”. It will then show your progress for the flashing, then verifying the flash was successful.

It’s Done!
The flashing has now completed, so don’t freak out when you see this. Often time with a variety of Linux images, after writing the image it then attempts to mount the disc. When this happens, it doesn’t recognize the format, so this warning pops up from the OS. Click “Ignore” and continue.

Congratulations!
You now have an OS image on your SD card your BeagleBone can boot from. If you are using one of the other boards, especially those without an OS on-board, you are set. If you want to use this disc to automatically update the OS on your BeagleBone black wireless, you have a few more steps to go, which we will cover in a bit. Close etcher and we can get hooked up!

Connect Your BeagleBone

Insert the SD Card
Insert the SD Card into your BeagleBone Black Wireless. This will allow us to make the changes needed if we want to autoflash the latest OS image.

Connect to your PC
Connect your BeagleBone Black Wireless to your computer using the MicroUSB Cable. Wait a few minutes for it to initialize and boot before proceeding to the next step and verifying it’s connection.

Open your Start Page
If we wanted to get out of this easy, we’d just tell you to then fire up 192.168.6.2 in your browser (we used Chrome, which comes in handy later) but we can attest that some times it isn’t that simple! So we’ll help you out a little. Take a chance and try, and if it doesn’t work, follow our “next step”, otherwise skip jump ahead a step.

Find Your Network IP

Tracking down your IP
If it doesn’t work the easy way, have no fear, there are a couple of other ways we can find it. Open up System Preferences, and navigate to “Network” preferences. From here we can see if it is detected.

Is it here?
If your Beaglebone Black Wireless is detected by your computer, it will show up here, along with the IP address of your connection (NOT THE IP ADDRESS OF THE BEAGLEBONE HOST PAGE). Here you can see it detected our board, so we will click on it to pull up the stats.

Double Check the IP
Again, this is the IP of your connection, not the host page.

By default the BeagleBone Black Wireless IP, through the USB Network connection, will be 192.168.6.2.

Since our IP is in the .6 subnet we can assume this is the case, as expected.

Start Pages

Navigate to Start Page
Type in: 192.168.6.2 in your browser and this beautiful page should pop up. If so we can jump to the fun stuff.

This page contains a wealth of information, so don’t skimp on reading it when you have time.

Click on “Cloud9 IDE”
Scroll down the front page and click on “Cloud9 IDE”. This is where we will be writing our code. It’s simple already onboard, and lets us use bonescript to make things happen fast.

Setting up your SD Card for Automatic Flashing

Your SD Card by default is set just to allow it to boot directly as an OS. This is great for the boards that don’t have an onboard flash to store the OS, but your BeagleBone Black Wireless is a luxurious companion with this capability. Because of this we need to modify your SD Card to allow for flashing. Luckily we can do this using the Beaglebone Black Wireless itself.

Insert the SD Card and let the BeagleBone Boot and be recognized by the system.

Ours was the default of 192.168.6.2

Open Terminal
Since we are using a Mac we will open Terminal to allow us to SSH into the BeagleBone.

If we were in Windows we would use Putty to do the same.

Enter the SSH Command
Type in:

ssh
debian@192.168.6.2

This is important as we need to use the default username of debian, since we know the default password for this!

Hit return and if this is your first attempt connecting then it will let you know about the new fingerprint it detected. If so : Type in “yes” and hit enter.

Enter the Password
By default the debian user password is “temppwd”. Enter this when asked and hit enter.

You will now be at the command prompt.

Edit the/boot/uEnv File

At the prompt, enter the command:

sudo nano /boot/uEnv.txt

This will use the common Nano editor to edit the uEnv text file with the setting we need.

Using Nano is one of the simpler tools for editing these files.

Scroll down to the bottom of the file where you will see the section starting:

##enable Generic eMMC Flasher

# is a symbol that lets the OS know this is a comment, so any line that starts this way is ignored.

## is generally used in these cases to let the end user know that this is an actual Comment. By using a single # to comment out a line, it can easily be un-commented, and added back into live use, but using two ## lets the user know this is a comment, generally to let the end user know what needs to be done or why these lines are here.

We won’t get too technical, just find that section then go to the line that starts

#cmdline=init=/.......

as highlighted in this photo.

Delete this # so that the line now starts just

cmdline=init=/......

Save the file
Use Ctrl+O (the letter O) to save the file.

It will pop up a dialog at the bottom, letting you know the file you are about to save. Leave it as it is and hit enter.

Reboot your BeagleBone with “Boot” button held down
Leaving the SD Card in, unplug the Beaglebone Black Wireless.

Holding down the “Boot” button (up near the power connector) plug the BeagleBone Black Wireless.

Wait until all 4 LEDS in the status row light up at the same time then release. The status LEDS will look like it is booting normally then go into a really cool Cylon pattern. (for those more vehicularly inclined than robot enamored, think KITT lights!)

This will continue for a while (up to 45 minutes depending), then all the lights will go dark.

At this point your board is flashed. Remove the power, then remove the SD Card. Then plug your board back in to your computer and lets get started coding!

The Development Environment

Our board is booted and ready to go!
(We know because we can reach this webpage when we navigate to 192.168.6.2 – also because we have that beautiful green box!)

Click on “Cloud9 IDE”
Scroll down the page until you get to the Cloud9 IDE link and click it.

On the way you’ll pass the BoneScript section. Once you’ve whet your appetite go there to find out more about what BoneScript can do. BoneScript is the “language” we will be using. It is based of of javascript with special customizations for scripting for Beaglebone Black Wireless’ capabilities.

We promise we won’t try and bore you too much with all the coding talk (heck, you may already be well versed and are just looking for the finer points needed here) but we want to cover the basics for those just getting started. We will keep it real simple, and give you just what you need to accomplish our goals, without overwhelming you. If you want a deeper dive there are many resources on almost all of the aspects to run and find out more from.

Cloud9 is an onboard hosted coding tool. It is an IDE (Integrated Development Environment) letting you write your code, compile it for the computer to run (or to let you know when you haven’t typed something quite right), and even debug it (for when you didn’t type what you thought you typed). This is very handy, and Cloud9 is very easy to use.

Welcome to Cloud9
Feel free to browse around but to start we will concentrate on the file structure section on the left hand side.

Behind the scenes Cloud9 is already being hosted on it’s own web server on our board, but we don’t need to concern ourselves with the details now. Just realize that, and it makes certain things (like hosting web pages from within there) easier.

Examples abound
Feel free to check out the many examples they have given us to get started with. Many great examples of how to do basic (to advanced) tasks are here.

Enough already! To the CODE!!!

Digging Into The Code

Right click in the Blank area of Cloud9

By doing this we open up a context sensitive File System Menu that lets us organize our code.

Coders can have a tendency to be fanatical about these things, having intense discussions over the smallest of considerations. For now we won’t bother with all of that, other than to say, once we start coding examples, we will create a new directory for each project.

By using a separate directory for each project we will keep everything neat and tidy and orderly, which will help later when things get complex.

Click on “New Folder”

This allows us to create a New Folder.

We will call it “MyPrograms” to house all of our programs. This gives us a great home base.

Click on “MyPrograms”

Then repeat the same process as before to add another subdirectory:

Right Click on “My Programs”

This will bring up the same menu.

Again choose “New Folder”

We will name this one “BlinkDemo”

For our Demo we will be blinking the status LEDS.

Right Click and Choose “New File”

Name it BlinkDemo.js

Click on BlinkDemo.js
This will open the BlinkDemo javascript file so we can edit it.

Because we made our file a “.js” file the system automatically assumes it’s a javascript file. This means it assumes it is a program ready to compile and run. If you didn’t know – now you know!

We will take a little extra time this first code run through for those that may not feel at home here. Nothing to be afraid of – its pretty simple once you see how it works.

Decoding: BlinkDemo
Enter the following code in the BlinkDemo.js file

//flash lights
var b = require('bonescript');
var state = b.LOW;

b.pinMode("USR0", b.OUTPUT);
b.pinMode("USR1", b.OUTPUT);
b.pinMode("USR2", b.OUTPUT);
b.pinMode("USR3", b.OUTPUT);

setInterval(toggle, 1000);

function toggle() {
    if(state == b.LOW) state = b.HIGH;
    else state = b.LOW;

    b.digitalWrite("USR0", state);
    b.digitalWrite("USR1", state);
    b.digitalWrite("USR2", state);
    b.digitalWrite("USR3", state);
}

Decoding: // Comments
// is a way to add comments to your code that the computer ignores.

Any line (or any text after) these characters simply does not exist to the computer. This is very helpful when you are writing difficult code, or you want others to be able to easily understand your own code.

“//flash lights” is used to remind ourselves that this program flashes the onboard lights (LEDs – or Light Emitting Diodes)

You will also often see this after variables such as var iCount = 0; //my variable to track my count of the loop

Decoding: Declare Variables
We declare two variables.

The first is the MOST important and we will use it in all of our Bonescript programs.

var b = require('bonescript');

We are declaring a variable “b” that will become our Bonescript object, or basically our stand in for the Beaglebone Board.

Through this variable (sometimes it helps to think of it as an object), we can do things like measure the voltage on a pin, turn things on and off, control onboard peripherals, use the various wireless connections, etc. This is the central hub for what we will do.

By Requiring the Bonescript libraries we are pulling in all of the necessary units and libraries that we will need to do this, making it VERY simple to take actions with our board. In fact our first example is our next variable.

var state = b.LOW;

We have created a variable to track the state of our pins. For now we will keep this real simple and say that our pins will be ON (High) or OFF (Low). This equates to a voltage level on the pins, but for now that is enough to keep us moving.

If we want an LED to be on, it needs to be HIGH, and we can set it to LOW to turn it of .

By creating a variable to track our state, we can easily keep track of on or of in our memory, without needing to read it in from anywhere.

Decoding: Setting our Output Pins
In order to use a pin (GPIO or otherwise) on our Beaglebone, we must let our program know that we want to use it, and HOW we want to use it (INPUT, OUTPUT, ETC).

In this case we want to use our onboard LED pins (USR0, USR1, USR2, and USR3) to flash them on and of . (These are the same 4 LEDS in a row you see flashing as status LEDS when your board is on, and the ones that made the neat cylon display when you flashed the latest OS).

b.pinMode("USR0", b.OUTPUT);
b.pinMode("USR1", b.OUTPUT);
b.pinMode("USR2", b.OUTPUT);
b.pinMode("USR3", b.OUTPUT);

In this code we use pinMode, which lets us set the mode of our pin. Since its a part of our beagleboard we use the function from our “b” variable.

We pass it two parameters, which Pin we are talking about, and what Mode to set it to. So in the first line we are really saying “Hey Beaglebone, I want Pin USR0 to be used for OUTPUT!”

Decoding: setInterval
“setInterval” is a function that tells the Beagleboard to run a specific function over and over on a specific interval. That specific interval is set in milliseconds. This means for every second we want it to wait, we tell it 1000. We pass setInterval the name of the function we want it to run. setInterval(toggle, 1000);

This tells our Beaglebone to run the function “toggle” once every second.

Decoding: Functions
We declare a function simply by using the function keyword then naming our function. So for our function “toggle” we simply say

function toggle() {

// DO SOMETHING HERE

}

The () after toggle means our function takes no parameters. Parameters are values we would pass to our function to let it do it’s task. In this case it needs none.

The curly braces { and } come before and after our code. They sandwich the block of code that our function runs. That is why I put a giant “DO SOMETHING HERE” comment in this slide, because that is precisely where we will do something – in this case toggle the LEDs.

Decoding: If / Then / Else
In order to process logic we use a variety of statements in code. One of the simplest is an if / then statement.

IF (*SOMETHING IS TRUE*)
THEN (*DO SOMETHING ELSE*)

We can add to this with the if/then/else. The “ELSE” is simply a way of saying that, if the “IF” is FALSE then do a DIFFERENT TASK.

if(state == b.LOW) state = b.HIGH;
else state = b.LOW;

Here we are looking at our “state” variable. If the state is LOW the lights are off, if it is HIGH they are on. We want to turn them OFF if they are on, and ON if they are off.

So we are saying IF our “state” variable is the same as the Beaglebones LOW value, then set our “state” value to the Beaglebones HIGH value. If is not the Beaglebones LOW value, then it is our HIGH value, so we do the ELSE and set the “state” value to LOW.

Decoding: Turning LEDS on and off
In order to turn our LEDs on, we must set the state of our pins HIGH or LOW as previously discussed.

They have already been declared as output pins so now all we need to do is write to the output pin the state we want. Luckily, we already have this state in memory as our variable “state”

We do this by using the digitalWrite command. It is a function of our Beaglebone variable. It takes the pin we want to write to, and the value we want to write to it, and makes it so!

b.digitalWrite("USR0", state);
b.digitalWrite("USR1", state);
b.digitalWrite("USR2", state);
b.digitalWrite("USR3", state);

So, if state is “HIGH” and we call digitalWrite to USR0, it will make sure our USR0 LED is lit up. If the state is “LOW” it will turn . the LED of .

Click “Run”
This will run our program and allow us to see if it works!

Notice we are running Our debugger is now listening and if all goes well our lights will begin to flash.

Congratulations, you have the basics down for working with the BeagleBoneBlack Wireless. Stay tuned as we create more tutorials for working with the this Beagle and their other products.

Created by Chris Yohe.

Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.