1. Home
  2. Getting Started
  3. Tutorials
  4. Barbara onboarding Tutorial – Chapter 3: Additional Apps – The Modbus connector

Barbara onboarding Tutorial – Chapter 3: Additional Apps – The Modbus connector

Apart from the “Starter Kit” Barbara may provide you with some additional apps for you to make the most of your trial:

The MODBUS connector

This application is a real example of an industrial connector that reads and write data from a Modbus interface (RTU o TCP). It process real data received from a Modbus Industrial equipment, and publishes it in the MQTT broker. It also allows writing to the Modbus interface by publishing in the MQTT broker.

The application requires a running MQTT broker, so make sure you have already installed it as explained in the previous section.

Configuring the Secrets

  • To configure the application you need first to register the following secrets:
NAMEVALUE
MODBUS_MQTT_USERuser
MODBUS_MQTT_PASSWORDpassword
MODBUS_MQTT_PORT8883
MODBUS_MQTT_HOSTmqttbbr
MODBUS_MQTT_CLIENT_IDConector_Modbus
MODBUS_MQTT_TLSfalse
MODBUS_MQTT_PUB_TOPICapi/v2/internal/
MODBUS_MQTT_SUB_TOPICapi/v2/internal/writes/#
MODBUS_MQTT_SUB_TOPIC_QOS0
  • To add them, click the “Advanced Options” icon in the top menu
  • Then click the “Add Secret” button and add the secrets according to the previous table:

You can add them manually one by one, or in bulk importing a TXT file. For your convenience we have compiled that list of secrets in the following TXT file. Just download it and import it through the “TXT FILE” button

Installing the Modbus Connector

  • Now you can install the application by clicking the ADD CARD button and choose the “User Docker App” option 
  • Select the “Modbus Connector” app from the list of apps and pick the latest existing version. Click SEND button

In a few seconds you should see that the app is up and running

Configuring the Modbus Connector with the Appconfig file

  • Finally, you need to configure some settings via the “App config”. To do so you need to paste the following JSON-format text in the CONFIG section of the application card
{
  "connectorModbus": {
    "system": {
      "debugLevel": "info",
      "persist": false,
      "refresh": 0,
      "resetOnFailure": false,
      "resetOnFailureAttemps": 0,
      "rwGapTime": 0
    },
    "inputs": [
      {
        "connection": {
          "type": "",
          "server": "",
          "port": 0,
          "baudRate": 0,
          "parity": "",
          "dataBits": 0,
          "stopBits": 0,
          "timeout": 0
        },
        "devices": [
          {
            "slaveId": 0,
            "deviceDisplayName": "",
            "mapping": [
              {
                "displayName": "",
                "address": 0,
                "bitQuantity": 0,
                "dataType": "",
                "registerType": "",
                "bigEndian": true,
                "correctionFactor": 0,
                "ieee754": true
              }
            ]
          }
        ]
      }
    ]
  }
}

Notice that the values above are just examples.

Where the meaning of every field is:

System (Basic system configuration)

  • debugLevel : Logging configuration.
    • 0 – Fatal Error
    • 1 – Errors
    • 2 – Warnings
    • 3 – General Information
    • 4 – Debug Information
  • persist: Activates local database for readings in case of connectivity failure with the mqtt
    • false
    • true
  • refresh: global time between readings (can be replaced by the refresh of each connection.)
    • int (seconds)
  • resetOnFailure: on failure of a “resetOnFailureAttemps” read quantity the connector is restarted
    • false
    • true

Outputs: (outputs of the connector data – MQTT – MYSQL – REST API)

  • Note: temporarily cannot be modified, more outputs will be supported in the future.

Inputs:

  • connection:
- type: 
	- "rtu"
	- "tcp"
- server:
	- If tcp:  destination ip "192.168.1.0"
	- If rtu: Location of the device where the modbus bus is connected "/dev/ttyS0"
- port: destination port only for modbus tcp type
	- int
- baudRate: only for modbus rtu type
	- int (1200 - 115200)
- parity: 
	- "N" (none)
	- "E" (even)
	- "O" (odd)
 - databits:
	 - 5
	 - 6
	 - 7
	 - 8
 - stopbits:
	 - 1
	 - 2
 - timeout : read write timeout
        - int (seconds)
  • device: (slave to read in connection)
- slaveId:
	- int
- deviceDisplayName: (name for the db registry of the device)
	- string
  • mapping: (variables to read in the device)
- displayName: Display name of the read in the db
	- string
- address:
	- int
- bitQuantity: bits to read in the register
	- int
- dataType:
	- "bit"
	- "uInt8"
	- "uInt16"
	- "uInt32"
	- "uInt64"
	- "int8"
	- "int16"
	- "int32"
	- "int64"
- registerType:
	- "holding"
	- "coil"
	- "input"
- bigEndian: codification of data in modbus
	- true (bigEndian)
	- false (littleEndian)
- ieee754: optional support for ieee754 codification
	- true
	- false

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support