Set up Microsoft Azure* IoT Edge on an UP Squared* Board

By Nhuy N Le,

Published:09/20/2018   Last Updated:09/20/2018

Introduction

This article demonstrates how to set up Microsoft Azure* IoT Edge on a UP Squared* board running the Ubuntu* desktop operating system. It deploys a temperature sensor module to the Up Squared device and sends telemetry data to Microsoft Azure* IoT Hub. Azure IoT Hub is the cloud gateway that manages IoT Edge devices. IoT Edge provides cloud intelligence locally by deploying and running Azure services, Artificial intelligence (AI) and custom logic on IoT devices so that the data can be analyzed on devices instead of in the cloud. IoT Edge device connects IoT devices with the cloud, and controls the data flow between them.

The UP Squared board is a low-power and high performance platform ideal for IoT applications. The UP Squared board is based on either the Intel® Celeron® processor (N3350) or Pentium® processor (N4200). For more information, visit the UP Squared home page.

Figure 1: Azure IoT Edge on UP Squared

Hardware Requirements

The hardware components used in this project are listed below:

Software Requirements

The software used in this project are listed below:
  • For the UP Squared* board, an Ubuntu 16.04.4 Desktop image comes pre-installed. 
  • A Microsoft Azure account is required for this project. Go to Microsoft Azure to create a free account if you don’t have one.

Create Microsoft Azure* IoT Hub

To create a Microsoft Azure IoT Hub, from the Azure Portal navigate to All services on the left panel, click on IoT Hub, and then select Add. Fill out all the fields and click on Review + Create.

Figure 2: IoT Hub basics

Move to the Size and Scale tab of the IoT Hub Microsoft window and select F1: Free tier for Pricing and scale tier. Select Review + Create, then click on Create to create a new Microsoft Azure Hub. For more information, follow the create IoT hub through portal instructions. 

Figure 3: IoT Hub size and scale

After the IoT Hub is successfully created, navigate to All services on the left panel, click on IoT Hub. It will display the newly created IoT Hub.

Figure 4: IoT Hub list

Create Microsoft Azure* IoT Edge Device

There are three components in the IoT Edge device: IoT Edge modules, IoT Edge runtime and a cloud based interface that monitors and manages IoT Edge devices remotely. IoT Edge modules are containers and each module performs an action. The IoT Edge runtime connects the IoT Edge device to the cloud and sends data up to Azure. For detailed information, please refer to What is Azure IoT Edge.
Select the IoT Hub on Figure 4: IoT Hub list above, then click on IoT Edge. Next, select Add IoT Edge Device. Fill out Device ID, mark Auto Generate Keys to generate primary and secondary keys automatically for the device to connect securely to the IoT Edge later, and then click on Save button.

Figure 5: Add IoT Edge device

Once the IoT Edge device is created successfully, it will display as follows:

Figure 6: IoT Edge device list

To view the connection string of the IoT Edge device, click on the SensorDevice. Take a note of the Connection string (primary key). The device will need it to connect to the IoT Edge Hub.
 

Figure 7: Connection string of the IoT Edge device

Install Microsoft Azure* IoT Edge Runtime on UP Squared* Board

The Azure IoT Edge runtime will provide security and management for the UP Squared IoT Edge device.

1. Register Microsoft Key and Software Repository Feed

Visit how to install IoT edge Linux for detailed information.

# Install repository configuration
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > ./microsoft-prod.list
sudo cp ./microsoft-prod.list /etc/apt/sources.list.d

# Install Microsoft GPG public key to access the repository
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d

2. Install the Container Runtime

Moby is an open source container management system, which will handle the device management and security in this example.

sudo apt-get update

# Install Moby engine
sudo apt-get install moby-engine

# Install the Moby CLI commands. CLI is useful for development but it’s optional in this article
sudo apt-get install moby-cli

3. Install the Microsoft Azure* IoT Edge Security Daemon

Install the IoT Edge security daemon so that the IoT Edge runtime starts every time the device boots.
sudo apt-get update
sudo apt-get install iotedge

4. Configure the Microsoft Azure* IoT Edge Security

Update the IoT Edge configuration to add the IoT Edge device.
sudo chmod +w /etc/iotedge/config.yaml
sudo vi /etc/iotedge/config.yaml

Update the device_connection_string with the connection string (primary key) from Figure 7: Connection string of the IoT Edge device.

  source: "manual"
  device_connection_string: "<ADD DEVICE CONNECTION STRING from Figure 7: Connection string of the IoT Edge device HERE>"

# provisioning: 
#   source: "dps"
#   global_endpoint: "https://global.azure-devices-provisioning.net"
#   scope_id: "{scope_id}"
provisioning:
#   registration_id: "{registration_id}"

Restart the IoT Edge daemon:

sudo systemctl restart iotedge

5. Verify Successful Installation

Check the status of the IoT Edge daemon and list the running modules:
systemctl status iotedge
sudo iotedge list

Microsoft Azure* IoT Edge Hub Runtime Status

Now refresh the IoT Edge Hub connections. The $edgeAgent should be running.

Figure 8: IoT Edge Hub connections

Deploy Sensor Module

Go to the Azure Portal, then navigate to All services on the left panel, click on IoT Hub, and then select your SensorsIoTEdgeHub, IoTEdge, IoT Edge Devices, then your SensorDevice.

Figure 9: UP Squared as an IoT Edge device

Select Set modules.

Figure 10: IoT Edge device details

Click Add in the Deployment Modules, then select IoT Edge Module.

Figure 11: Set Modules window

Fill out the IoT Edge module name and the temperature sensor URL.

mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0

Then click on the Save button.

Figure 12: IoT Edge Custom Modules window

Click Next, Next again, then Submit. Once the tempSensor IoT Edge module is successfully created, refresh the Device Details window. The tempSensor IoT Edge module should be running.

Figure 13: IoT Edge Modules

Type the following command on the UP Squared terminal to view generated sensor data:

sudo iotedge logs tempSensor -f

Delete Microsoft Azure* Resources on UP Squared* Board

Follow these steps below to delete Azure resources if they are no longer needed. Visit this site for more information.

# Remove existing Docker
sudo apt-get purge docker lxc-docker docker-engine docker.io

# Install required packages
sudo apt-get install  curl  apt-transport-https ca-certificates software-properties-common

# Add Docker apt key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add

# Set up the stable repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

#Install Docker package
sudo apt-get update
sudo apt-get install docker-ce

# Docker status
sudo systemctl status docker

# Delete Dockers runtime
sudo docker rm –f tempSensor
sudo docker rm –f edgeAgent
sudo docker rm –f edgeHub

# Delete IoT Edge runtime
sudo apt-get remove --purge iotedge

Summary

We have described how a Microsoft Azure IoT Edge deployment works. This includes how to create an Azure IoT Hub, how to set up the UP Squared device as an IoT Edge device, as well as how to deploy a temperature sensor module to the UP Squared device that sends telemetry data to Azure IoT Hub. You can also expand your project by deploying a Custom Vision module to the UP Squared.

Key References

UP Squared* board

About the Author

Nancy Le is a software engineer at Intel Corporation in the Core & Visual Computing Group working on Intel Atom® processor enabling for Intel® IoT projects.
 
 

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804