Connecting Things to Internet (Part 4) – Configuring and Connecting a Gateway Device to IoT Hub

This is the fourth installment of 5 part series Connecting Things to Internet – a step-by-step guide on how to get things connected to the Internet using low cost devices. In this fourth article, I will focus on getting Windows Azure IoT SDK installed on on your gateway device, The Rasbberry Pi 2, and configure the device in IoT hub that was create in the second article. As mentioned in the earlier article, I will be using Node implementation of Azure IoT SDK in this series.

Installing Azure IoT Node SDK

It is assumed that you already have Node(0.12.x or later) and serialport package installed in your RPi. If not done so, please refer to the previous article and have the gateway device ready before proceeding with the steps in this article. There are 2 ways of installing Azure IoT in your RPi.

Option 1: Installing IoT suite by compiling the source code.


  • Connect to your RPi using Bitvise SSH Client and clone the project to your working directory



  • Now you should have the project cloned in your working directory


  • Navigate to the node folder in your local copy of this repository (azure-iot-sdks). Run the build/ script to prepare your development environment. it will take a while to complete the build. so, please be patient.


  • Then run the build/ script to verify your installation. if the build is completed successfully you should not see any errors.



Option 2: Installing IoT suite by using npm

  • Go to your working directory and execute the following commands in the given order


Configuring Remote Device

After installing Windows IoT Azure SDK on your RPi, the next step of the process is to configure the device that you added in the  second article. Follow the steps to have the device configured in the IoT hub.

  • Copy the following javascript code in to your text editor and save the file, configure-device.js, in the working directory of your RPi. make sure that you replace IoT hub name, device id and the device key in the code with the values recorded from the device creation step. you may add dummy metadata from line 28 to 40. however, make sure to have a valid DeviceID at line 27.
  • Execute the following command
  • Log in to the IoT hub, select the newly added device and verify the device metadata defined in the above code.

This concludes the fourth article in the series. In the fifth and last article, I will explain how to send the sensor data captured from Arduino to the Iot Hub.

One thought on “Connecting Things to Internet (Part 4) – Configuring and Connecting a Gateway Device to IoT Hub

Leave a Comment