This repo contains a demo Azure IoT Edge application consisting of two python components:
- An IoT device to be run on a Raspberry Pi, which reads data from a DS18B20 sensor and sends a message towards the cloud each second.
- An IoT Edge deployment with a single module, which intercepts and prints these messages before forwarding them to the cloud.
The python code is based on Microsoft's Azure IoT Python samples.
The following steps will guide you in setting up the demo application. The setup used in the live demo looked as following:
- You'll need an azure subscription with an Azure IoT Hub and a container registry, follow this quickstart guide from Microsoft for guidance
- Install the azure cli with the iotedge extension and login using
az login - Install iotedgedev using
pip install iotedgedev(or use the VSCode extension) locally
- Either provision a VM with Ubuntu-16.04 or a Raspberry Pi with Raspbian
- Install the iot edge runtime on your Raspberry Pi or your VM
- Configure the IoT edge device with name
edge-nodeby following these steps
- Set up Certificates for the Edge Node
If you have everything set up you first need to change the container registry settings in the module.json and deployment.template.json. Simply replace inovexedgedemoacr.azurecr.io with your registry URI and adjust the credentials accordingly.
In the Docker entrypoint, replace the IP address in echo '10.100.36.59 edge-node' with the one of your edge-node. This procedure is a hotfix for us not having a FQDN for our edge-node.
You can then deploy to the edge node using the iotedgedev cli:
# Prepare environment variables for iotedgedev, skip this part when redeploying
$HUB_NAME=<your-hub-name>
echo "BUILD_BUILDNUMBER=0.0.1" >> .env
echo "IOTHUB_CONNECTION_STRING=$(az iot hub show-connection-string -n $HUB_NAME | jq '.cs')" >> .env
echo "DEVICE_CONNECTION_STRING=$(az iot hub device-identity show-connection-string -n $HUB_NAME -d edge-node | jq '.cs')" >> .env
# Build & Push Docker images and deploy
iotedgedev build -f deployment.template.json -P arm32v7 --push --deploy- Provision two Raspberry Pis with an DS18B20 sensor and Raspbian as Edge Devices
- The Pis should be able to reach the Edge Node on a static IP
- The IP address of the Edge Node needs to be added to /etc/hosts of the devices:
echo "<Edge Node ip> edge-node" >> /etc/hosts - Install the certificates from the Edge Node on the Edge devices
- Create a device identity in your IoT Hub for both:
HUB_NAME=<your-hub-name>
for iotdevice in edge-device-0 edge-device-1; do
az iot hub device-identity create -n $HUB_NAME -d $iotdevice
echo "Created $iotdevice. Connection String:"
az iot hub device-identity show-connection-string -n $HUB_NAME -d $iotdevice | jq ".cs"
doneThen refer to the device readme to setup the sensor and software.
Refer to the device readme
