Zum Hauptinhalt springen

Tutorial: Setting Up Azure IoT Edge Runtime on RevPi Devices

Introduction

This tutorial describes how to use Microsoft IoT Edge to connect a Revolution Pi (RevPi) device to Azure IoT Hub. The process involves configuring Azure IoT Hub, registering your IoT device, and setting up the IoT Edge runtime on your RevPi.

Prerequisites

  1. A valid Azure account
  2. RevPi device (at least 8 GB storage)
  3. PC with internet access
  4. Basic familiarity with Linux command line
  5. SSH access to your RevPi

Requirements

Hardware:

  • RevPi device with minimum 8 GB storage
  • Power supply
  • Network connection
  • PC with internet access

Software:

  • Latest version of Raspberry Pi OS
  • At least 600 MB of available memory
  • SSH client (e.g., PuTTY)

Preparation

  1. Create an Azure account at azure.microsoft.com/free
  2. Log in to the Azure Portal
  3. Set up SSH access to your RevPi device
  4. Update your RevPi to the latest version of Raspberry Pi OS
  5. Ensure you have 600 MB of free memory available

Step 1: Setting up Azure

Creating the IoT Hub

▷ Log in to the Azure Portal at portal.azure.com

▷ Click on "Create a resource" and search for "IoT Hub"

▷ Click "Create"

▷ Select your subscription and resource group or create a new one

▷ Choose the region closest to you (note: not all Azure services are available in all regions)

▷ Select the pricing tier that matches your needs under "Management"

▷ Click "Review + Create"

▷ Click "Create" to deploy your IoT Hub

Creating the Edge Device

▷ Navigate to your newly created IoT Hub

▷ Select "IoT Edge" under "Device management" in the sidebar

▷ Click "Add IoT Edge Device"

▷ Enter a Device ID for your RevPi

▷ Accept the default settings

▷ Click "Save"

▷ Click "Refresh"

▷ Select your newly created device

▷ Copy the "Primary Connection String" - you'll need this later

Step 2: Setting up the RevPi Device

Installing Required Packages

First, add the Microsoft package repository and GPG key:

curl https://packages.microsoft.com/config/debian/stretch/multiarch/packages-microsoft-prod.deb > ./packages-microsoft-prod.deb
sudo apt install ./packages-microsoft-prod.deb

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/

sudo apt-get update

Installing IoT Edge Runtime

Install the Moby container engine and IoT Edge:

sudo apt-get install moby-engine -y
sudo apt-get install iotedge -y

Configuring IoT Edge

▷ Open the configuration file:

sudo nano /etc/iotedge/config.yaml

▷ Find the "Manual provisioning configuration" section and update the device_connection_string with your Primary Connection String:

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

Starting and Verifying IoT Edge

▷ Restart the IoT Edge service:

sudo systemctl restart iotedge

▷ Check the status:

sudo systemctl status iotedge
sudo iotedge check

▷ Run "iotedge check" twice - it's normal to see one remaining error about "Production readiness: Edge hub's storage directory"

Troubleshooting

If you encounter issues:

  • Check the RevPi forum at revolutionpi.de/forum/
  • Review Azure IoT Edge logs: journalctl -u iotedge
  • Verify network connectivity
  • Ensure all required ports are open
  • Check system resources

Further Information