Up and Running with the Board
Any previous experience with embedded systems platforms will make your path towards IoT prototyping much more direct. In addition, in order to interact with more complex devices or shields, you should know how the Inter-Integrated Circuit (I2C) bus and Serial Peripheral Interface (SPI) bus work. Some shields that you connect to the Galileo board require you to use either I2C or SPI buses to communicate with them, and the Node.js libraries provide only a high-level abstraction to send and receive messages through these buses. If you don't meet these knowledge requirements, don't worry you can still read along and follow my examples. However, you will need to learn about those electronics and hardware topics before you actually start work on more complex IoT prototypes.
There are many starter kits that provide a collection of modules, which you can easily plug in to your Galileo board for rapid prototyping. I won't be working with additional modules, so the Intel Galileo Gen 2 board will be enough to run my examples. The Intel XDK IoT Edition IDE requires the board to boot a specific Yocto Linux meta distribution from a microSD card that must be plugged in to the board. The meta distribution includes additional libraries and resources that aren't included in the Yocto Linux available in the board when you unbox it without a microSD card. The specific meta distribution includes Intel IoT Development Kit software, Node.js, GCC, Python, and many Node.js hardware interface libraries, among other packages. Thus, the first thing you need to know is that you cannot unbox a board and start working with the IDE without a few additional steps and some configuration preliminaries.
Intel XDK IoT Edition is a free multiplatform IDE that runs on Windows, Mac OS X, and Linux. You must sign in with an Intel Developer Zone account in order to start working with the IDE. If you don't have an account, you can register for free when you start the IDE for the first time.
After you unbox an Intel Galileo Gen 2, you will find the following elements:
- Intel Galileo Gen 2 board
- 12 VDC, 1.5 A power supply
I initially worked with Intel XDK IoT Edition version 52 without updating the original on-board firmware. In some cases, you might need an update and it is a good idea to make sure that the board has the latest available firmware before you work with the IDE. Thus, it is necessary to follow the instructions explained here to use the Galileo Arduino IDE to update the onboard firmware to the latest available version. You must remove all the connections from the board and the microSD card before running the firmware update. You need to connect a USB Type A to Micro-B USB cable from your computer to the micro USB connector labeled as
USB CLIENT in the board after the board has finished the boot process. Notice that you cannot power the board off USB. Just make sure you follow all the instructions explained to update the firmware in order to avoid damaging the board. (Sadly, the cable isn't included within the board's box.)
After you finish updating the on-board firmware and testing that it works correctly, make sure you disconnect the USB cable and unplug the board's power supply. There is still more work to be done before you start working with the IDE. You need the following additional elements that aren't included within the board's box:
- A microSD card of at least 4GB with a maximum capacity of 32GB. It is convenient to use a speed class 4 or greater microSD card.
- An Ethernet cable.
- An Ethernet switch or a WiFi router with a free Ethernet port. (You will connect the board to your LAN.)
You need to download the latest version of the Yocto boot image (
iot-devkit-latest-mmcblkp0.direct.bz2), decompress the downloaded image file, and write the extracted image (
iot-devkit-latest-mmcblkp0.direct) to the microSD card. You can download the latest compressed boot image from the Intel repository.
For Mac OS X and Linux, you can use bunzip2 to extract the contents from the bz2 file, diskutil to unmount the microSD card, and dd to write the image to the microSD card. For example, the following dd command writes the image in the input file named
iot-devkit-latest-mmcblkp0.direct to the previously unmounted microSD card in
/dev/disk1. Be careful with the commands to avoid erasing the wrong device (such as your hard drive!):
sudo dd if=iot-devkit-latest-mmcblkp0.direct of=/dev/disk1 bs=8m
Note that it will quite a while to write the image to the microSD card. Wait until the command finishes and the terminal displays the prompt again before closing the terminal window.
Make sure that the board is unplugged and place the microSD card with the Yocto image in the microSD card slot on the board (see Figure 1). Next, connect the board to your LAN with the Ethernet cable and plug in the board's power supply to turn on the board and start it up. You will notice the onboard LED labeled SD indicates that there is activity with the microSD card. Wait approximately 1 minute to make sure that the board finishes the boot process. The LED labeled SD will stop blinking after the boot process finished.
Figure 1: An Intel Galileo Gen 2 board with the microSD card and connected to a LAN with an Ethernet cable.
Configuring the IDE
Now, launch Intel XDK IoT edition. At the bottom of the window, you will find a panel with a dropdown, labeled IoT Device, and a few buttons. The following list shows the commands for each of these controls from left to right (see Figure 2). I will use the command names included in this list in my explanations.
- IoT device dropdown.
- Manage your daemon/IoT device.
- Toggle console window.
Figure 2: The IDE control located at the bottom of the main window.
Click on Toggle console window. You will be able to check what the IDE is doing when you execute the different commands and interact with the board. You will see two new buttons at the right-hand side of the bottom panel that allow you to copy the console contents and clear the output.
After the board finished booting, it will be running the Intel XDK app daemon. The IDE uses Bonjour, also known as short for Zero-configuration networking (Zeroconf ), which is a multicast DNS service to automatically detect the compatible devices connected on the LAN. In Windows, you can download and install Bonjour here. However, you might have problems in certain versions, such as Windows 8.1. If you have trouble, you can use the Bonjour Browser developed by Hobbyist Software for Windows to discover the board's assigned IP. In Mac OS X, you can use the Bonjour Browser application developed by Kevin Ballard for Mac OS X to achieve the same goal.
Click on the IoT device dropdown. If you don't see an IP address and a port after a separator, click
[%] Rescan for devices and the IDE will try to find the device in the network. If you see an IP address and a port (the default port is
58888), select it and the IDE will display a dialog box indicating that it can establish a connection with the Galileo Gen 2 board (the device).
If you don't see the device listed, make sure you've waited the necessary time to let the process finish. If you cannot see the device IP listed after rescanning for devices, you can use the MAC address included in a label on the board's Ethernet port, and check your DHCP client list to obtain the IP address assigned to the board. Your LAN administrator might help if you are using a corporate LAN. Then, click on the IoT device dropdown, select
[+] Add Manual Connection and enter the IP address and the port number. Remember that the default port for the Intel XDK app daemon is
58888. Once you know the IP address, you can use a terminal to connect, run
ssh, and log in to the remote device. The
root user doesn't have a password.
Make sure the device is selected in the IoT device dropdown. Then, click
Manage your daemon/IoT device |
Set IoT device name/alias and enter the desired alias to easily identify your board. The IDE will display the alias to identify your board within the IoT device dropdown.
Manage your daemon/IoT device |
Sync PC time with clock on target device. Notice that the IDE will display information about the latest command after it finishes in the console window.
Manage your daemon/IoT device and activate the following checkboxes below
Build Settings. This way, whenever you deploy any new node module added to the package, it is going to be installed on the board.
npm installdirectly on IoT Device (requires Internet connection on device)