VOOZH about

URL: https://thenewstack.io/tutorial-connect-and-configure-raspberry-pi-as-an-azure-iot-edge-device/

⇱ Tutorial: Connect and Configure Raspberry Pi as an Azure IoT Edge Device - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2018-09-21 10:06:36
Tutorial: Connect and Configure Raspberry Pi as an Azure IoT Edge Device
analysis,tutorial,

Tutorial: Connect and Configure Raspberry Pi as an Azure IoT Edge Device

Sep 21st, 2018 10:06am by Janakiram MSV
👁 Featued image for: Tutorial: Connect and Configure Raspberry Pi as an Azure IoT Edge Device

Azure IoT Edge is an edge computing platform from Microsoft. It is an extension of Azure IoT that can run on local devices in offline mode.

In the last part of this series, I introduced the technical architecture of Azure IoT Edge. In this tutorial, we will explore how to connect and configure Raspberry Pi as an edge device that talks to Azure IoT.

We will control an LED matrix that comes with a Raspberry Pi accessory known as Sense Hat. The idea is to change the color of the LED matrix remotely by pushing different versions of modules packaged as Docker containers.

There are three broad steps involved in this tutorial:

  1. Creating cloud resources in Azure IoT
  2. Configuring and connecting Raspberry Pi to Azure IoT
  3. Deploying modules to the edge devices

We will use the CLI for the most parts of the tutorial while switching to Azure Portal for configuring and deploying modules.

Let’s get started!

Prerequisites

Step 1 – Configuring Azure IoT

On your development machine (Mac or Windows), start by configuring the Azure IoT CLI. This tool makes it easy to work with Azure IoT Hub.

$ az extension add --name azure-cli-iot-ext

We will then create a resource group that acts as a logical boundary for all the resources that we create for this project.

$ az group create --name TNSIoT --location westus

Let’s create an IoT Hub which is the gateway to Azure IoT. This service handles device management, security, and communication among the connected devices.

$ az iot hub create --resource-group TNSIoT --name TNSIoTHub --sku S1

Once we have an IoT Hub in place, we can start connecting devices. But before that we need to create an identity for the device which will provide the credentials to authenticate with IoT Hub.

Since we are configuring an edge device, we will go ahead and add –edge-enabled flag. It’s important to understand that edge devices are not different from other devices except that they enjoy additional capabilities.

The below command creates an identity for Raspberry Pi with a device id Pi1. The output will contain a device-specific connection string that we need to save. Keep the connection string safe and secure. It is required in the next step.

$ az iot hub device-identity create --hub-name TNSIoTHub --device-id Pi1 --edge-enabled

We are done with the first part where a logical device identity is created in the cloud. We will now associate an actual Raspberry Pi device with this identity.

Step 2 – Configure Raspberry Pi

Assuming you have a Raspberry Pi running the latest Raspbian OS connected to the same network as your development machine, SSH into it.

Since Azure IoT Edge modules are run as containers, we need to have Docker installed the edge device. In this case, we are setting up Moby, an open source toolchain that powers Docker Engine.

$ curl -L https://aka.ms/moby-engine-armhf-latest -o moby_engine.deb && sudo dpkg -i ./moby_engine.deb

$ curl -L https://aka.ms/moby-cli-armhf-latest -o moby_cli.deb && sudo dpkg -i ./moby_cli.deb

$ sudo apt-get install -f

Make sure Moby and the CLI are properly installed before going ahead with the next steps.

$ sudo docker version

👁 Image

The second component that we need to install on Raspberry Pi is Azure IoT Edge runtime, which runs as a background daemon.

Run the below commands to install it.

$ curl -L https://aka.ms/libiothsm-std-linux-armhf-latest -o libiothsm-std.deb && sudo dpkg -i ./libiothsm-std.deb 

$ curl -L https://aka.ms/iotedged-linux-armhf-latest -o iotedge.deb && sudo dpkg -i ./iotedge.deb 

$sudo apt-get install -f

With the runtime in place, we are all set to connect the device to Azure IoT Hub. This is done by adding the device connection string that we acquired in step 1 to the configuration file.

Open /etc/iotedge/config.yaml in an editor of your choice and replace “<ADD DEVICE CONNECTION STRING HERE>” with the actual connection string.

👁 Image

Since the configuration is changed, let’s restart the runtime, and verify the status.

$ sudo systemctl restart iotedge

$ sudo systemctl status iotedge

The output should be similar to the below screenshot:

👁 Image

You may want to explore the service further with the below command.

$ sudo journalctl -u iotedge --no-pager --no-full

We have successfully connected Raspberry Pi to Azure IoT and configured it as an edge device. We are now ready to deploy the module that can control the LED matrix.

Step 3: Deploying Modules

 Open your favorite browser and navigate to Azure Portal. Access the IoT Hub we created in the first step, and click on IoT Edge under Automation Device Management section.

👁 Image

Under IoT Edge Devices section, you should see PI1 device. Click on that to set the modules.

👁 Image

Choose IoT Edge Module from the list to deploy a custom module.

👁 Image

We will now use the portal to push a container image as a module to the edge device. You can use the prebuilt images that I have already pushed to Docker Hub.

The image, janakiramm/matrix:v1, is built to turn all the LEDs of Sense Hat to blue while janakiramm/matrix:v2 is configured to turn the matrix to green.

Let’s first push the first version to turn the matrix to blue.

Under the IoT Edge Custom Modules section, give the name of the module as Matrix and janakiramm/matrix:v1 for Image URI. Since we access the local I2C bus on Raspberry Pi, we need to run the container in privileged mode. Paste the following JSON string under Container Create Options.

{

  "HostConfig": {

    "Privileged": true

  }

}

👁 Image

Click on the Save button and complete all the steps by accepting the defaults.

This will trigger custom module deployment on the edge device. After a while, the modules section should look like the below screenshot.

👁 Image

You can also verify that the module is deployed to the device by running iotedge CLI on Raspberry Pi.

$ sudo iotedge list

👁 Image

If everything went well, you should see the Sense Hat LED matrix turning blue.

👁 Image

Now, let’s go ahead and update the deployment to run the version 2 of the module. Click on Matrix module to access its properties. Change the Image URI to janakiramm/matrix:v2.

Click on the Save button and complete all the steps by accepting the defaults.

👁 Image

Within a few seconds, the LED matrix turns green indicating that the module has been updated to the latest version.

👁 Image

Running iotedge CLI on the device will confirm the same.

$ sudo iotedge list

👁 Image

Though changing the color of the LEDs can be achieved without actually pushing a new container, the idea of the tutorial is to highlight the concept of custom modules and managing the deployments.

In the last and final part of this series, I will walk you through the steps involved in configuring Kubernetes to orchestrate Azure IoT Edge modules. We will do a blue/green deployment of modules through kubectl, the CLI of Kubernetes.

TRENDING STORIES
Janakiram MSV (Jani) is a practicing architect, research analyst, and advisor to Silicon Valley startups. He focuses on the convergence of modern infrastructure powered by cloud-native technology and machine intelligence driven by generative AI. Before becoming an entrepreneur, he spent...
Read more from Janakiram MSV
SHARE THIS STORY
TRENDING STORIES
Microsoft is a sponsor of The New Stack.
TNS owner Insight Partners is an investor in: Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.