Skip to main content
Version: 2.2.0

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:
    1. Obtain and modify device properties by module twin.
    2. Upload ThingsPro tags data by D2C message.
    3. 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. img

  • Azure IoT Edge setup

    Set up and make sure ThingsPro's Azure IoT Edge service is connected successfully. img

  • 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

    img

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.
    img

    On the ThingsPro webpage, you can see that the property has been modified. img

  • 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
    }

    img

    The message has been sent to the Azure IoTHub.
    Here I use the Azure IoTHub plugin on vscode to monitor D2C message.
    img

  • 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. img You can monitor that the value of power is updated to true. img

Last updated on 2022-05-31 by Aeluin Chen (陳映攸)