# Retrieve data from MODBUS slave devices
[[inputs.modbus]]

  # Hiermit wird auch _time auf 60s (also ganze Minuten) gerundet
  # Sollten (nach der Timestamp Rundung) mehrere Abfragen auf denselben Timestamp (_time)
  # kommen wird kein Fehler geworfen, sondern der bestehende Wert wird einfach upgedated!
  precision = "60s"


  ## 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 = "EAP"

  ## Timeout for each request
  timeout = "500ms"

  ## Maximum number of retries and the time to wait between retries
  ## when a slave-device is busy.
  busy_retries = 3
  busy_retries_wait = "200ms"

  # TCP - connect via Modbus/TCP
  controller = "tcp://192.168.254.223:502"

  ## 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 = true

  ## 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 = "request"

  ## --- "request" configuration style ---

  ## Per request definition
  ##

  ## Define a request sent to the device
  [[inputs.modbus.request]]
    slave_id = 9
    byte_order = "ABCD"
    register = "holding"
    fields = [
      { address=32000, measurement="Bitfield", name="State1", type="UINT16" },
      { address=32002, measurement="Bitfield", name="State2", type="UINT16" },
      { address=32003, measurement="Bitfield", name="State3", type="UINT32" },
      { address=32008, measurement="Bitfield", name="Alarm1", type="UINT16" },
      { address=32009, measurement="Bitfield", name="Alarm2", type="UINT16" },
      { address=32010, measurement="Bitfield", name="Alarm3", type="UINT16" },
      { address=32016, measurement="Voltage", name="PV1", type="INT16", scale=0.1, output="FLOAT64" },
      { address=32017, measurement="Current", name="PV1", type="INT16", scale=0.01, output="FLOAT64" },
      { address=32018, measurement="Voltage", name="PV2", type="INT16", scale=0.1, output="FLOAT64" },
      { address=32019, measurement="Current", name="PV2", type="INT16", scale=0.01, output="FLOAT64" },
      { address=32020, measurement="Voltage", name="PV3", type="INT16", scale=0.1, output="FLOAT64" },
      { address=32021, measurement="Current", name="PV3", type="INT16", scale=0.01, output="FLOAT64" },
      { address=32022, measurement="Voltage", name="PV4", type="INT16", scale=0.1, output="FLOAT64" },
      { address=32023, measurement="Current", name="PV4", type="INT16", scale=0.01, output="FLOAT64" },
      { address=32064, measurement="Power", name="DC", type="INT32", output="FLOAT64" },
      { address=32080, measurement="Power", name="AC", type="INT32", output="FLOAT64" },
      { address=32086, measurement="Power", name="Efficiency", type="UINT16", scale=0.01, output="FLOAT64" },
      { address=32087, measurement="Temp", name="Internal", type="INT16", scale=0.1, output="FLOAT64" },
      { address=32088, measurement="Resistance", name="Insulation", type="UINT16", scale=0.001, output="FLOAT64" },
      { address=32089, measurement="Status", name="Device", type="UINT16" },
    ]
    [inputs.modbus.request.tags]
      resource = "30KTL"