ctrlX#Let’s Use Telegraf App

This article explains how to link Telegraf APP as well as InfluxDB in ctrlX. telegraf has more than 300 Plug-ins – we will configure MQTT, OPC UA and Modbus Configuration settings that can be used most in OT and Collect the Groov EPIC Controller ‘s data.

Now let’s get started!

ctrlX AUTOMATION – Telegraf

Telegraf™ is a trademark registered/owned by InfluxData and InfluxData is not associated with this ctrlX CORE App The Telegraf App collects, processes and aggregates information and can write to target systems such as InfluxDB It provides a number of Plugins.

With Telegraf, the following functions can be implemented, for example

  • Database: connects to data sources such as MongoDB, MySQL and Redis for data collection and transmission.
  • Systems: information can be gathered from the latest stack of cloud platforms, containers and orchestrators.
  • IoT sensors: critical condition data (e.g. pressure levels, temperature levels) can be collected from IoT sensors and devices.

This is the basic screen of the Telegraf App.

This is Telegraf’s Configuration management screen.

The Telegraf APP also has a Diagnostic Log function, which allows you to check the actual status of your Telegraf.

As shown in the diagram below, a red message is displayed when Telegraf encounters an error.

Install APP

Next, click on Web Server>Install an app to install the Telegraf App.

Click Install from file.

Select Telegraf App.

Just a seconds..

Enter the Telegraf Checkbox and click on the Install button.

Done!

Reference Link

ctrlX#Let’s use influxDB
PLCNEXT#Play with Influxdb
PLCNEXT#Play with InfluxDB x telegraf

Implemnetation1

First, we will create a Configuration for the Telegraf APP and send the internal Usage of ctrlX to InfluxDB.

Go to the ctrlX web server and click on Telegraf on the right.

こちらはctrlXのTelgrafのConfiguration画面になります。

Click Add Telegraf Configuration.

The Telegraf Create New screen is displayed.

Enter a Configuration name, select demo Configuration and proceed with >Ok.

Done!New Configuration is created!

Next, click on the pencil ICON and modify the Configuration File in Telegraf.

The Telegraf Configuration File is now displayed within ctrlX.

You can save the Configuration using this button.

Done!

Configuration File

This is the Telegraf Configuration screen from Implementation 1.

[agent]
  interval = “5s”
  round_interval = true
  flush_interval = “5s”

