Click here to Skip to main content
15,742,303 members
Articles / Internet of Things
Posted 17 May 2016


3 bookmarked

How-To Intel IoT Code Samples: Range Finder Scanner

17 May 2016CPOL6 min read
This range finder scanner application is part of a series of how-to Intel IoT code sample exercises using the Intel® IoT Developer Kit, Intel® Edison development platform, cloud platforms, APIs, and other technologies.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.


This range finder scanner application is part of a series of how-to Intel IoT code sample exercises using the Intel® IoT Developer Kit, Intel® Edison development platform, cloud platforms, APIs, and other technologies.

From this exercise, developers will learn how to:

  • Connect the Intel® Edison development platform, a computing platform designed for prototyping and producing IoT and wearable computing products.
  • Interface with the Intel® Edison platform IO and sensor repository using MRAA and UPM from the Intel® IoT Developer Kit, a complete hardware and software solution to help developers explore the IoT and implement innovative projects.
  • Run this code sample in Intel® XDK IoT Edition, an IDE for creating applications that interact with sensors and actuators, enabling a quick start for developing software for the Intel® Edison or Intel® Galileo board.
  • Set up a web application server to view range finder data using a web page served directly from Intel® Edison.

What it is

Using an Intel® Edison board, this project lets you create a range finding scanner that:

  • Continuously checks the Grove* IR Distance Interrupter;
  • Moves the stepper motor in a 360-degree circle;
  • Can be accessed via the built-in web interface to view range finder data.

How it works

As the stepper motor turns, it pauses to get readings from the Grove* IR Distance Interrupter.

These readings can be seen by viewing the web page served directly from Intel® Edison.

Hardware requirements

Grove* Robotics Kit containing:

  1. Intel® Edison with an Arduino* breakout board
  2. Grove* IR Distance Interrupter
  3. Stepper Motor Controller & Stepper Motor

Software requirements

  1. Intel® XDK IoT Edition
  2. Microsoft* Azure* account

How to set up

To begin, clone the How-To Intel IoT Code Samples repository with Git* on your computer as follows:

$ git clone

Want to download a .zip file? In your web browser, go to and click the Download ZIP button at the lower right. Once the .zip file is downloaded, uncompress it, and then use the files in the directory for this example.

Adding the program to Intel® XDK IoT Edition

In Intel® XDK IoT Edition, select Import Your Node.js Project:

Image 1

Then, navigate to the directory where the example project exists, and select it:

Image 2

You need to connect to your Intel® Edison board from your computer to send code to it.

Image 3

Click the IoT Device menu at the bottom left. If your Intel® Edison is automatically recognized, select it.

Image 4

Otherwise, select Add Manual Connection. In the Address field, type In the Port field, type 58888. Click Connect to save your connection.

Installing the program manually on Intel® Edison

Alternatively, you can set up the code manually on the Intel® Edison board.

Clone the How-To Intel IoT Code Samples repository to your Intel® Edison board after you establish an SSH connection to it, as follows:

$ git clone

Then, navigate to the directory with this example.

To install Git* on Intel® Edison, if you don’t have it yet, establish an SSH connection to the board and run the following command:

$ opkg install git

Connecting the Grove* sensors

Image 5

You need to have a Grove* Shield connected to an Arduino*-compatible breakout board to plug all the Grove* devices into the Grove* Shield. Make sure you have the tiny VCC switch on the Grove* Shield set to 5V.

You need to power Intel® Edison with the external power adaptor that comes with your starter kit, or substitute it with an external 12V 1.5A power supply. You can also use an external battery, such as a 5V USB battery.

In addition, you need a breadboard and an extra 5V power supply to provide power to the motor. Note: you need a separate battery or power supply for the motor. You cannot use the same power supply for both the Intel® Edison board and the motor, so you need either 2 batteries or 2 power supplies in total.

  1. Plug the stepper motor controller into pins 9, 10, 11, and 12 on the Arduino* breakout board for it to be able to be controlled. Connect the controller to ground (GND), to the 5V power coming from the Arduino* breakout board (VCC), and to the separate 5V power for the motor (VM).

  2. Plug one end of a Grove* cable into the Grove* IR Distance Interrupter, and connect the other end to the D2 port on the Grove* Shield.

Manual Intel® Edison setup

If you're running this code on your Intel® Edison manually, you need to install some dependencies.

To obtain the Node.js* modules needed for this example to execute on Intel® Edison, run the following command:

npm install

Microsoft* Azure* server setup

Optionally, you can store the data generated by this example program in a backend database deployed using Microsoft* Azure*, Node.js*, and a Redis* data store.

For information on how to set up your own cloud data server, go to:

Configuring the example

To configure the example for the optional Microsoft* Azure* data store, change the SERVER and AUTH_TOKEN keys in the config.json file as follows:

  "SERVER": "",
  "AUTH_TOKEN": "s3cr3t"

Running the program using Intel® XDK IoT Edition

When you're ready to run the example, make sure you saved all the files.

Image 6

Click the Upload icon to upload the files to the Intel® Edison board.

Image 7

Click the Run icon at the bottom of Intel® XDK IoT Edition. This runs the code on Intel® Edison.

Image 8

If you made changes to the code, click Upload and Run. This runs the latest code with your changes on Intel® Edison.

Image 9

You will see output similar to the above when the program is running.

Running the program manually

To run the example manually on Intel® Edison, establish an SSH connection to the board and execute the following command:

node index.js

Viewing the range data

Image 10

The range finder data is viewed using a single-page web interface served from Intel® Edison while the sample program is running.

The web server runs on port 3000, so if Intel® Edison is connected to Wi-Fi* on, the address to browse to if you are on the same network is

Determining the Intel® Edison IP address

You can determine what IP address Intel® Edison is connected to by running the following command:

ip addr show | grep wlan

You will see the output similar to the following:

3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    inet brd scope global wlan0

The IP address is shown next to inet. In the example above, the IP address is

For a complete list of How-To Intel IoT Code Samples, go to Intel® Developer Zone.

For more details about this code sample, go to GitHub*.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
United States United States
You may know us for our processors. But we do so much more. Intel invents at the boundaries of technology to make amazing experiences possible for business and society, and for every person on Earth.

Harnessing the capability of the cloud, the ubiquity of the Internet of Things, the latest advances in memory and programmable solutions, and the promise of always-on 5G connectivity, Intel is disrupting industries and solving global challenges. Leading on policy, diversity, inclusion, education and sustainability, we create value for our stockholders, customers and society.
This is a Organisation

42 members

Comments and Discussions

-- There are no messages in this forum --