-
1Tutorial
Steps to reproduce:
To begin, you will need a Microsoft Azure subscription with a deployed IoT Hub. You can deploy an IoT Hub to an existing subscription by following this guide.
Next, we you will want to begin configuration of your hardware by connecting an LED to GPIO18 of the Raspberry Pi. Instructions for this process can be found here.
With circuitry and cloud services prepared, you will want to install the Azure IoT Edge runtime to your Raspberry Pi by following this guide. Once the runtime is installed, you will need to manually provision the device by following these instructions.
Next we will create a special deployment within Azure that will allow us to blink our LED.
Create a deployment as shown below:
The image URI:
toolboc/johnny5onedge:0.0.981-arm32v7
The container create options:
{"ExposedPorts":{"9229/tcp":{}},"HostConfig":{"PortBindings":{"9229/tcp":[{"HostPort":"9229"}]},"Privileged":true,"Devices":[{"PathOnHost":"/dev/i2c-1","PathInContainer":"/dev/i2c-1","CgroupPermissions":"rwm"},{"PathOnHost":"/dev/gpiomem","PathInContainer":"/dev/gpiomem","CgroupPermissions":"rwm"}],"Mounts":[{"Type":"bind","Source":"/lib/modules/","Target":"/lib/modules/"}]}}
The Module twin's desired properties:
{ "properties.desired": { "config": "{\"peripherals\":[{\"type\":\"Led\",\"name\":\"alarm\",\"settings\":{\"pin\":\"GPIO18\"},\"initialState\": {\"method\":\"blink\",\"period\":500},\"outputAlias\":\"alias2\"},{\"type\":\"Button\",\"name\":\"on\",\"settings\":{\"pin\":\"GPIO20\"},\"outputAlias\":\"alias1\"}]}" } }
Save when you are finished. Then skip through the "Specify Routes" and "Specify Metrics" sections until you get to "Target Devices".
Set the Priority to 10 and add a target condition of tags.environment='blink'
Submit the deployment and locate the device that was provisioned then select the "Device Twin":
Add the following above properties as shown:
"tags": { "environment": "blink" },
Head back to the pi and execute the following commands in the terminal:
sudo systemctl stop iotedge sudo iotedged -c /etc/iotedge/config.yaml
After a few minutes, the deployment should be applied and the containers will get pulled down to the device and begin running. If you did everything correctly, you should see the LED begin to blink!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.