## Install InfluxDB at first
## Set up the InfluxDB with organization and initial bucket
## Log in the InfluxDB UI and get the token
## Configure the output plugin influxdb_v2 with these datas
[[outputs.influxdb_v2]]
  urls =  [“https://127.0.0.1/influxdb”]
  token = “CquPrz9Vmbx-QgvMqGJgMVdHADDkjVAKZELRcANRKqWXRr-nxKQfVEGesQz6gad5GNV1neHdSMKfkd5eb5urkA==”
  organization = “mana”
  bucket = “mainBucket”
  insecure_skip_verify = true


## Configure the input plugin with the username and password to ctrlX Core 
[[inputs.ctrlx_datalayer]]
  ## Hostname or IP address of the ctrlX CORE Data Layer server
  ##  example: server = “localhost”        # Telegraf is running directly on the device
  ##           server = “192.168.1.1”      # Connect to ctrlX CORE remote via IP
  ##           server = “host.example.com” # Connect to ctrlX CORE remote via hostname
  ##           server = “10.0.2.2:8443”    # Connect to ctrlX CORE Virtual from development environment
  server = “192.168.5.67:8443”

  ## Authentication credentials
  username = “boschrexroth”
  password = “boschrexroth”

  ## Use TLS but skip chain & host verification
  insecure_skip_verify = true

  ## Timeout for HTTP requests. (default: “10s”)
  # timeout = “10s”


  ## Create a ctrlX Data Layer subscription.
  ## It is possible to define multiple subscriptions per host. Each subscription can have its own
  ## sampling properties and a list of nodes to subscribe to.
  ## All subscriptions share the same credentials.
  [[inputs.ctrlx_datalayer.subscription]]
      ## The name of the measurement. (default: “ctrlx”)
      measurement = “metrics”

      ## Configure the ctrlX Data Layer nodes which should be subscribed.
      ## address – node address in ctrlX Data Layer (mandatory)
      ## name    – field name to use in the output (optional, default: base name of address)
      ## tags    – extra node tags to be added to the output metric (optional)
      ## Note:
      ## Use either the inline notation or the bracketed notation, not both.
      ## The tags property is only supported in bracketed notation due to toml parser restrictions
      ## Examples:
      ## Inline notation
      nodes=[
        {name=”cpu_usage_percent”, address=”framework/metrics/system/cpu-utilisation-percent”},
      ]
      ## Bracketed notation
      # [[inputs.ctrlx_datalayer.subscription.nodes]]
      #    name   =”available”
      #    address=”framework/metrics/system/memavailable-mb”
      #    ## Define extra tags related to node to be added to the output metric (optional)
      #    [inputs.ctrlx_datalayer.subscription.nodes.tags]
      #       node_tag1=”node_tag1″
      #       node_tag2=”node_tag2″
      # [[inputs.ctrlx_datalayer.subscription.nodes]]
      #    name   =”used”
      #    address=”framework/metrics/system/memused-mb”

      ## The switch “output_json_string” enables output of the measurement as json.
      ## That way it can be used in in a subsequent processor plugin, e.g. “Starlark Processor Plugin”.
      # output_json_string = false

      ## Define extra tags related to subscription to be added to the output metric (optional)
      # [inputs.ctrlx_datalayer.subscription.tags]
      #    subscription_tag1 = “subscription_tag1”
      #    subscription_tag2 = “subscription_tag2”

      ## The interval in which messages shall be sent by the ctrlX Data Layer to this plugin. (default: 1s)
      ## Higher values reduce load on network by queuing samples on server side and sending as a single TCP packet.
      #publish_interval = “1s”

      ## The interval a “keepalive” message is sent if no change of data occurs. (default: 60s)
      ## Only used internally to detect broken network connections.
      # keep_alive_interval = “60s”

      ## The interval an “error” message is sent if an error was received from a node. (default: 10s)
      ## Higher values reduce load on output target and network in case of errors by limiting frequency of error messages.
      # error_interval = “10s”

      ## The interval that defines the fastest rate at which the node values should be sampled and values captured. (default: 1s)
      ## The sampling frequency should be adjusted to the dynamics of the signal to be sampled.
      ## Higher sampling frequence increases load on ctrlX Data Layer.
      ## The sampling frequency can be higher, than the publish interval. Captured samples are put in a queue and sent in publish interval.
      ## Note: The minimum sampling interval can be overruled by a global setting in the ctrlX Data Layer configuration (‘datalayer/subscriptions/settings’).
      #sampling_interval = “1s”

      ## The requested size of the node value queue. (default: 10)
      ## Relevant if more values are captured than can be sent.
      # queue_size = 10

      ## The behaviour of the queue if it is full. (default: “DiscardOldest”)
      ## Possible values:
      ## – “DiscardOldest”
      ##   The oldest value gets deleted from the queue when it is full.
      ## – “DiscardNewest”
      ##   The newest value gets deleted from the queue when it is full.
      # queue_behaviour = “DiscardOldest”

      ## The filter when a new value will be sampled. (default: 0.0)
      ## Calculation rule: If (abs(lastCapturedValue – newValue) > dead_band_value) capture(newValue).
      # dead_band_value = 0.0

      ## The conditions on which a sample should be captured and thus will be sent as a message. (default: “StatusValue”)
      ## Possible values:
      ## – “Status”
      ##   Capture the value only, when the state of the node changes from or to error state. Value changes are ignored.
      ## – “StatusValue”
      ##   Capture when the value changes or the node changes from or to error state.
      ##   See also ‘dead_band_value’ for what is considered as a value change.
      ## – “StatusValueTimestamp”:
      ##   Capture even if the value is the same, but the timestamp of the value is newer.
      ##   Note: This might lead to high load on the network because every sample will be sent as a message
      ##   even if the value of the node did not change.
      # value_change = “StatusValue”

[[outputs.influxdb_v2]]

Change the connection settings between Telegraf and Influxdb.

[[outputs.influxdb_v2]]
  urls =  [“https://127.0.0.1/influxdb”]
  token = “CquPrz9Vmbx-QgvMqGJgMVdHADDkjVAKZELRcANRKqWXRr-nxKQfVEGesQz6gad5GNV1neHdSMKfkd5eb5urkA==”
  organization = “mana”
  bucket = “mainBucket”
  insecure_skip_verify = true

organization

organization corresponds to the one set up in InfluxDB.

bucket

The bucket should match the name of the Table where you want to store the Data.

token

The token is the API Key. If you have lost your API Key, please regenerate it.

[[inputs.ctrlx_datalayer]]

The next step is to set up the Interface to be connected to ctrlX.

server

server is the IP address of the VirtualCore.

username/passaword

The username/passaword should be entered as set in the web server.

RUN

Finally, click on the Play button to start Telegraf.

Just a seconds..

Telegraf ConfigurationのStateはRunningになります。

If you want to check the current running status of Telegraf, click on the ICON in the red box.

The screen is split into two and the execution history is displayed in the Diagnostic log.

Result

Done!There are metrics in _measurement and a _field called cpu_usage_percent.

CPU usage of ctrlX Virtualcore is now visible.

Implementation2 OPC-UA Plugin

The next step is to add the OPC UA Plugin to the Configuration of the Telegraf APP, access the OPC UA Server on the groov EPIC CPU and store the data in InfluxDB.

Reference Link

Opto22#Let’s use OPC UA Server in Groov EPIC Controller with Ctrlx OPC UA Client App!

Opto22 Side

There are detailed explanations from the Reference Link mentioned earlier, but we will only give a brief introduction to the settings in this article as well.

Click on ‘Data Service’ in Opto22.

Data Services の画面が表示され、Configuure Buttonをクリックします。

Configure the Local I/O System settings in Scanned Devices.

Ensure that Data Services in the Local I/O System is enabled.

It is also necessary to enable I/O Channels in Public Access.

The I/O screen shows all the IO Slots installed in the Opto22.

Each Channel can also be accessed as a Node in the OPCUA Server by setting a name.

This is the Module0 and Channel0 configuration screen, where you can click the Configure button to configure detailed settings.

The basic principle is that you only need to set up Name and Pubic Access-able data.

ctlX Side

The next step is to configure the ctrlX Side: open the Source Menu in InfluxDB.

The Load Data Source screen is displayed.

Search for OPC UA and double-click on Telegraf’s OPC UA Client Plugin.

The OPC UA Input Plugin screen appears.

Copy all Configuration text on the screen and paste it into the Telegraf Configuration in ctrlX.

Configuration

This is the Telegraf Configuration with the OPC-UA Plugin added.

[agent]
  interval = “5s”
  round_interval = true
  flush_interval = “5s”

## Install InfluxDB at first
## Set up the InfluxDB with organization and initial bucket
## Log in the InfluxDB UI and get the token
## Configure the output plugin influxdb_v2 with these datas
[[outputs.influxdb_v2]]
  urls =  [“https://127.0.0.1/influxdb”]
  token = “CquPrz9Vmbx-QgvMqGJgMVdHADDkjVAKZELRcANRKqWXRr-nxKQfVEGesQz6gad5GNV1neHdSMKfkd5eb5urkA==”
  organization = “mana”
  bucket = “mainBucket”
  insecure_skip_verify = true


## Configure the input plugin with the username and password to ctrlX Core 
[[inputs.ctrlx_datalayer]]
  ## Hostname or IP address of the ctrlX CORE Data Layer server
  ##  example: server = “localhost”        # Telegraf is running directly on the device
  ##           server = “192.168.1.1”      # Connect to ctrlX CORE remote via IP
  ##           server = “host.example.com” # Connect to ctrlX CORE remote via hostname
  ##           server = “10.0.2.2:8443”    # Connect to ctrlX CORE Virtual from development environment
  server = “192.168.5.67:8443”

  ## Authentication credentials
  username = “boschrexroth”
  password = “boschrexroth”

  ## Use TLS but skip chain & host verification
  insecure_skip_verify = true

  ## Timeout for HTTP requests. (default: “10s”)
  # timeout = “10s”


  ## Create a ctrlX Data Layer subscription.
  ## It is possible to define multiple subscriptions per host. Each subscription can have its own
  ## sampling properties and a list of nodes to subscribe to.
  ## All subscriptions share the same credentials.
  [[inputs.ctrlx_datalayer.subscription]]
      ## The name of the measurement. (default: “ctrlx”)
      measurement = “metrics”

      ## Configure the ctrlX Data Layer nodes which should be subscribed.
      ## address – node address in ctrlX Data Layer (mandatory)
      ## name    – field name to use in the output (optional, default: base name of address)
      ## tags    – extra node tags to be added to the output metric (optional)
      ## Note:
      ## Use either the inline notation or the bracketed notation, not both.
      ## The tags property is only supported in bracketed notation due to toml parser restrictions
      ## Examples:
      ## Inline notation
      nodes=[
        {name=”cpu_usage_percent”, address=”framework/metrics/system/cpu-utilisation-percent”},
      ]
      ## Bracketed notation
      # [[inputs.ctrlx_datalayer.subscription.nodes]]
      #    name   =”available”
      #    address=”framework/metrics/system/memavailable-mb”
      #    ## Define extra tags related to node to be added to the output metric (optional)
      #    [inputs.ctrlx_datalayer.subscription.nodes.tags]
      #       node_tag1=”node_tag1″
      #       node_tag2=”node_tag2″
      # [[inputs.ctrlx_datalayer.subscription.nodes]]
      #    name   =”used”
      #    address=”framework/metrics/system/memused-mb”

      ## The switch “output_json_string” enables output of the measurement as json.
      ## That way it can be used in in a subsequent processor plugin, e.g. “Starlark Processor Plugin”.
      # output_json_string = false

      ## Define extra tags related to subscription to be added to the output metric (optional)
      # [inputs.ctrlx_datalayer.subscription.tags]
      #    subscription_tag1 = “subscription_tag1”
      #    subscription_tag2 = “subscription_tag2”

      ## The interval in which messages shall be sent by the ctrlX Data Layer to this plugin. (default: 1s)
      ## Higher values reduce load on network by queuing samples on server side and sending as a single TCP packet.
      #publish_interval = “1s”

      ## The interval a “keepalive” message is sent if no change of data occurs. (default: 60s)
      ## Only used internally to detect broken network connections.
      # keep_alive_interval = “60s”

      ## The interval an “error” message is sent if an error was received from a node. (default: 10s)
      ## Higher values reduce load on output target and network in case of errors by limiting frequency of error messages.
      # error_interval = “10s”

      ## The interval that defines the fastest rate at which the node values should be sampled and values captured. (default: 1s)
      ## The sampling frequency should be adjusted to the dynamics of the signal to be sampled.
      ## Higher sampling frequence increases load on ctrlX Data Layer.
      ## The sampling frequency can be higher, than the publish interval. Captured samples are put in a queue and sent in publish interval.
      ## Note: The minimum sampling interval can be overruled by a global setting in the ctrlX Data Layer configuration (‘datalayer/subscriptions/settings’).
      #sampling_interval = “1s”

      ## The requested size of the node value queue. (default: 10)
      ## Relevant if more values are captured than can be sent.
      # queue_size = 10

      ## The behaviour of the queue if it is full. (default: “DiscardOldest”)
      ## Possible values:
      ## – “DiscardOldest”
      ##   The oldest value gets deleted from the queue when it is full.
      ## – “DiscardNewest”
      ##   The newest value gets deleted from the queue when it is full.
      # queue_behaviour = “DiscardOldest”

      ## The filter when a new value will be sampled. (default: 0.0)
      ## Calculation rule: If (abs(lastCapturedValue – newValue) > dead_band_value) capture(newValue).
      # dead_band_value = 0.0

      ## The conditions on which a sample should be captured and thus will be sent as a message. (default: “StatusValue”)
      ## Possible values:
      ## – “Status”
      ##   Capture the value only, when the state of the node changes from or to error state. Value changes are ignored.
      ## – “StatusValue”
      ##   Capture when the value changes or the node changes from or to error state.
      ##   See also ‘dead_band_value’ for what is considered as a value change.
      ## – “StatusValueTimestamp”:
      ##   Capture even if the value is the same, but the timestamp of the value is newer.
      ##   Note: This might lead to high load on the network because every sample will be sent as a message
      ##   even if the value of the node did not change.
      # value_change = “StatusValue”
     
     
[[inputs.opcua]]
  ## Metric name
  name = “opcua”
  #
  ## OPC UA Endpoint URL
  endpoint = “opc.tcp://192.168.5.134:14840/groov”
  #
  ## Maximum time allowed to establish a connect to the endpoint.
  connect_timeout = “10s”
  #
  ## Maximum time allowed for a request over the estabilished connection.
  request_timeout = “5s”
  #
  ## Security policy, one of “None”, “Basic128Rsa15”, “Basic256”,
  ## “Basic256Sha256”, or “auto”
  security_policy = “None”
  #
  ## Security mode, one of “None”, “Sign”, “SignAndEncrypt”, or “auto”
  security_mode = “None”
  #
  ## Path to cert.pem. Required when security mode or policy isn’t “None”.
  ## If cert path is not supplied, self-signed cert and key will be generated.
  # certificate = “/etc/telegraf/cert.pem”
  #
  ## Path to private key.pem. Required when security mode or policy isn’t “None”.
  ## If key path is not supplied, self-signed cert and key will be generated.
  # private_key = “/etc/telegraf/key.pem”
  #
  ## Authentication Method, one of “Certificate”, “UserName”, or “Anonymous”.  To
  ## authenticate using a specific ID, select ‘Certificate’ or ‘UserName’
  # auth_method = “Anonymous”
  #
  ## Username. Required for auth_method = “UserName”
  # username = “”
  #
  ## Password. Required for auth_method = “UserName”
  # password = “”
  #
  ## Option to select the metric timestamp to use. Valid options are:
  ##     “gather” — uses the time of receiving the data in telegraf
  ##     “server” — uses the timestamp provided by the server
  ##     “source” — uses the timestamp provided by the source
  # timestamp = “gather”
  #
  ## Node ID configuration
  ## name              – field name to use in the output
  ## namespace         – OPC UA namespace of the node (integer value 0 thru 3)
  ## identifier_type   – OPC UA ID type (s=string, i=numeric, g=guid, b=opaque)
  ## identifier        – OPC UA ID (tag as shown in opcua browser)
  ## tags              – extra tags to be added to the output metric (optional)
  ## Example:
  ## {name=”ProductUri”, namespace=”0″, identifier_type=”i”, identifier=”2262″, tags=[[“tag1″,”value1”],[“tag2”,”value2]]}
  nodes = [
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
    {name=”DIChannel0″,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/DI_CHANNEL0/State”}
    ,{name=”DIChannel1″,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/DI_CHANNEL1/State”}
    ,{name=”AIRotarySwitch”,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/AI_RotarySwitch/Value”}
    ,{name=”AITempature”,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/AI_Tempature/Value”}
  ]
  #
  ## Node Group
  ## Sets defaults for OPC UA namespace and ID type so they aren’t required in
  ## every node.  A group can also have a metric name that overrides the main
  ## plugin metric name.
  ##
  ## Multiple node groups are allowed
  #[[inputs.opcua.group]]
  ## Group Metric name. Overrides the top level name.  If unset, the
  ## top level name is used.
  # name =
  #
  ## Group default namespace. If a node in the group doesn’t set its
  ## namespace, this is used.
  # namespace =
  #
  ## Group default identifier type. If a node in the group doesn’t set its
  ## namespace, this is used.
  # identifier_type =
  #
  ## Node ID Configuration.  Array of nodes with the same settings as above.
  # nodes = [
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #]

  ## Enable workarounds required by some devices to work correctly
  # [inputs.opcua.workarounds]
    ## Set additional valid status codes, StatusOK (0x0) is always considered valid
    # additional_valid_status_codes = [“0xC0”]
   
    # Retrieve data from MODBUS slave devices

[[inputs.opcua]]

基本的にはこちらの設定をOPC UA Serverの設定と合わせる必要があります。

endpoint

The endpoint is the access endpoint of the OPC UA Server.

security_policy security_mode 

This is the security mode when accessing the OPC UA Server.

## Security policy, one of “None”, “Basic128Rsa15”, “Basic256”,
  ## “Basic256Sha256”, or “auto”
  security_policy = “None”
  #
  ## Security mode, one of “None”, “Sign”, “SignAndEncrypt”, or “auto”
  security_mode = “None”
  #
Nodes

Nodes is actually the OPC UA Server Nodes you want to access on the application.

Result

Done!The _measurement has more “opcua” and the _field has OPC UA Server Node data.

Implementation3 Modbus

This time, we will add Modbus Plugin to the Configuration of the Telegraf APP, access the Modbus TCP Server of the groov EPIC CPU and store the data in InfluxDB.

Reference Link

Opto22#Let’s get the IO Data from Groov EPIC via ModbusTCP

Opto22 Side

The detailed explanation is available from the Reference Link mentioned earlier, but we will only give a brief introduction to the settings in this article as well: make sure that you have enabled the Modbus function in the I/O Configuration screen.

The next step is to check the Modbus address of the Opto22 Controller. For example, in the diagram below, the Modbus addresses for Module 3, Channel 0 are Unit ID=21, 6144 and 6145.

ctrlX Side

Now we need to add Telegraf’s Modbus Plugins. This Plugin supports both RTU and TCP.

Configuration

This is the Telegraf Configuration with the Modbus Plugin added.

  [agent]
  interval = “5s”
  round_interval = true
  flush_interval = “5s”

## Install InfluxDB at first
## Set up the InfluxDB with organization and initial bucket
## Log in the InfluxDB UI and get the token
## Configure the output plugin influxdb_v2 with these datas
[[outputs.influxdb_v2]]
  urls =  [“https://127.0.0.1/influxdb”]
  token = “CquPrz9Vmbx-QgvMqGJgMVdHADDkjVAKZELRcANRKqWXRr-nxKQfVEGesQz6gad5GNV1neHdSMKfkd5eb5urkA==”
  organization = “mana”
  bucket = “mainBucket2”
  insecure_skip_verify = true


## Configure the input plugin with the username and password to ctrlX Core 
[[inputs.ctrlx_datalayer]]
  ## Hostname or IP address of the ctrlX CORE Data Layer server
  ##  example: server = “localhost”        # Telegraf is running directly on the device
  ##           server = “192.168.1.1”      # Connect to ctrlX CORE remote via IP
  ##           server = “host.example.com” # Connect to ctrlX CORE remote via hostname
  ##           server = “10.0.2.2:8443”    # Connect to ctrlX CORE Virtual from development environment
  server = “192.168.5.67:8443”

  ## Authentication credentials
  username = “boschrexroth”
  password = “boschrexroth”

  ## Use TLS but skip chain & host verification
  insecure_skip_verify = true

  ## Timeout for HTTP requests. (default: “10s”)
  # timeout = “10s”


  ## Create a ctrlX Data Layer subscription.
  ## It is possible to define multiple subscriptions per host. Each subscription can have its own
  ## sampling properties and a list of nodes to subscribe to.
  ## All subscriptions share the same credentials.
  [[inputs.ctrlx_datalayer.subscription]]
      ## The name of the measurement. (default: “ctrlx”)
      measurement = “metrics”

      ## Configure the ctrlX Data Layer nodes which should be subscribed.
      ## address – node address in ctrlX Data Layer (mandatory)
      ## name    – field name to use in the output (optional, default: base name of address)
      ## tags    – extra node tags to be added to the output metric (optional)
      ## Note:
      ## Use either the inline notation or the bracketed notation, not both.
      ## The tags property is only supported in bracketed notation due to toml parser restrictions
      ## Examples:
      ## Inline notation
      nodes=[
        {name=”cpu_usage_percent”, address=”framework/metrics/system/cpu-utilisation-percent”},
      ]
      ## Bracketed notation
      # [[inputs.ctrlx_datalayer.subscription.nodes]]
      #    name   =”available”
      #    address=”framework/metrics/system/memavailable-mb”
      #    ## Define extra tags related to node to be added to the output metric (optional)
      #    [inputs.ctrlx_datalayer.subscription.nodes.tags]
      #       node_tag1=”node_tag1″
      #       node_tag2=”node_tag2″
      # [[inputs.ctrlx_datalayer.subscription.nodes]]
      #    name   =”used”
      #    address=”framework/metrics/system/memused-mb”

      ## The switch “output_json_string” enables output of the measurement as json.
      ## That way it can be used in in a subsequent processor plugin, e.g. “Starlark Processor Plugin”.
      # output_json_string = false

      ## Define extra tags related to subscription to be added to the output metric (optional)
      # [inputs.ctrlx_datalayer.subscription.tags]
      #    subscription_tag1 = “subscription_tag1”
      #    subscription_tag2 = “subscription_tag2”

      ## The interval in which messages shall be sent by the ctrlX Data Layer to this plugin. (default: 1s)
      ## Higher values reduce load on network by queuing samples on server side and sending as a single TCP packet.
      #publish_interval = “1s”

      ## The interval a “keepalive” message is sent if no change of data occurs. (default: 60s)
      ## Only used internally to detect broken network connections.
      # keep_alive_interval = “60s”

      ## The interval an “error” message is sent if an error was received from a node. (default: 10s)
      ## Higher values reduce load on output target and network in case of errors by limiting frequency of error messages.
      # error_interval = “10s”

      ## The interval that defines the fastest rate at which the node values should be sampled and values captured. (default: 1s)
      ## The sampling frequency should be adjusted to the dynamics of the signal to be sampled.
      ## Higher sampling frequence increases load on ctrlX Data Layer.
      ## The sampling frequency can be higher, than the publish interval. Captured samples are put in a queue and sent in publish interval.
      ## Note: The minimum sampling interval can be overruled by a global setting in the ctrlX Data Layer configuration (‘datalayer/subscriptions/settings’).
      #sampling_interval = “1s”

      ## The requested size of the node value queue. (default: 10)
      ## Relevant if more values are captured than can be sent.
      # queue_size = 10

      ## The behaviour of the queue if it is full. (default: “DiscardOldest”)
      ## Possible values:
      ## – “DiscardOldest”
      ##   The oldest value gets deleted from the queue when it is full.
      ## – “DiscardNewest”
      ##   The newest value gets deleted from the queue when it is full.
      # queue_behaviour = “DiscardOldest”

      ## The filter when a new value will be sampled. (default: 0.0)
      ## Calculation rule: If (abs(lastCapturedValue – newValue) > dead_band_value) capture(newValue).
      # dead_band_value = 0.0

      ## The conditions on which a sample should be captured and thus will be sent as a message. (default: “StatusValue”)
      ## Possible values:
      ## – “Status”
      ##   Capture the value only, when the state of the node changes from or to error state. Value changes are ignored.
      ## – “StatusValue”
      ##   Capture when the value changes or the node changes from or to error state.
      ##   See also ‘dead_band_value’ for what is considered as a value change.
      ## – “StatusValueTimestamp”:
      ##   Capture even if the value is the same, but the timestamp of the value is newer.
      ##   Note: This might lead to high load on the network because every sample will be sent as a message
      ##   even if the value of the node did not change.
      # value_change = “StatusValue”
     
     
[[inputs.opcua]]
  ## Metric name
  name = “opcua”
  #
  ## OPC UA Endpoint URL
  endpoint = “opc.tcp://192.168.5.134:14840/groov”
  #
  ## Maximum time allowed to establish a connect to the endpoint.
  connect_timeout = “10s”
  #
  ## Maximum time allowed for a request over the estabilished connection.
  request_timeout = “5s”
  #
  ## Security policy, one of “None”, “Basic128Rsa15”, “Basic256”,
  ## “Basic256Sha256”, or “auto”
  security_policy = “None”
  #
  ## Security mode, one of “None”, “Sign”, “SignAndEncrypt”, or “auto”
  security_mode = “None”
  #
  ## Path to cert.pem. Required when security mode or policy isn’t “None”.
  ## If cert path is not supplied, self-signed cert and key will be generated.
  # certificate = “/etc/telegraf/cert.pem”
  #
  ## Path to private key.pem. Required when security mode or policy isn’t “None”.
  ## If key path is not supplied, self-signed cert and key will be generated.
  # private_key = “/etc/telegraf/key.pem”
  #
  ## Authentication Method, one of “Certificate”, “UserName”, or “Anonymous”.  To
  ## authenticate using a specific ID, select ‘Certificate’ or ‘UserName’
  # auth_method = “Anonymous”
  #
  ## Username. Required for auth_method = “UserName”
  # username = “”
  #
  ## Password. Required for auth_method = “UserName”
  # password = “”
  #
  ## Option to select the metric timestamp to use. Valid options are:
  ##     “gather” — uses the time of receiving the data in telegraf
  ##     “server” — uses the timestamp provided by the server
  ##     “source” — uses the timestamp provided by the source
  # timestamp = “gather”
  #
  ## Node ID configuration
  ## name              – field name to use in the output
  ## namespace         – OPC UA namespace of the node (integer value 0 thru 3)
  ## identifier_type   – OPC UA ID type (s=string, i=numeric, g=guid, b=opaque)
  ## identifier        – OPC UA ID (tag as shown in opcua browser)
  ## tags              – extra tags to be added to the output metric (optional)
  ## Example:
  ## {name=”ProductUri”, namespace=”0″, identifier_type=”i”, identifier=”2262″, tags=[[“tag1″,”value1”],[“tag2”,”value2]]}
  nodes = [
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
    {name=”DIChannel0″,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/DI_CHANNEL0/State”}
    ,{name=”DIChannel1″,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/DI_CHANNEL1/State”}
    ,{name=”AIRotarySwitch”,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/AI_RotarySwitch/Value”}
    ,{name=”AITempature”,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/AI_Tempature/Value”}
  ]
  #
  ## Node Group
  ## Sets defaults for OPC UA namespace and ID type so they aren’t required in
  ## every node.  A group can also have a metric name that overrides the main
  ## plugin metric name.
  ##
  ## Multiple node groups are allowed
  #[[inputs.opcua.group]]
  ## Group Metric name. Overrides the top level name.  If unset, the
  ## top level name is used.
  # name =
  #
  ## Group default namespace. If a node in the group doesn’t set its
  ## namespace, this is used.
  # namespace =
  #
  ## Group default identifier type. If a node in the group doesn’t set its
  ## namespace, this is used.
  # identifier_type =
  #
  ## Node ID Configuration.  Array of nodes with the same settings as above.
  # nodes = [
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #]

  ## Enable workarounds required by some devices to work correctly
  # [inputs.opcua.workarounds]
    ## Set additional valid status codes, StatusOK (0x0) is always considered valid
    # additional_valid_status_codes = [“0xC0”]
   
    # Retrieve data from MODBUS slave devices

[[inputs.modbus]]
  ## Connection Configuration
  ##
  ## The plugin supports connections to PLCs via MODBUS/TCP, RTU over TCP, ASCII over TCP or
  ## via serial line communication in binary (RTU) or readable (ASCII) encoding
  ##
  ## Device name
  name = “ModbusDriverOpto22”

  ## Slave ID – addresses a MODBUS device on the bus
  ## Range: 0 – 255 [0 = broadcast; 248 – 255 = reserved]
  slave_id = 21

  ## Timeout for each request
  timeout = “1s”

  ## Maximum number of retries and the time to wait between retries
  ## when a slave-device is busy.
  # busy_retries = 0
  # busy_retries_wait = “100ms”

  # TCP – connect via Modbus/TCP
  controller = “tcp://192.168.5.134:502”

  ## Serial (RS485; RS232)
  # controller = “file:///dev/ttyUSB0”
  # baud_rate = 9600
  # data_bits = 8
  # parity = “N”
  # stop_bits = 1

  ## For Modbus over TCP you can choose between “TCP”, “RTUoverTCP” and “ASCIIoverTCP”
  ## default behaviour is “TCP” if the controller is TCP
  ## For Serial you can choose between “RTU” and “ASCII”
  # transmission_mode = “RTU”

  ## Trace the connection to the modbus device as debug messages
  ## Note: You have to enable telegraf’s debug mode to see those messages!
  # debug_connection = false

  ## Define the configuration schema
  ##  |—register — define fields per register type in the original style (only supports one slave ID)
  ##  |—request  — define fields on a requests base
  configuration_type = “register”

  ## — “register” configuration style —

  ## Measurements
  ##

  ## Digital Variables, Discrete Inputs and Coils
  ## measurement – the (optional) measurement name, defaults to “modbus”
  ## name        – the variable name
  ## address     – variable address

  #discrete_inputs = [
  #  { name = “start”,          address = [0]},
  #  { name = “stop”,           address = [1]},
  #  { name = “reset”,          address = [2]},
  #  { name = “emergency_stop”, address = [3]},
  #]
  #coils = [
  #  { name = “motor1_run”,     address = [0]},
  #  { name = “motor1_jog”,     address = [1]},
  #  { name = “motor1_stop”,    address = [2]},
  #]

  ## Analog Variables, Input Registers and Holding Registers
  ## measurement – the (optional) measurement name, defaults to “modbus”
  ## name        – the variable name
  ## byte_order  – the ordering of bytes
  ##  |—AB, ABCD   – Big Endian
  ##  |—BA, DCBA   – Little Endian
  ##  |—BADC       – Mid-Big Endian
  ##  |—CDAB       – Mid-Little Endian
  ## data_type   – INT16, UINT16, INT32, UINT32, INT64, UINT64,
  ##               FLOAT32-IEEE, FLOAT64-IEEE (the IEEE 754 binary representation)
  ##               FLOAT32, FIXED, UFIXED (fixed-point representation on input)
  ## scale       – the final numeric variable representation
  ## address     – variable address

  holding_registers = [
    { name = “RotarySwitch”, byte_order = “ABCD”,  data_type = “FLOAT32-IEEE”, scale=1.0 ,address = [6144,6145]}
    , { name = “RotarySwitch_MinLimit”, byte_order = “ABCD”,   data_type = “FLOAT32-IEEE”, scale=1.0,  address = [6148,6149]}
    , { name = “RotarySwitch_MaxLimit”, byte_order = “ABCD”,   data_type = “FLOAT32-IEEE”, scale=1.0,  address = [6150,6151]}
  #  { name = “voltage”,      byte_order = “AB”,   data_type = “FIXED”, scale=0.1,   address = [0]},
  #  { name = “energy”,       byte_order = “ABCD”, data_type = “FIXED”, scale=0.001, address = [5,6]},
  #  { name = “current”,      byte_order = “ABCD”, data_type = “FIXED”, scale=0.001, address = [1,2]},
  #  { name = “frequency”,    byte_order = “AB”,   data_type = “UFIXED”, scale=0.1,  address = [7]},
  #  { name = “power”,        byte_order = “ABCD”, data_type = “UFIXED”, scale=0.1,  address = [3,4]},
  ]
# input_registers = [
#   { name = “tank_level”,   byte_order = “AB”,   data_type = “INT16”,   scale=1.0,     address = [0]},
#   { name = “tank_ph”,      byte_order = “AB”,   data_type = “INT16”,   scale=1.0,     address = [1]},
#   { name = “pump1_speed”,  byte_order = “ABCD”, data_type = “INT32”,   scale=1.0,     address = [3,4]},
# ]


  ## Enable workarounds required by some devices to work correctly
  # [inputs.modbus.workarounds]
    ## Pause between read requests sent to the device. This might be necessary for (slow) serial devices.
    # pause_between_requests = “0ms”
    ## Close the connection after every gather cycle. Usually the plugin closes the connection after a certain
    ## idle-timeout, however, if you query a device with limited simultaneous connectivity (e.g. serial devices)
    ## from multiple instances you might want to only stay connected during gather and disconnect afterwards.
    # close_connection_after_gather = false

[[inputs.modbus]]

Basically, the settings here need to match the settings of the Modbus TCP Server.

The Controller is the IP address of the Modbus TCP Server.

Slave id

The Slave id should be set according to the Server side.

Register

Register is the Register that you actually want to access on the application.

Result

Done!In _measurement “modbus” was added and in _field there was also register data for Modbus TCP Server.

Implementation 4MQTT

The last step is to add MQTT Plugin to the Configuration of the Telegraf APP, subscribe to the Groov EPIC CPU’s Message and store the data in InfluxDB.

Reference Link

Opto22#Let’s use MQTT function in your Groov EPIC Controller

Opto22 Side

You can find more detailed instructions from the Reference Link mentioned earlier, but this article will also just give you a brief introduction to the configuration: enable MQTT for the MQTT String and configure the MQTT Broker, etc. to be accessed.

Okay, I see the Topic published by OPTO22.

ctrlX Side

Now we can add Telegraf’s MQTTPlugins.

Configuration

This is the Telegraf Configuration with the MQTT Plugin added.

  [agent]
  interval = “5s”
  round_interval = true
  flush_interval = “5s”

## Install InfluxDB at first
## Set up the InfluxDB with organization and initial bucket
## Log in the InfluxDB UI and get the token
## Configure the output plugin influxdb_v2 with these datas
[[outputs.influxdb_v2]]
  urls =  [“https://127.0.0.1/influxdb”]
  token = “CquPrz9Vmbx-QgvMqGJgMVdHADDkjVAKZELRcANRKqWXRr-nxKQfVEGesQz6gad5GNV1neHdSMKfkd5eb5urkA==”
  organization = “mana”
  bucket = “mainBucket2”
  insecure_skip_verify = true


## Configure the input plugin with the username and password to ctrlX Core 
[[inputs.ctrlx_datalayer]]
  ## Hostname or IP address of the ctrlX CORE Data Layer server
  ##  example: server = “localhost”        # Telegraf is running directly on the device
  ##           server = “192.168.1.1”      # Connect to ctrlX CORE remote via IP
  ##           server = “host.example.com” # Connect to ctrlX CORE remote via hostname
  ##           server = “10.0.2.2:8443”    # Connect to ctrlX CORE Virtual from development environment
  server = “192.168.5.67:8443”

  ## Authentication credentials
  username = “boschrexroth”
  password = “boschrexroth”

  ## Use TLS but skip chain & host verification
  insecure_skip_verify = true

  ## Timeout for HTTP requests. (default: “10s”)
  # timeout = “10s”


  ## Create a ctrlX Data Layer subscription.
  ## It is possible to define multiple subscriptions per host. Each subscription can have its own
  ## sampling properties and a list of nodes to subscribe to.
  ## All subscriptions share the same credentials.
  [[inputs.ctrlx_datalayer.subscription]]
      ## The name of the measurement. (default: “ctrlx”)
      measurement = “metrics”

      ## Configure the ctrlX Data Layer nodes which should be subscribed.
      ## address – node address in ctrlX Data Layer (mandatory)
      ## name    – field name to use in the output (optional, default: base name of address)
      ## tags    – extra node tags to be added to the output metric (optional)
      ## Note:
      ## Use either the inline notation or the bracketed notation, not both.
      ## The tags property is only supported in bracketed notation due to toml parser restrictions
      ## Examples:
      ## Inline notation
      nodes=[
        {name=”cpu_usage_percent”, address=”framework/metrics/system/cpu-utilisation-percent”},
      ]
      ## Bracketed notation
      # [[inputs.ctrlx_datalayer.subscription.nodes]]
      #    name   =”available”
      #    address=”framework/metrics/system/memavailable-mb”
      #    ## Define extra tags related to node to be added to the output metric (optional)
      #    [inputs.ctrlx_datalayer.subscription.nodes.tags]
      #       node_tag1=”node_tag1″
      #       node_tag2=”node_tag2″
      # [[inputs.ctrlx_datalayer.subscription.nodes]]
      #    name   =”used”
      #    address=”framework/metrics/system/memused-mb”

      ## The switch “output_json_string” enables output of the measurement as json.
      ## That way it can be used in in a subsequent processor plugin, e.g. “Starlark Processor Plugin”.
      # output_json_string = false

      ## Define extra tags related to subscription to be added to the output metric (optional)
      # [inputs.ctrlx_datalayer.subscription.tags]
      #    subscription_tag1 = “subscription_tag1”
      #    subscription_tag2 = “subscription_tag2”

      ## The interval in which messages shall be sent by the ctrlX Data Layer to this plugin. (default: 1s)
      ## Higher values reduce load on network by queuing samples on server side and sending as a single TCP packet.
      #publish_interval = “1s”

      ## The interval a “keepalive” message is sent if no change of data occurs. (default: 60s)
      ## Only used internally to detect broken network connections.
      # keep_alive_interval = “60s”

      ## The interval an “error” message is sent if an error was received from a node. (default: 10s)
      ## Higher values reduce load on output target and network in case of errors by limiting frequency of error messages.
      # error_interval = “10s”

      ## The interval that defines the fastest rate at which the node values should be sampled and values captured. (default: 1s)
      ## The sampling frequency should be adjusted to the dynamics of the signal to be sampled.
      ## Higher sampling frequence increases load on ctrlX Data Layer.
      ## The sampling frequency can be higher, than the publish interval. Captured samples are put in a queue and sent in publish interval.
      ## Note: The minimum sampling interval can be overruled by a global setting in the ctrlX Data Layer configuration (‘datalayer/subscriptions/settings’).
      #sampling_interval = “1s”

      ## The requested size of the node value queue. (default: 10)
      ## Relevant if more values are captured than can be sent.
      # queue_size = 10

      ## The behaviour of the queue if it is full. (default: “DiscardOldest”)
      ## Possible values:
      ## – “DiscardOldest”
      ##   The oldest value gets deleted from the queue when it is full.
      ## – “DiscardNewest”
      ##   The newest value gets deleted from the queue when it is full.
      # queue_behaviour = “DiscardOldest”

      ## The filter when a new value will be sampled. (default: 0.0)
      ## Calculation rule: If (abs(lastCapturedValue – newValue) > dead_band_value) capture(newValue).
      # dead_band_value = 0.0

      ## The conditions on which a sample should be captured and thus will be sent as a message. (default: “StatusValue”)
      ## Possible values:
      ## – “Status”
      ##   Capture the value only, when the state of the node changes from or to error state. Value changes are ignored.
      ## – “StatusValue”
      ##   Capture when the value changes or the node changes from or to error state.
      ##   See also ‘dead_band_value’ for what is considered as a value change.
      ## – “StatusValueTimestamp”:
      ##   Capture even if the value is the same, but the timestamp of the value is newer.
      ##   Note: This might lead to high load on the network because every sample will be sent as a message
      ##   even if the value of the node did not change.
      # value_change = “StatusValue”
     
     
[[inputs.opcua]]
  ## Metric name
  name = “opcua”
  #
  ## OPC UA Endpoint URL
  endpoint = “opc.tcp://192.168.5.134:14840/groov”
  #
  ## Maximum time allowed to establish a connect to the endpoint.
  connect_timeout = “10s”
  #
  ## Maximum time allowed for a request over the estabilished connection.
  request_timeout = “5s”
  #
  ## Security policy, one of “None”, “Basic128Rsa15”, “Basic256”,
  ## “Basic256Sha256”, or “auto”
  security_policy = “None”
  #
  ## Security mode, one of “None”, “Sign”, “SignAndEncrypt”, or “auto”
  security_mode = “None”
  #
  ## Path to cert.pem. Required when security mode or policy isn’t “None”.
  ## If cert path is not supplied, self-signed cert and key will be generated.
  # certificate = “/etc/telegraf/cert.pem”
  #
  ## Path to private key.pem. Required when security mode or policy isn’t “None”.
  ## If key path is not supplied, self-signed cert and key will be generated.
  # private_key = “/etc/telegraf/key.pem”
  #
  ## Authentication Method, one of “Certificate”, “UserName”, or “Anonymous”.  To
  ## authenticate using a specific ID, select ‘Certificate’ or ‘UserName’
  # auth_method = “Anonymous”
  #
  ## Username. Required for auth_method = “UserName”
  # username = “”
  #
  ## Password. Required for auth_method = “UserName”
  # password = “”
  #
  ## Option to select the metric timestamp to use. Valid options are:
  ##     “gather” — uses the time of receiving the data in telegraf
  ##     “server” — uses the timestamp provided by the server
  ##     “source” — uses the timestamp provided by the source
  # timestamp = “gather”
  #
  ## Node ID configuration
  ## name              – field name to use in the output
  ## namespace         – OPC UA namespace of the node (integer value 0 thru 3)
  ## identifier_type   – OPC UA ID type (s=string, i=numeric, g=guid, b=opaque)
  ## identifier        – OPC UA ID (tag as shown in opcua browser)
  ## tags              – extra tags to be added to the output metric (optional)
  ## Example:
  ## {name=”ProductUri”, namespace=”0″, identifier_type=”i”, identifier=”2262″, tags=[[“tag1″,”value1”],[“tag2”,”value2]]}
  nodes = [
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
    {name=”DIChannel0″,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/DI_CHANNEL0/State”}
    ,{name=”DIChannel1″,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/DI_CHANNEL1/State”}
    ,{name=”AIRotarySwitch”,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/AI_RotarySwitch/Value”}
    ,{name=”AITempature”,namespace=”2″,identifier_type=”s”,identifier=”Devices/[optoController]/OptoMMP/Modules/Channels/AI_Tempature/Value”}
  ]
  #
  ## Node Group
  ## Sets defaults for OPC UA namespace and ID type so they aren’t required in
  ## every node.  A group can also have a metric name that overrides the main
  ## plugin metric name.
  ##
  ## Multiple node groups are allowed
  #[[inputs.opcua.group]]
  ## Group Metric name. Overrides the top level name.  If unset, the
  ## top level name is used.
  # name =
  #
  ## Group default namespace. If a node in the group doesn’t set its
  ## namespace, this is used.
  # namespace =
  #
  ## Group default identifier type. If a node in the group doesn’t set its
  ## namespace, this is used.
  # identifier_type =
  #
  ## Node ID Configuration.  Array of nodes with the same settings as above.
  # nodes = [
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #  {name=””, namespace=””, identifier_type=””, identifier=””},
  #]

  ## Enable workarounds required by some devices to work correctly
  # [inputs.opcua.workarounds]
    ## Set additional valid status codes, StatusOK (0x0) is always considered valid
    # additional_valid_status_codes = [“0xC0”]
   
    # Retrieve data from MODBUS slave devices

[[inputs.modbus]]
  ## Connection Configuration
  ##
  ## The plugin supports connections to PLCs via MODBUS/TCP, RTU over TCP, ASCII over TCP or
  ## via serial line communication in binary (RTU) or readable (ASCII) encoding
  ##
  ## Device name
  name = “ModbusDriverOpto22”

  ## Slave ID – addresses a MODBUS device on the bus
  ## Range: 0 – 255 [0 = broadcast; 248 – 255 = reserved]
  slave_id = 21

  ## Timeout for each request
  timeout = “1s”

  ## Maximum number of retries and the time to wait between retries
  ## when a slave-device is busy.
  # busy_retries = 0
  # busy_retries_wait = “100ms”

  # TCP – connect via Modbus/TCP
  controller = “tcp://192.168.5.134:502”

  ## Serial (RS485; RS232)
  # controller = “file:///dev/ttyUSB0”
  # baud_rate = 9600
  # data_bits = 8
  # parity = “N”
  # stop_bits = 1

  ## For Modbus over TCP you can choose between “TCP”, “RTUoverTCP” and “ASCIIoverTCP”
  ## default behaviour is “TCP” if the controller is TCP
  ## For Serial you can choose between “RTU” and “ASCII”
  # transmission_mode = “RTU”

  ## Trace the connection to the modbus device as debug messages
  ## Note: You have to enable telegraf’s debug mode to see those messages!
  # debug_connection = false

  ## Define the configuration schema
  ##  |—register — define fields per register type in the original style (only supports one slave ID)
  ##  |—request  — define fields on a requests base
  configuration_type = “register”

  ## — “register” configuration style —

  ## Measurements
  ##

  ## Digital Variables, Discrete Inputs and Coils
  ## measurement – the (optional) measurement name, defaults to “modbus”
  ## name        – the variable name
  ## address     – variable address

  #discrete_inputs = [
  #  { name = “start”,          address = [0]},
  #  { name = “stop”,           address = [1]},
  #  { name = “reset”,          address = [2]},
  #  { name = “emergency_stop”, address = [3]},
  #]
  #coils = [
  #  { name = “motor1_run”,     address = [0]},
  #  { name = “motor1_jog”,     address = [1]},
  #  { name = “motor1_stop”,    address = [2]},
  #]

  ## Analog Variables, Input Registers and Holding Registers
  ## measurement – the (optional) measurement name, defaults to “modbus”
  ## name        – the variable name
  ## byte_order  – the ordering of bytes
  ##  |—AB, ABCD   – Big Endian
  ##  |—BA, DCBA   – Little Endian
  ##  |—BADC       – Mid-Big Endian
  ##  |—CDAB       – Mid-Little Endian
  ## data_type   – INT16, UINT16, INT32, UINT32, INT64, UINT64,
  ##               FLOAT32-IEEE, FLOAT64-IEEE (the IEEE 754 binary representation)
  ##               FLOAT32, FIXED, UFIXED (fixed-point representation on input)
  ## scale       – the final numeric variable representation
  ## address     – variable address

  holding_registers = [
    { name = “RotarySwitch”, byte_order = “ABCD”,  data_type = “FLOAT32-IEEE”, scale=1.0 ,address = [6144,6145]}
    , { name = “RotarySwitch_MinLimit”, byte_order = “ABCD”,   data_type = “FLOAT32-IEEE”, scale=1.0,  address = [6148,6149]}
    , { name = “RotarySwitch_MaxLimit”, byte_order = “ABCD”,   data_type = “FLOAT32-IEEE”, scale=1.0,  address = [6150,6151]}
  #  { name = “voltage”,      byte_order = “AB”,   data_type = “FIXED”, scale=0.1,   address = [0]},
  #  { name = “energy”,       byte_order = “ABCD”, data_type = “FIXED”, scale=0.001, address = [5,6]},
  #  { name = “current”,      byte_order = “ABCD”, data_type = “FIXED”, scale=0.001, address = [1,2]},
  #  { name = “frequency”,    byte_order = “AB”,   data_type = “UFIXED”, scale=0.1,  address = [7]},
  #  { name = “power”,        byte_order = “ABCD”, data_type = “UFIXED”, scale=0.1,  address = [3,4]},
  ]
# input_registers = [
#   { name = “tank_level”,   byte_order = “AB”,   data_type = “INT16”,   scale=1.0,     address = [0]},
#   { name = “tank_ph”,      byte_order = “AB”,   data_type = “INT16”,   scale=1.0,     address = [1]},
#   { name = “pump1_speed”,  byte_order = “ABCD”, data_type = “INT32”,   scale=1.0,     address = [3,4]},
# ]


  ## Enable workarounds required by some devices to work correctly
  # [inputs.modbus.workarounds]
    ## Pause between read requests sent to the device. This might be necessary for (slow) serial devices.
    # pause_between_requests = “0ms”
    ## Close the connection after every gather cycle. Usually the plugin closes the connection after a certain
    ## idle-timeout, however, if you query a device with limited simultaneous connectivity (e.g. serial devices)
    ## from multiple instances you might want to only stay connected during gather and disconnect afterwards.
    # close_connection_after_gather = false
   
   
# Read metrics from MQTT topic(s)
[[inputs.mqtt_consumer]]
  ## Broker URLs for the MQTT server or cluster.  To connect to multiple
  ## clusters or standalone servers, use a separate plugin instance.
  ##   example: servers = [“tcp://localhost:1883”]
  ##            servers = [“ssl://localhost:1883”]
  ##            servers = [“ws://localhost:1883”]
  servers = [“tcp://192.168.5.72:1883”]

  ## Topics that will be subscribed to.
  topics = [
    “IOModuleSlots/optoController/OptoMMP/Modules/Channels/DI_CHANNEL0/State”,
    “IOModuleSlots/optoController/OptoMMP/Modules/Channels/AI_Tempature/Value”,
    “IOModuleSlots/optoController/OptoMMP/Modules/Channels/AI_RotarySwitch/Value”,
    “IOModuleSlots/optoController/Device Properties/Firmware Version”,
    “IOModuleSlots/optoController/Device Properties/Part Number”
   
  ]

  ## The message topic will be stored in a tag specified by this value.  If set
  ## to the empty string no topic tag will be created.
  topic_tag = “topic”

  ## QoS policy for messages
  ##   0 = at most once
  ##   1 = at least once
  ##   2 = exactly once
  ##
  ## When using a QoS of 1 or 2, you should enable persistent_session to allow
  ## resuming unacknowledged messages.
  # qos = 0

  ## Connection timeout for initial connection in seconds
  # connection_timeout = “30s”

  ## Maximum messages to read from the broker that have not been written by an
  ## output.  For best throughput set based on the number of metrics within
  ## each message and the size of the output’s metric_batch_size.
  ##
  ## For example, if each message from the queue contains 10 metrics and the
  ## output metric_batch_size is 1000, setting this to 100 will ensure that a
  ## full batch is collected and the write is triggered immediately without
  ## waiting until the next flush_interval.
  # max_undelivered_messages = 1000

  ## Persistent session disables clearing of the client session on connection.
  ## In order for this option to work you must also set client_id to identify
  ## the client.  To receive messages that arrived while the client is offline,
  ## also set the qos option to 1 or 2 and don’t forget to also set the QoS when
  ## publishing.
  # persistent_session = false

  ## If unset, a random client ID will be generated.
  # client_id = “”

  ## Username and password to connect MQTT server.
  # username = “telegraf”
  # password = “metricsmetricsmetricsmetrics”

  ## Optional TLS Config
  # tls_ca = “/etc/telegraf/ca.pem”
  # tls_cert = “/etc/telegraf/cert.pem”
  # tls_key = “/etc/telegraf/key.pem”
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = “value”
data_type = “float”

[[inputs.mqtt_consumer]]

MQTT settings should be configured according to the Broker and the Topic you want to subscribe to.

Servers

Servers are set to Broker IP address and Port.

topics

The Topic can be adapted to what you want to Subscribe to.

Data Format

Data Format is real this time.

Result

Done!The _measurement had an additional “mqtt_consumer” and the _field had subscribed data.

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする