Getting started with Johnny Five and the Intel Galileo gen2

David Resseguie edited this page Jan 29, 2016 · 2 revisions

In this tutorial we will learn how to set up an Intel Galileo development board and get it to run a blinking LED loop in johnny-five.

NOTE: You will need a 16 or 32GB micro SD card for your Galileo to complete this tutorial

Update firmware

Before we get started we want to make sure that we have the latest firmware installed on our Galileo. This process can be different depending on the Operating System you are using on your development machine. Therefore Intel provides detailed instructions for this process for each supported OS.

NOTE: If you get the error message Target Firmware Version Query Failed it usually means that the Galileo is not available on the selected serial (USB) port in the IDE. Sometimes it may happen if there is a sketch running on the board. Try rebooting the board and your computer, then connect the USB cable and re-select the correct serial port in the IDE.

Installing Yocto Linux Image

Before we can get johnny-five to run on the board, we first need to download the Yocto Linux image for the Galileo and install it on our micro SD card; you can download the latest image here

Once the image is downloaded we will need to extract it and install it on our micro SD card. This process once again can be different depending on your OS.

Getting remote access to your board

Note: If you are on Windows , you can use PuTTY to make ssh connections.

Now that we have Yocto Linux Installed on the micro SD card and have booted our board with it, it's time to get access to it.

There are a few options when it comes to getting terminal access to the Galileo. But by far the easiest way is just to plug in an ethernet cable and access it via SSH.

To do this we first need to obtain the IP address of the Galileo. This can be found using applications like fing or Bonjour Browser.

Bonjour Galileo IP address

Now that we have our IP, all we need to do is type

ssh root@x.x.x.x

We should now have a root terminal session on the Galileo

Tip: To exit the ssh session and get back to your local terminal type exit

Setting the date

It's always a good idea to be sure that the OS on the board has it's date set correctly, especially when using npm. You can very easily get the date from another system on your network by typing:

date -u `ssh username@x.x.x.x date -u '+%m%d%H%M%Y.%S'`

where x.x.x.x is a system with the correct date

NOTE: If you don't have access to such a machine , you can also follow this guide on setting the date for the Galileo.

Running a blink example

The Yocto Linux image already has node installed so all that's left to do is write some Johnny-Five code, push it to the board and then run it.

We will do this in a folder on our local machine and then copy it to the Galileo to run. You can either set up the Galileo with an LED on pin 13 or you can just watch the built in LED labeled L right next to the USB port on the board. This example is the same as the standard Johnny-Five blink example, except it specifies the use of the galileo-io IO-Plugin so it will run directly on the board.

Let's create an index.js with the following code:

var five = require("johnny-five");
var Galileo = require("galileo-io");
var board = new five.Board({
  io: new Galileo()
});

board.on("ready", function() {
  var led = new five.Led(13);
  led.blink(500);
});

And now we can copy index.js over to the board using scp:

scp index.js root@x.x.x.x:~

Now ssh back into the board and let's run our code.

First we we install our dependencies:

npm install johnny-five galileo-io

Then we run our program with node index.js.

We should now have a blinking light on pin 13!

Further reading