Connect a Modbus device to the IoTHub

Connecting a Modbus device to the IoTHub requires a running agent. There are two ways to install and start an agent. The first way (recommended) is to use the agent controller (see more). The second way is to start the agent as a standalone process manually (see moreopen in new window).

Step-by-step guide using the agent controller

  1. Connect an agent controller to the IoTHub (see more).

  2. Add a modbus agent to the IoTHub by clicking the icon at the top of the agent list.

Agent Page
Agent Page
  1. Fill out the dialog with a unique name, a human-readable title, and an optional description.
Add Modbus agent
Add Modbus agent
  1. Select Modbus TCP from the Third Party Agents group as Agent Type and Confirm the data.

  2. Select the agent from the list at the left and assign the agent controller by clicking at the Assign Controller button at the top of the details view.

Assign Controller
Assign Controller
  1. Install the agent by clicking the icon in the Controller Actions and State frame
Controller State assigned
Controller State assigned
  1. Start the agent by clicking the icon.
Agent state installed
Agent state installed
  1. Confirm that the agent is connected to the IoTHub. It might be required to click the refresh icon () to see the latest state of the agent.
Agent state connected
Agent state connected

Step-by-step guide installing the agent manually

  1. Download the agent binary for the target system:
Latestv3.0.0
Linux x86open in new windowLinux x86open in new window
Linux amd64open in new windowLinux amd64open in new window
Linux armopen in new windowLinux armopen in new window
Linux arm64open in new windowLinux arm64open in new window
Windows x86open in new windowWindows x86open in new window
Windows amd64open in new windowWindows amd64open in new window
Darwinopen in new windowDarwinopen in new window
  1. Unpack it to a destination folder and open a terminal there

  2. Start the agent with the command line

./modbus-tcp --id ${id} \
  --gateway${url} \
  --token ${token}

with

  • id: ID of the agent, can be found at the General Info box
  • url: The IoTHub URL with the gateway port
  • token: Security token of the agent, can be found and copied at the General Info box
  1. Find more options at the agent manualopen in new window

Step-by-step guide connecting a Modbus thing

  1. Add a Modbus thing to the IoTHub by clicking the icon in top of the thing list at the Thing page.
Thing page
Thing page
  1. Select the type Modbus TCP and click Next
Select Thing Type
Select Thing Type
  1. Fill out the dialog with a unique name, a human-readable title, and an optional description.
Descriptive attributes of the thing
Descriptive attributes of the thing
  1. Scroll down to the configuration section and provide the device's endpoint (address and port) and a different Rack or Slot number if required. Then click Next.
Configuration of the Modbus thing
Configuration of the modbus thing
  1. Install the thing by clicking the Install button.
Install the Modbus thing
Install the Modbus thing
  1. Navigate to the Agents page and select the Modbus agent.

  2. Enable editing the agent by clicking Edit Agent

Edit Agent
Edit Agent
  1. Scroll to the Thing Assignment box and select the previously created thing.
Assign thing
Assign thing
  1. Save the assignement by clicking on the Save Changes button at the bottom.

  2. Switch back to the Things page and select the Modbus thing

Thing view
Thing view
  1. Clicking at the TRIGGER ACTIONS button at the top of the detail view.

  2. Clicking at the CONNECT DEVICE action

Action selection
Action selection
  1. Create properties to observe data items at the PLC. Use the below the Info box
Add a property
Add a property
  1. Give the property a unique name, select the correct data type and Area for it. Select an address and Quantity. Optionally, add a description and a human-readable title.
Define the property
Define the property
  1. Scroll down to see more options for example read-only, Unit, and Minimum and Maximum.
Define the property
Define the property
  1. Confirm the data.

  2. If the property was correctly created, it will be immediately visible. Moreover, if the Thing is connected, the property will automatically get values updates from the agent.

Property view
Property view
Last Updated: