Develop An Azure IoT Edge module In ThingsPro Edge
IoT Edge Module (Azure Documents)
IoT Edge Module Example
- Here is an example for you to refer to develop a IoT Edge module to complete the requirements:
- Obtain and modify device properties by module twin.
- Upload ThingsPro tags data by D2C message.
- Update tag value by direct command.
- soure code
Preparation Before Use The Example Module
- modbus tcp device setup
Here I setup modbus tcp master to get the switch value of the meter.
- Azure IoT Edge setup
Set up and make sure ThingsPro's Azure IoT Edge service is connected successfully.
- Setup the example module on your IoT Edge device
module name: test
image URL:moxa2019/thingspro-sample:0.0.3-amd64
container create options:{
"HostConfig": {
"Binds": [
"/var/thingspro/data/:/var/thingspro/data/"
]
}
} - After IoT Edge deployment is complete, you can see the test module on the ThingsPro's Azure IoT Edge service page
How To Use The Example Module
- Obtain and modify device properties by module twin.
The example module supports modifying the configuration of device description.
Fill in the desired properties and click save in the IoT Edge's module twin page.
On the ThingsPro webpage, you can see that the property has been modified.
- Upload ThingsPro's tags data by D2C message.
The example module supports modifying the configuration of ThingsPro tags upload.
Fill in the desired properties and click save in the IoT Edge's module twin page.{
"uploadTags": [
{
"providerName": "modbus_tcp_master",
"moduleName": "mydevice",
"tagName": "power"
}
],
"uploadInterval": 5
}The message has been sent to the Azure IoTHub.
Here I use the Azure IoTHub plugin on vscode to monitor D2C message.
- Update ThingsPro's tag value by direct command.
Commands supported by the example module:
command name:tagWrite
command payload:{
"providerName": "modbus_tcp_master",
"moduleName": "mydevice",
"tagName": "power_w",
"dataType": "boolean",
"dataValue": true
}Invoke module command in IoT Edge device's direct command page.
You can monitor that the value of power is updated to
true
.
Last updated on 2022-05-31 by Aeluin Chen (陳映攸)