Updated on 2023-05-17 GMT+08:00

Connecting Modbus Devices

Overview

A device can connect to ROMA Connect by integrating EdgeShell. EdgeShell is used to collect data from edge devices and send the data to the edge gateway of ROMA Connect. EdgeShell supports the access of devices that use the Modbus or OPC UA protocol. This section describes how to connect devices using the Modbus protocol.

ROMA Connect does not directly store data reported by devices. You must configure data forwarding rules to forward device data to other services for storage.

Prerequisites

Devices can communicate with a ROMA Connect instance over the public network. Ensure that the instance has been bound with an EIP.

Connecting a Device

EdgeShell is used to collect data from edge devices and send the data to the edge gateway of ROMA Connect. To connect a device using Modbus, perform the following steps:

  1. Create a product.

    On the Product Management page, click Create Product, set Product Type to Common, and set Protocol Type to ModBus.

  2. Create a device.

    On the Device Management page, click Create Device and select the product created in 1.

  3. Download the EdgeShell installation package.

    Click the device name to access the device details page. On the Basic Information tab page, click Download Installation Package next to EdgeShell to download the EdgeShell installation package.

  4. Start EdgeShell.

    EdgeShell can run in both the Windows and Linux environments. The startup script varies according to the environment.

    1. EdgeShell depends on the Java 11 operating environment. Before running EdgeShell, ensure that the Java operating environment has been installed and the JAVA_HOME environment variable has been configured.
    2. Decompress the downloaded edge-shell.zip package. The following figure shows the directory structure obtained after the decompression.

      • bin: startup and stop scripts
      • config: configuration parameters
      • lib: dependent jar package
      • edge-shell-1.0.0.jar: main program
    3. On the Basic Information tab page of the device details page, copy SSL Connection Address(IPv4) to the mqtt.properties file in the config directory.
    4. Run the startup script.
      • In Windows, run bin/windows/start.bat.
      • In Linux, run bin/linux/start.sh.
    5. After the device is started, the EdgeShell is connected to LINK. In this case, the device is displayed as online, and data is displayed in the Edge Details tab page of the device details page.

      After the script is started, the log directory is generated, which records startup and run logs. The edge-shell-error.log and edge-shell-info.log files exist in the directory. If the device is not connected after the startup, you can view the error logs to quickly locate the fault.

      On Windows, if the log directory is not generated after you click Start, modify the following statement in the start.bat file.

      Before the change:

      start edge-shell %JAVA_OPT% -jar edge-shell-1.0.0.jar
      
      pause

      After the change:

      java %JAVA_OPT% -jar edge-shell-1.0.0.jar
  5. Download the plug-in.

    On the Plug-in Deployment page, click Download Plug-in. In the displayed dialog box, click Download and Deploy.

    After the plug-in is installed, click Start in the Operation column to start the plug-in.

  6. Configure the Modbus connection point and collection policy.
    1. If the created device is a Modbus device, Modbus Configuration is displayed on the device details page. The Modbus plug-in supports TCP/IP and serial port connection modes. The configuration is as follows:
      • To create a Modbus connection point with the TCP/IP type, set the parameters, as shown in the following figure.

      • To create a Modbus connection point with the serial type, set the parameters, as shown in the following figure.

    2. Create a collection policy under the created connection point.

      The register address of a user device is determined by the start address and function code.

      The Modbus protocol defines the range of a device address (or start address) to be 0 to 65535, while the register address ranges from 1 to 65536. Therefore, if the start address is 5, its register address is 6.

      Function codes 01, 02, 03, and 04 are supported. Range of their register address:

      01: 000001 to 065536

      02: 100001 to 165536

      03: 400001 to 465536

      04: 300001 to 365536

      For example, if the function code is 03 and the start address is 5, the corresponding register address is 400006.

  7. Deliver the collection policy to the EdgeShell.

    On the Modbus Configuration tab page of the device details page, select the target Modbus connection point and click Deliver Policy.

  8. Configure the rule engine.

    Forward data collected from common devices to MQS.

    1. On the Rule Engine page, click Create Rule. In the dialog box displayed, select the same application as that of the common product.

    2. Click the rule engine name to access the rule engine details page and configure the source and destination.
      • Select the created product and device as the data source.
      • Select MQS in the same instance as the destination.

Debugging a Device

After the rule engine forwards the collected data to MQS, you can view the reported data on MQS. In this case, the data is reported to ROMA Connect.