Skip to content

chrismckelt/edgy

Repository files navigation

Edgy - an Azure IOT Edge Demo

This repo contains an Azure IoT Edge solution that will deploy the below modules to an IOT Edge device

A walkthrough series on how this was setup is available here:

https://dev.to/chris_mckelt/azure-iot-edge-who-is-cooler-dotnet-node-or-python-369m

Setup instructions

https://github.com/chrismckelt/edgy/wiki

Demo Goal

This solution demonstrates an air-conditioning monitoring system where 3 room sensors are publishing their temperature over time.   When a room gets too hot the air conditioner for that room is turned on. Once the room is cooled it is turned off.

Three ‘data generator’ modules publish a message with the following properties.

  • Timestamp 
  • Temperature –   room temp in Celsius
  • IsAirConditionerOn – true/false
  • TagKey – room name (in this case  dotnet, node, python)

Three ‘data recorder’ modules subscribe to the published temperature messages and save the data in a time series database.

A custom module will listen to all temperature messages and analyse when a room is too hot. Sending a message to turn the rooms air conditioner on.

Demo Focus Areas

  1. show local debug/development options &  remote/real deployment
  2. how to create and configure an Azure IOT Hub environment in Azure using Azure CLI scripts
  3. coding custom modules in .Net, Python, NodeJS (sorry Java)
  4. using existing Azure IoT Edge marketplace modules
  5. using non-edge marketplace modules (docker images) to save data with Timescale
  6. connecting a data flow engine ( Apache Nifi) to the Edge MQTT Broker
  7. viewing the data through a Grafana dashboard.

Getting started

In order to develop solutions for the edge:

  1. Read Developing custom modules
  2. Setup your machine using the Azure IoT EdgeHub Dev Tool
  3. I recommend installing these VS code extensions
  4. I recommend using Portainer for docker management both locally & on the deployed edge solution
Portainer running on http://localhost:9000/


Solution Overview

Azure Setup

Scripts found here will create out the below environment in a given resource group.

Modules

The code contains the docker build files , code & scripts to create the following modules

Code

Descriptions of folders and files

Folder /  File Description
config automatically generate files from the deployment.templates.json (debug or prod) that are used to deploy the solution
modules custom code, docker images for your IOT Edge solution
scripts code to create the environment, build the code/docker images and deploy the solution
tools certificate generator and other tools for solution support
.env holds environment variables that populate the generated config files from the templates
deployment.debug.template.json   creates a file in the /config folder called 'deployment.debug.json' that populates environment variables, used for local development
deployment.prod.template.json creates a file in the /config folder called 'deployment.prod.json' that populates environment variables, used for production like deployment

Solution Structure Overview

Azure IOT Edge Devices

The solution used 3 devices which will be setup in a future post.

1. Local Simulator

A simulated local environment using the Azure IoT Edge Hub Development simulator to run against the IOT Hub.   When developing for the edge it is recommended not to install the real ‘IOT edge runtime’ on your machine but instead use the simulator.

2. Local Device

Linux Ubuntu machine hosted in VMWare on my local machine using Hyper V

https://docs.microsoft.com/bs-latn-ba/Azure/iot-edge/how-to-install-iot-edge-linux

3. Cloud Device

Linux Ubuntu hosted on Azure in our resource group created using this script

This uses the pre-existing Linux Ubuntu image from the Azure Marketplace  with the runtime installed.

Once up and running VS Code will show the devices below.