Skip to content

Instantly share code, notes, and snippets.

@derpeter
Created March 31, 2021 14:15
Show Gist options
  • Save derpeter/724114ce674c33cdd5489dd46034e235 to your computer and use it in GitHub Desktop.
Save derpeter/724114ce674c33cdd5489dd46034e235 to your computer and use it in GitHub Desktop.
# # Retrieve data from MODBUS slave devices
[[inputs.modbus]]
# ## Connection Configuration
# ##
# ## The plugin supports connections to PLCs via MODBUS/TCP or
# ## via serial line communication in binary (RTU) or readable (ASCII) encoding
# ##
# ## Device name
name = "SOLAR"
#
# ## Slave ID - addresses a MODBUS device on the bus
# ## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved]
slave_id = 1
#
# ## 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://localhost:502"
#
# ## Serial (RS485; RS232)
controller = "file:///dev/ttyUSB3"
baud_rate = 115200
data_bits = 8
parity = "N"
stop_bits = 1
transmission_mode = "RTU"
#
#
# ## 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 = "power_factor", byte_order = "AB", data_type = "FIXED", scale=0.01, address = [8]},
# { 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 = "PV array voltage", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12544]},
{ name = "PV array current", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12545]},
{ name = "PV array power", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [12546,12547]},
{ name = "Battery voltage", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12548]},
{ name = "Battery charging current", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12549]},
{ name = "Battery charging power", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [12550, 12551]},
{ name = "Load voltage", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12556]},
{ name = "Load current", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12557]},
{ name = "Load power", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [12558,12559]},
{ name = "Battery temperature", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12560]},
{ name = "Charger temperature", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12561]},
{ name = "Heat sink temperature", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [12562]},
{ name = "Battery SOC", byte_order = "AB", data_type = "FLOAT32", scale=1.0, address = [12570]},
{ name = "Max input voltage today", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [13056]},
{ name = "Max battery voltage today", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [13058]},
{ name = "Min battery voltage today", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [13059]},
{ name = "Consumed energy today", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [13060,13061]},
{ name = "Consumed energy this month", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [13062,13063]},
{ name = "Consumed energy this year", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [13064,13065]},
{ name = "Total consumed energy", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [13066,13067]},
{ name = "Generated energy today", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [13068,13069]},
{ name = "Generated energy this month", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [13070,13071]},
{ name = "Generated energy this year", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [13072,13073]},
{ name = "Total generated energy", byte_order = "CDAB", data_type = "FLOAT32", scale=0.01, address = [13074,13075]},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment