Getting Started Guide

Learn how to create a Node.js*-powered IoT app from a sample template and run the app on your board.

The primary goal of this guide is to provide a sample IoT project you can follow along with to learn about features of the Intel XDK. The project we'll be creating is a simple Blink LED NodeJS* application that is based on one of the templates supplied with the Intel XDK.

The secondary goal of this project is to help you learn enough about the features and functions of the Intel XDK to be confident forging ahead with your own projects and testing out other project templates. They may feature examples that are relevant to what you want to accomplish in your own projects, thus saving you time so you don't have to reinvent the wheel!

The sample project walkthroughs use an Intel® Edison board and Intel® Galileo board as examples of IoT devices. Other kinds of boards and devices may be added as we further expand the documentation.

Before we begin, let us get the basic terminology clarified. When we say host platform or machine, we mean the computer where we're installing and running the Intel® XDK. Once the Intel XDK is installed to our host, we can then connect to, talk to, and program the IoT device. The IoT device is what we call the target platform, target machine, or sometimes simply just “the board”.

A high-level summary of the steps we will be walking through is provided here:

  • Assemble your board and gather any hardware requirements for your project.
  • Download and install the Intel® XDK and any required libraries or dependencies to your host.
  • Launch the Intel XDK, select the project and establish a connection between it and the board.
  • Select the Onboard LED Blink template.
  • Connect the board to the Intel XDK.
  • Develop your project, upload it and run it.
  • Make changes to the project and debug as necessary.

Assemble your board and any gather hardware requirements

The steps required for assembling your board vary according to the kind of board. See the appropriate section below:

After assembling your board, be sure you have all the required hardware components for this template

  • Connectors and power supplies required to connect and power your board, including an Ethernet cable for your Intel® Galileo board.
  • A few LEDs, or the Grove* - Starter Kit Plus IoT Edison. Many of the samples included with the Intel XDK are intended to be used with this starter kit. See here for a jumping off point that links to the kit, plus many other sensors that are compatible with genuine Intel boards.

Download and Install the Intel® XDK

Next, download the XDK appropriate to your host from our Downloads page.

Launch the Intel® XDK and Log In

Before establishing a connection to the board, you must launch the Intel® XDK by double-clicking its icon on your taskbar or your desktop. If you have trouble finding the desktop shortcut on Windows, try searching for XDK from the startup menu. To pin the Intel® XDK to your start menu or taskbar, right-click its name and select Pin to Start or Pin to Taskbar.

Follow the on-screen instructions to log in to your Intel® XDK account, or sign-up for a new account. You can work through this guide without creating an account; however, further development will be streamlined applications in the future.

Select the Onboard LED Blink template

From the "Projects" tab, click Start a New Project in the bottom left. The "Start a New Project" page opens. In the Internet of Things Embedded Application list on the left, click Templates: Select Start with a Sample or Template.

Tip: Type or browse for the folder you want to store your projects in the Project Directory field. The Intel® XDK puts each new project inside this parent directory. Each project is stored in its own folder with a matching name.

You can create multiple parent directories for storing your projects. For example, if you'd like to create a separate parent directory for each of your clients, then store all projects for a client in their own designated client folder.

In the Project Name field, type a name for your project.

Example of creating a new project

Click Create. Your project is created.

If you are a Windows user and Bonjour is not installed on your machine, a "Bonjour is missing" message is displayed. Complete the steps in the Install Bonjour section to install Bonjour.
Error message for Bonjour

Connect to the board

  • From the IoT Device drop-down list in the bottom left, select your development board. The Connect to your IoT Device dialog box opens. If your development board is not included in the drop-down list, you must connect to your board manually. Select Add Manual Connection and supply your board's IP address in the Address field. By default, the Intel® XDK assumes your board's IP address is 192.168.2.15. For help finding the IP address of your board, see Manually connecting your board to the Intel® XDK. For general connection issues, see Finding and connecting your board to the Intel XDK.
  • If you have created a user name and password to log in to your board, type them in the User Name and Password fields; otherwise, leave the default values.
  • Click Connect.
  • If you see a message saying that your daemon is out of date, update the daemon. This will disconnect from the board, as the daemon has to be restarted, so follow the instructions to reconnect when prompted.
  • If you see a message about the clock on your board and the Intel® XDK being out of sync, click Sync.
  • A confirmation message appears, displaying the connection status and IP address of your development board. Click Dismiss. Your board is now connected.

