Create a custom module after Install and Settings of Azure IoT Edge.
It's the very first, so I'll give it a try. (It feels like a waste of technology than Mr. T's FPGA + IoT Edge with L Chika) However, there are traps just by L-Chika. I'll explain in detail later, but the problem is that IoT Edge is running in a container.
See also the official documentation (https://docs.microsoft.com/ja-jp/azure/iot-edge/tutorial-python-module?view=iotedge-2018-06).
・ IoT Hub ・ RaspberryPi (ARM32v7 or higher model) IoT Edge installed ・ Container registry ・ Docker ・ VS Code · Python extension for VS Code · Azure IoT Tools for VS Code ・ Python (3.7)
Connect the LED and resistor to the Raspberry Pi.
Select the folder where you want to save the solution files.
Enter the solution name.
Select the Python module.
Enter the module name.
Enter the repository information. It will be [registry name] .azurecr.io/module name.
Open the .env file in the project and check that the user name and password are set. If not set, copy the username and password from the container registry access key.
Click the target platform at the bottom of the screen and change the platform to "ARM32v7".
Make sure that the language used at the bottom of the screen is Python 3.7. If it is different, select it again on the command palette.
Open main.py and change it to the following:
main.py
import time
import RPi.GPIO as gpio
gpio.setmode(gpio.BCM)
gpio.setup(26,gpio.OUT)
try:
while True:
gpio.output(26,1)
time.sleep(.5)
gpio.output(26,0)
time.sleep(.5)
except KeyboardInterrupt:
gpio.cleanup()
Dockerfile.arm32v7
FROM arm32v7/python:3.7-slim-buster
WORKDIR /app
RUN apt update && apt install -y \
build-essential
COPY requirements.txt ./
RUN pip install -r requirements.txt
RUN pip install RPi.GPIO
COPY . .
CMD [ "python3", "-u", "./main.py" ]
deployment.template.json
~ Omitted ~
"createOptions": {
"NetworkingConfig": {
"EndpointsConfig": {
"host": {}
}
},
"HostCOnfig": {
"NetworkMode": "host",
"Privileged": true
}
}
~ Omitted ~
Right-click deployment.template.json and click Build and Push IoT Edge Solution. If there is no problem, the built solution file will be registered in the container registry.
Expand Devices from the Auzre IoT Hub section, right-click the device you want to deploy and click "Place in One IoT Edge".
Open the config folder and select "deployment.arm32v7.json".
If there is no problem, the LED will start blinking after a while.
Try changing the numbers in time.sleep on lines 14 and 18 of main.py.
Increase the value of "version" on the 7th line in module.json and save it.
If you proceed from step 15 again, the changes should be reflected on the device.
I was able to do remote deployment using IoT Edge.
What did you think.