Modbus TCP multiple ids

Hi,

I’ve set up these things:

Bridge modbus:tcp:raspbx_port_1 [ host="raspbx", port=501, id=41 ] {
    Bridge poller smtr_boiler_act_pwr [ start=12, length=2, refresh=2000, type="input" ] {
        Thing data smtr_boiler_act_pwr_val [ readStart="12", readValueType="float32" ]
    }
}

Bridge modbus:tcp:raspbx_port_1 [ host="raspbx", port=501, id=40 ] {
    Bridge poller smtr_aqs_act_pwr [ start=12, length=2, refresh=2000, type="input" ] {
        Thing data smtr_aqs_act_pwr_val [ readStart="12", readValueType="float32" ]
    }
}

And these items:

Number AQS_active_power             "Potência AQS [%.1f]"             (All)  {channel="modbus:data:raspbx_port_1:smtr_aqs_act_pwr:smtr_aqs_act_pwr_val:number"}
Number Boiler_active_power          "Potência Aquecimento [%.1f]"     (All)  {channel="modbus:data:raspbx_port_1:smtr_boiler_act_pwr:smtr_boiler_act_pwr_val:number"}

The issue is that both items are updated with the same value. Boiler_active_power is correct, but AQS_active_power is not.

These are the logs:

10:20:56.786 [DEBUG] [dbus.handler.ModbusPollerThingHandler] - Thing modbus:poller:raspbx_port_1:smtr_aqs_act_pwr received response PollResult(result=AsyncModbusReadResult(request = ModbusReadRequestBlueprint@187184c[slaveId=41,functionCode=READ_INPUT_REGISTERS,start=12,length=2,maxTries=3], registers = ModbusRegisterArrayImpl(41 11 99 9a)))
10:20:56.789 [DEBUG] [ternal.handler.ModbusDataThingHandler] - Thing modbus:data:raspbx_port_1:smtr_aqs_act_pwr:smtr_aqs_act_pwr_val channels updated: {modbus:data:raspbx_port_1:smtr_aqs_act_pwr:smtr_aqs_act_pwr_val:number=9.100000381469727}. readValueType=float32, readIndex=Optional[12], readSubIndex(or 0)=0, extractIndex=0 -> numeric value 9.100000381469727 and boolValue=true. Registers ModbusRegisterArrayImpl(41 11 99 9a) for request ModbusReadRequestBlueprint@187184c[slaveId=41,functionCode=READ_INPUT_REGISTERS,start=12,length=2,maxTries=3]
10:20:57.617 [DEBUG] [dbus.handler.ModbusPollerThingHandler] - Thing modbus:poller:raspbx_port_1:smtr_boiler_act_pwr received response PollResult(result=AsyncModbusReadResult(request = ModbusReadRequestBlueprint@191165e[slaveId=41,functionCode=READ_INPUT_REGISTERS,start=12,length=2,maxTries=3], registers = ModbusRegisterArrayImpl(41 11 99 9a)))
10:20:57.620 [DEBUG] [ternal.handler.ModbusDataThingHandler] - Thing modbus:data:raspbx_port_1:smtr_boiler_act_pwr:smtr_boiler_act_pwr_val channels updated: {modbus:data:raspbx_port_1:smtr_boiler_act_pwr:smtr_boiler_act_pwr_val:number=9.100000381469727}. readValueType=float32, readIndex=Optional[12], readSubIndex(or 0)=0, extractIndex=0 -> numeric value 9.100000381469727 and boolValue=true. Registers ModbusRegisterArrayImpl(41 11 99 9a) for request ModbusReadRequestBlueprint@191165e[slaveId=41,functionCode=READ_INPUT_REGISTERS,start=12,length=2,maxTries=3]
10:21:00.498 [DEBUG] [dbus.handler.ModbusPollerThingHandler] - Thing modbus:poller:raspbx_port_1:smtr_aqs_act_pwr received response PollResult(result=AsyncModbusReadResult(request = ModbusReadRequestBlueprint@187184c[slaveId=41,functionCode=READ_INPUT_REGISTERS,start=12,length=2,maxTries=3], registers = ModbusRegisterArrayImpl(41 13 33 33)))
10:21:00.503 [DEBUG] [ternal.handler.ModbusDataThingHandler] - Thing modbus:data:raspbx_port_1:smtr_aqs_act_pwr:smtr_aqs_act_pwr_val channels updated: {modbus:data:raspbx_port_1:smtr_aqs_act_pwr:smtr_aqs_act_pwr_val:number=9.199999809265137}. readValueType=float32, readIndex=Optional[12], readSubIndex(or 0)=0, extractIndex=0 -> numeric value 9.199999809265137 and boolValue=true. Registers ModbusRegisterArrayImpl(41 13 33 33) for request ModbusReadRequestBlueprint@187184c[slaveId=41,functionCode=READ_INPUT_REGISTERS,start=12,length=2,maxTries=3]

On the modbus server, I can only see requests to the device with id=41, which matches the logs.

Is there any thing wrong in my config? I checked and re-checked, and I can’t find anything wrong.

Thanks.

Your file creates only one TCP Bridge Thing (and then edits it)

Bridge modbus:tcp:raspbx_port_1

The unique ID must be, well, unique.

1 Like
Bridge modbus:tcp:raspbx_port_1 [ host="raspbx", port=501, id=41 ] {

Bridge poller smtr_boiler_act_pwr [ start=12, length=2, refresh=2000, type="input" ] {
    Thing data smtr_boiler_act_pwr_val [ readStart="12", readValueType="float32" ]
    }

Bridge poller smtr_aqs_act_pwr [ start=12, length=2, refresh=2000, type="input" ] {
    Thing data smtr_aqs_act_pwr_val [ readStart="12", readValueType="float32" ]
    }

}

This way, i think - but why do you want to get the same data twice?
Are you sure, start/readStart are configured correct?

Maybe there is another way:

Bridge modbus:tcp:raspbx_port_1 [ host="raspbx", port=501, id=41 ] {

Bridge poller smtr                     [ start=12, length=3, refresh=2000, type="input" ] {
    Thing data smtr_boiler_act_pwr_val [ readStart="12", readValueType="float32" ]
	Thing data smtr_aqs_act_pwr_val    [ readStart="13", readValueType="float32" ]
    }		
}

Changed poller-name + length + readStart in this example.

The OP wants to use two different IDs with the same TCP target. That’s fine, that’s how gateways work. There are a few other Modbus-TCP devices that will respond to multiple IDs as well.
You just make a (unique) Bridge for each ID.

Ah… I understand!
I always thought, different connections need different ID´s.

Thank you for explaining.

That was the solution. Thanks for the effort.