Develop your project, upload it, and run it.

  • From the top of the application window, click the Develop tab. Look for the IoT toolbar at the bottom of the window. Example of the IoT toolbar
  • Click the Upload icon Upload icon to upload your project to the board.
  • Now click the Run icon Run icon to run your code. You should see an LED on your board flashing on and off. Click the Stop icon Stop icon to stop the LED.

Congratulations, you have run your first IoT app using the Intel® XDK!

- Modifying the project template

If you have the Grove* - Starter Kit Plus: Intel® (or just a few LEDs on hand), you can tinker with your new project by connecting additional LEDs to your board. In this example, we'll start with a green LED. Connect it between digital pin 13 and ground (GND).

LEDs have a positive lead and a negative lead, so be sure to connect your LED correctly. The positive lead (longer leg) goes in the pin 13 socket, and the shorter leg goes in the GND socket. Also be sure you have the right sockets connected; it can be very easy to stick a lead in the wrong socket due to visual error. The GND socket is the fourth from the top when reading the pin labels right side up, and pin 13 is the fifth from the top.

Your setup should look like the following on an Intel® Edison board:

Example of connecting the LED to an Intel® Edison board

And here's the setup on an Intel® Galileo Gen 2 board:

Example of connecting the LED to an Intel® Galileo board

Now that your project is working, let's modify the template to alternate flashing a set of LEDs.

  1. Restart the project. Since you haven't changed any code, there's no need to reupload your project to your board. The LED you just connected to pin 13 flashes in sync with the LED on your board.
  2. Now take the LED lead currently connected to the pin 13 socket and connect it to pin 12 instead. The LED will go dark and stay that way.
  3. From the top left of the Intel® XDK window, locate the list of project files. From the list, click main.js to view your project code.

    Example of the main.js file
  4. Click the Stop icon Stop icon.
  5. Click the Debug/strong> icon Debug icon. The Node.js debugger opens in a new window.
  6. We can press F10 to step through the code. F11 also steps through our code and the effect is the same until we get to the call to “periodicActivity”. Here we want to use F11 so that we will step into the routine. F10 here would step over the routine.

Stepping into the routine and using either F11 or F10 on each statement, we are none the wiser as to what I have done wrong (pretend you didn’t notice it already!). Let’s take another look at that routine.

  1. Click on the line number 34 in the debug window. You will see the background of the number turn blue. Now click the Resume Script Execution icon near the top left of the debug window:

    Example of the Run icon

    Be sure not to confuse this with the Run icon from the main Intel® XDK window.
  2. After a short time, the entire line 34 will turn blue. This means we have stopped there. Clicking on the line number a few steps ago set a breakpoint on that line so that execution will pause whenever we get there. Now let’s try stepping through the code again and see if we can spot anything amiss.
  3. On my board at the moment, both LEDs are off. Let’s hit F10 to step over the first line. The LED on the board lights up.
  4. Let’s step again. The board LED turns off!

Aha – I have both myOnboardLed and pin12Led associated with the same pin! Let’s check my instantiation of pin12Led at line 25. Indeed, I failed to change that 13 to 12 when I copied the other line. Cut and paste strikes again! So let’s make that change, download the template again and see if that is better.

var pin12Led = new mraa.Gpio(12);

Now my LEDs do indeed “wig/wag”.

Making life easier

Sick of having to perform multiple clicks every time you want to revise and test your code?

  1. Click the Manage your daemon/IoT device icon Manage your daemon/IoT device icon in the lower right of the Intel® XDK, then select Upload Control. The Upload Options dialog box opens.
  2. Under Automatic start, select the Automatically debug after upload option.
  3. Select the Save automatically on upload without asking check box.
  4. Click OK to apply your changes.

Now let’s try that. At line 20, let’s add a message:

console.log('My first fine app');

Click the Upload icon Upload icon. Your file is automatically saved and uploaded to the board, and the debugger is started. Press F10 a few times to step over the lines in the console log. Now click Console near the top of the debugger window. You will see your message “My first fine app” in the console window. You will also see it down in the Intel® XDK console:

Example of the console

One last thing

Notice the tiny “bell” icon just to the right of the IoT Device drop-down list Icon showing that your board is connected. This icon tells you the state of your connection to your board at a glance:

  • Icon showing that your board is disconnected: You are not connected to the board.
  • Icon showing that your board is connected: You are connected to the board, but no program is running on it.
  • Icon showing device connected and project running: You are connected to the board and your application is running on the board.

That concludes this getting started guide. Have fun, and develop some cool applications for your IoT devices.

  • Intel® XDK
  • For more complete information about compiler optimizations, see our Optimization Notice.