Skip to content

Instantly share code, notes, and snippets.

@bjeanes
Created July 23, 2022 00:25
Show Gist options
  • Save bjeanes/feba359223062a7d0bb438e7e547db6d to your computer and use it in GitHub Desktop.
Save bjeanes/feba359223062a7d0bb438e7e547db6d to your computer and use it in GitHub Desktop.
Config for collecting metrics from Sungrow inverter (tested on my SH5.0RS) with Telegraf, to publish to anywhere Telegraf supports
[[inputs.modbus]]
name = "Sungrow inverter"
controller = "tcp://$SUNGROW_IP:502"
slave_id = 1
timeout = "1s"
## 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"
tagexclude = ["slave_id", "type"]
## Per register definition
##
## Digital Variables, Discrete Inputs and Coils
## measurement - the (optional) measurement name, defaults to "modbus"
## name - the variable name
## address - variable address
discrete_inputs = [ ]
coils = [ ]
## 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 = []
input_registers = [
{ measurement = "Hz", name = "grid_frequency", byte_order = "AB", data_type = "UINT16", scale = 0.01, address = [5035] },
{ measurement = "V", name = "grid_voltage", byte_order = "AB", data_type = "UINT16", scale = 0.1, address = [5018] },
{ measurement = "A", name = "grid_current", byte_order = "AB", data_type = "INT16", scale = 0.1, address = [13030] },
{ measurement = "V", name = "mppt1_voltage", byte_order = "AB", data_type = "UINT16", scale = 0.1, address = [5010] },
{ measurement = "A", name = "mppt1_current", byte_order = "AB", data_type = "UINT16", scale = 0.1, address = [5011] },
{ measurement = "V", name = "mppt2_voltage", byte_order = "AB", data_type = "UINT16", scale = 0.1, address = [5012] },
{ measurement = "A", name = "mppt2_current", byte_order = "AB", data_type = "UINT16", scale = 0.1, address = [5013] },
{ measurement = "W", name = "dc_power", byte_order = "CDAB", data_type = "UINT32", scale = 1.0, address = [5016, 5017] },
{ measurement = "W", name = "ac_power", byte_order = "CDAB", data_type = "INT32", scale = 1.0, address = [13033, 13034] },
{ measurement = "var", name = "reactive_power", byte_order = "CDAB", data_type = "INT32", scale = 1.0, address = [5032, 5033] },
{ measurement = "%", name = "power_factor", byte_order = "AB", data_type = "INT16", scale = 0.1, address = [5034] },
{ measurement = "W", name = "load_power", byte_order = "CDAB", data_type = "INT32", scale = 1.0, address = [13007, 13008] },
{ measurement = "W", name = "export_power", byte_order = "CDAB", data_type = "INT32", scale = 1.0, address = [13009, 13010] },
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment