You can enroll multiple Modbus devices by specifying the IP address range to scan for Modbus devices.

Prerequisites

Ensure that you have:
  • Created a Liota gateway template on VMware Pulse IoT Center.
  • Enrolled a gateway using the Liota gateway template.
  • Created a Thing template to enroll the Modbus Thing devices.

Procedure

  1. Copy the Liota packages from the installer location to the packages folder in your gateway. Run the following command:
    root@photon-machine [ /opt/vmware/liota/data/packages ]# cp ~/mirrors_github_liota/example/pulsev2/* .
    The Liota packages are copied to the packages folder in your gateway.
  2. Edit the modbus_discovery.py package:
    root@photon-machine [ /opt/vmware/liota/data/packages ]# vi modbus_discovery.py
  3. The modbus.discovery.py package contains definitions for collecting metrics and for running commands.
    1. Configure the following parameters:
      Parameter Description
      device_props Specify the IP address range in a particular port for Modbus to scan for devices. For example,
      device_props = {"start-ip-range": "10.197.99.6", "end-ip-range": "10.197.99.8",
                                  "port": "502"}
      d Enter the device template name that you have created on VMware Pulse IoT Center. For example,
      d = PulseConnectedDevice(device_name, "HumiditySensorTemplate",
                                               self.iotcc_edge_system.reg_entity_id,
                                               device_context)
      metricName The name of the metric that is collected in VMware Pulse IoT Center. Ensure that you provide the same metric name and value type when creating a Thing template. For example,
      metricName = "Humidity"
      args To configure your humidity sensor device to send metrics to VMware Pulse IoT Center, update the entity type to InputRegister and specify the value type as float 32. The following entity types are available:
      • Coil
      • DiscreteInput
      • HoldingRegister
      • InputRegister
      For example,
      args = [self.reg_device.reg_entity_id,
                              "humidity_sensor",
                              {"entity": "InputRegister",
                               "address": 1, "type": "float32"}]
      d_metric Define the type of metric that is sent to VMware Pulse IoT Center. For example:
      d_metric = Metric(
                          name=metric_name,
                          mtype='double',
                          unit=None,
                          interval=10,
                          sampling_function=collect_metrics,
                          sampling_args=args
                      )
      client_id The ID for sending the commands. For example,
      client_id = "com.liota.modbus"
      interval The time interval in seconds to check for the commands. For example,
      interval=10
  4. After configuring the package, register it by running the following command:
    root@photon-machine [ /opt/vmware/liota/data/packages ]# python3 reg.py modbus_discovery

Results

All Modbus devices that are available within the specified IP address range are enrolled to VMware Pulse IoT Center and are listed in the Inventory > Devices page. The Metrics tab of each device publishes the metrics every 10 seconds.