loading...
Cover image for Setup Azure IOT Edge Runtime on the Raspberry Pi - Minified - 1

Setup Azure IOT Edge Runtime on the Raspberry Pi - Minified - 1

rohansawant profile image Rohan Sawant ・3 min read

The official documentation is very verbose and wordy, which is exactly how it should be, but this tutorial tries a more brief approach towards installing the IOT Runtime on the Raspberry Pi

Prerequisites

  • You are fairly comfortable with Cloud Service providers, AWS, Azure or GCP.
  • You have worked with the Raspberry Pi and SSH before

You will learn

  1. How to setup Azure IOT Edge using the Portal
  2. How to get a Raspberry Pi communicating with Azure

Key Concepts

Here are some of these explained in laymen's terms

Azure IOT Hub

  • Managed service to enable bi-directional communication between IoT devices and Azure

  • Azure IoT Hub provides a cloud-hosted solution backend to connect virtually any device.

Read More

Azure IOT Edge Device

  • Logical representation, or the identity which the IOT Hub assigns every physical hardware device connected to it.

Azure IOT Runtime

  • Enables custom and cloud logic on IoT Edge devices. The runtime sits on the IoT Edge device, and performs management and communication operations.

Read More

1. Setting up Azure

Creating the Hub

  1. Login to the Azure Portal
  2. Search for 'IOT Hub'
  3. Click Add, under Size and Scale select Free Tier, accept the defaults and create an IOT Hub

Creating the Edge Device

  1. Go to the IOT Hub you just created
  2. From the side panel under Automatic Device Management, click IoT Edge, then click New
  3. Add a device name, accept the defaults and click Save
  4. Refresh, click the Device you just created, unhide and copy the Primary Connection String, keep this handy for later.

References - Quickstart: Deploy your first IoT Edge module to a virtual Linux device

2. Setting up the Raspberry Pi

Prerequisites

  1. Ensure that the Raspberry Pi (RPi) is running Raspbian Stretch
  2. Ensure that Docker and Docker Compose are installed. Read More - Installing Docker and Docker Compose on the Raspberry Pi in 5 Simple Steps

Installing Azure IOT Edge Runtime

1) Registering Microsoft key and software repository feed

   curl https://packages.microsoft.com/config/debian/stretch/multiarch/prod.list > ./microsoft-prod.list
   sudo cp ./microsoft-prod.list /etc/apt/sources.list.d/
   curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
   sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d/

2) Installing Moby-Engine, and IOTEdge Runtime

   sudo apt-get update -y
   sudo apt-get install libssl1.0.2 moby-engine moby-cli iotedge -y

3) Let's add the connection string to connect the RPi with Azure

   sudo nano /etc/iotedge/config.yaml

Add the Primary Connection String from Step 1.2 in here, and it should look something like this.

   # Manual provisioning configuration
   provisioning:
     source: "manual"
     device_connection_string: "HostName=XXX.azure-devices.net;DeviceId=rpi-1;SharedAccessKey=XXXXc="

4) Setup is done, restart the service.

   sudo systemctl restart iotedge

5) Verify the installation.

   sudo systemctl status iotedge
   sudo iotedge check # should return 1 check as failed 'Edge Hub can bind to ports on host'
   sudo iotedge list # No modules are running

References - Install the Azure IoT Edge runtime on Debian-based Linux systems

In the next tutorial, we will Deploy a Module to Azure IOT Edge Runtime on Linux

Note

I know It's frustrating when something works in the tutorial but not when you do it, I would hate if that happened to you. So, please leave a comment, or reach out to me. If any of this does not work for you.

Discussion

pic
Editor guide