
Hi !
So, as a final post, here are some notes related to the Container Create option and also how to send telemetry from the device.
Container Create Option
This is the Container Create Option configuration that I define for the module. This specific configuration allows the access to the i2c components (raspberry pi pins) and also opens a port 8066 that will be used in the module when it’s exposed as a webserver.
# Container Create Options
{
"HostConfig": {
"Binds": [
"/dev/i2c-1:/dev/i2c-1"
],
"Privileged": true,
"ExposedPorts": {
"8066/tcp": {}
},
"PortBindings": {
"8066/tcp": [
{
"HostPort": "8066"
}
]
}
}
}
Sending Telemetry
Most of the code samples I founded online on how to send telemetry / messages are for IoT apps, not for Custom IoT Edge modules. So here is the lines you need to send a message / telemetry from the custom iot edge module.
In this sample, the message uses 3 properties action, door state and door state description. And the message create a JSON message with this properties and also add them as custom properties in the sent message.
To have more details on the class modules and properties, I checked
Docker Image build
This is the docker file for the raspberry pi
FROM arm32v7/python:3.7-slim-buster
WORKDIR /app
# custom installation for RPI Grove dependencies defined in requirements.txt
RUN apt-get update
RUN apt-get install -y gcc
COPY requirements.txt ./
RUN pip install -r requirements.txt
# Code added to support web app in the Azure IoT Module
RUN pip install flask pillow --index-url 'https://www.piwheels.org/simple'
# Expose the port
EXPOSE 8066
COPY . .
CMD [ "python3", "-u", "./main.py" ]
My requirement file is super simple
azure-iot-device~=2.7.0
RPi.GPIO
grove.py
seeed-python-dht
And I think this covers the most specific setups for this one !
References
- Seeedstudio, Grove
- Create an IoT hub using the Azure portal
- Tutorial: Develop and deploy a Python IoT Edge module for Linux devices
- Azure Container Registry
Happy coding!
Greetings
El Bruno
More posts in my blog ElBruno.com.
More info in https://beacons.ai/elbruno
Azure ☁ IoT
- Install ☁ Azure IoT on Raspberry Pi
- Deploy ☁ Azure Blob Storage on IoT Edge, lessons learned
- Connect to ☁ Azure Blob Storage on IoT Edge using Microsoft Azure Storage Explorer
- Lesson learned and tips on how to install Azure IoT Edge on Ubuntu on a Raspberry Pi
- Azure IoT Explorer, in preview and awesome
- Mapping a local ☁ Azure IoT Edge folder module with an Edge device folder 📁
- Creating a folder 📂 in the docker definition in an ☁ Azure IoT Edge
- Granting access to Raspberry Pi GPIO from an ☁ Azure IoT Edge Module
Create an Azure IoT Module using Raspberry Pi and Grove Sensors
- Raspberry Pi + Grove Sensors, read temperature and humidity values
- Raspberry Pi + Grove Sensors, send temperature and humidity values as telemetry to Azure IoT Hub
- Raspberry Pi + Grove Sensors, create a Azure IoT Module to send temperature and humidity values as telemetry to Azure IoT Hub
- Raspberry Pi + Grove Sensors, publish and use the Azure IoT Module
- Raspberry Pi + Grove Sensors, notes on build and configuration
- Raspberry Pi + Grove Sensors, details on how to send a telemetry message and sample messages
Create an Azure IoT Module from Azure Custom Vision project
- Create and export a Custom Vision Project as Docker image
- Analyze the content of the CV Docker image
- Create and analyze an Azure IoT Module
- Merge the CV project as an Azure IoT Module
- Deploy to an Azure IoT device and test the CV module
- Send telemetry for each analyzed image
- Add digital twin configuration to the Azure IoT module (coming soon)
¿Con ganas de ponerte al día?
En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:
- Si tienes ganas de ponerte al día con Front End (ES6, Typescript, React, Angular, Vuejs…) te recomendamos nuestros Máster Front End: https://lemoncode.net/master-frontend#inicio-banner
- Si te quieres poner al día en Backend (stacks .net y nodejs), te aconsejamos nuestro Bootcamp Backend: https://lemoncode.net/bootcamp-backend#bootcamp-backend/banner
- Y si tienes ganas de meterte con Docker, Kubernetes, CI/CD…, tenemos nuestro Bootcamp Devops: https://lemoncode.net/bootcamp-devops#bootcamp-devops/inicio