Skip to main content

Modbus Module

Modbus is a communication protocol developed in the late 1970s for use with programmable logic controllers (PLCs). It has since become a de facto standard communication protocol in the industry, and it is now widely used for connecting industrial electronic devices.

The Modbus protocol operates using a master-slave (or client-server) architecture where the master (or client) initiates a request and the slaves (or servers) respond with the requested information or perform the requested action.

Modbus supports communication to and from multiple devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems.

In the context of Azure IoT Edge, a Modbus module is a container that you deploy to your IoT Edge device to interface with devices that communicate over Modbus protocol. The Modbus module can read data from these devices and transmit it to other modules or to the cloud for further analysis or storage. This enables you to bring data from traditional industrial systems into a modern cloud-based IoT solution.

The Modbus module communicates with other modules on the IoT Edge device through the IoT Edge hub, providing opportunities for local processing and decision making at the edge, before sending data to the cloud.

Modbus manifest

Creating a manifest for a Modbus module and configuring a template for it in Azure IoT Central involves defining the Modbus module in the manifest, setting up its Docker image and settings, and routing its messages. Then, in IoT Central, a template reflecting the Modbus module's capabilities is created and linked with the IoT Edge device. Finally, the manifest is applied to start deployment.

Step 1: Create a Modbus Module Manifest

The manifest is a JSON document that describes which modules to deploy to your IoT Edge device and how to configure them. Here is a sample manifest that deploys a Modbus module:

{
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"modules": {
"ModbusModule": {
"settings": {
"image": "yourRegistry/yourRepository:yourTag",
"createOptions": {
"HostConfig": {
"Devices": [
{
"PathOnHost": "<device name on host machine>",
"PathInContainer": "<device name in container>",
"CgroupPermissions": "rwm"
}
]
}
}
},
"type": "docker",
"status": "running",
"restartPolicy": "always",
"version": "1.0"
},
// Additional modules go here
},
// Additional configuration goes here
}
},
// Additional module configurations go here
}
}

In this example, you would replace yourRegistry/yourRepository:yourTag with the actual Docker image location for the ModbusModule. The createOptions field includes placeholders for device mapping which is specific to Modbus RTU. You would replace <device name on host machine> and <device name in container> with the actual device names.

Please note that the specific options required for the ModbusModule will depend on its implementation. You should refer to the documentation or other resources provided by the developer of the ModbusModule to determine the correct options.

Step 2: Upload the Manifest to Azure IoT Central

Now you can upload this manifest to Azure IoT Central:

  1. In your Azure IoT Central application, go to Device Templates, and select the appropriate template for your IoT Edge device.
  2. Go to Edge Manifests.
  3. Click + New to add a new manifest.
  4. Enter a name for the manifest, and paste the manifest JSON in the Manifest field.
  5. Click Create.

Step 3: Deploy the Modbus Module

Finally, you can deploy your Modbus module to your IoT Edge device:

  1. In your Azure IoT Central application, go to Devices, and select your IoT Edge device.
  2. Go to Configuration.
  3. In the Configuration Manifests section, select the manifest you created in the previous step.
  4. Click Save.
info

An Azure IoT Edge device can host multiple modules, each serving a distinct function or process. It's important to understand that we don't deploy these modules individually; rather, we deploy a complete manifest. This manifest is a comprehensive description of all the modules to be installed, their configurations, and the inter-module communication routes. When the manifest is deployed, all of the outlined modules are deployed and configured together on the IoT Edge device.

Your IoT Edge device will now start deploying the Modbus module according to the manifest. This might take a few minutes. After the deployment is complete, the Modbus module will start running on your IoT Edge device, and you can start interacting with it through Azure IoT Central.

Please note that the exact steps and the specifics of the manifest might differ based on your specific use case and the specifics of your Modbus module.