modbus: exception '2' (illegal data address)

Hi, I am trying to get data from my SMA Solar Inverter. All addresses and the general function are tested with another Modbus client. So I know that address and connection are working. But when I configure the telegraf modbus plugin, this is what I am getting:

mathias@devbitch:~/Desktop$ telegraf --config http://localhost:8086/api/v2/telegrafs/0b81784f974ac000
2023-07-15T00:56:40Z I! Loading config: http://localhost:8086/api/v2/telegrafs/0b81784f974ac000
2023-07-15T00:56:40Z I! Starting Telegraf 1.27.2
2023-07-15T00:56:40Z I! Available plugins: 237 inputs, 9 aggregators, 28 processors, 23 parsers, 59 outputs, 4 secret-stores
2023-07-15T00:56:40Z I! Loaded inputs: modbus
2023-07-15T00:56:40Z I! Loaded aggregators: 
2023-07-15T00:56:40Z I! Loaded processors: 
2023-07-15T00:56:40Z I! Loaded secretstores: 
2023-07-15T00:56:40Z I! Loaded outputs: influxdb_v2
2023-07-15T00:56:40Z I! Tags enabled: host=devbitch
2023-07-15T00:56:40Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"devbitch", Flush Interval:10s
2023-07-15T00:56:40Z I! [inputs.modbus] Got 2 request(s) touching 2 holding registers for 2 fields (slave 3)
2023-07-15T00:56:40Z I! [inputs.modbus] Got 0 request(s) touching 0 inputs registers for 0 fields (slave 3)
2023-07-15T00:56:40Z I! [inputs.modbus] Got 0 request(s) touching 0 discrete registers for 0 fields (slave 3)
2023-07-15T00:56:40Z I! [inputs.modbus] Got 0 request(s) touching 0 coil registers for 0 fields (slave 3)
**2023-07-15T00:56:50Z E! [inputs.modbus] Error in plugin: slave 3: modbus: exception '2' (illegal data address), function '131'**
2023-07-15T00:56:51Z I! [agent] Hang on, flushing any cached metrics before shutdown
2023-07-15T00:56:51Z I! [agent] Stopping running outputs

This is my config file.

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  hostname = ""
  omit_hostname = false

[[outputs.influxdb_v2]]
  urls = ["http://localhost:8086"]
  token = "$INFLUX_TOKEN"
  organization = "765WID"
  bucket = "sma"

[[inputs.modbus]]
  name = "SunnyBoy"
  timeout = "1s"
  controller = "tcp://192.168.1.230:502"
  configuration_type = "request"

  [[inputs.modbus.request]]
    slave_id = 3
    byte_order = "ABCD"
    register = "holding"
    measurement = "inverter"
   
    fields = [
      { address=30203, name="Operation.Health", type="UINT16"},
      { address=30775, name="GridMs.TotW", type="INT16"}
    ]

Does anyone have experience with this error and might be able to give a hint?

try register = “input” instead of “holding”

If I am not wrong, addresses in the range of 30001 too 39999 corresponds to analog Input, not holding registers so those uses a different function code which on Telegraf i think is configured with the register parameter.

Type of the register for the request

## Can be "coil", "discrete", "holding" or "input"
register = "coil"

@fercasjr please omit the “high” part of the addresses as they indicate the register type. Your datasheet should specify the registers and we need the register address and not the data address. So usually you see something like

voltage; holding register 3028; IEEE-754 float 32-bit

Then the address in Telegraf should be 3028 (if registers start at 0) or 3027 (if registers start at 1) and register should be holding. Can you provide a link to the register table of your device?

Its not my device, I just copied a random modbus addres table because I saw address starting at 3X and tought that he may be addressing the wrong thing. But you are correct we need the datasheet of his device to see how the addresing is specified. I am assuming that the address number is correct because he mention another client and maybe that client uses the data address?.

Its like the endianess or the start 0 vs 1 each vendor has its own interpretation on how to implement and specify the Modbus “Standard” :rofl:

I am assuming that the address number is correct because he mention another client and maybe that client uses the data address?

The issue is that everyone is using “address” in Modbus land but they all mean different things. So it might well be that this “other client” is simply subtracting 30000 from the address i.e. converts the input to the register number. So it’s a bit of trial and error but usually the device datasheets are more clear about the meaning…