Modbus TCP - All switches drive same output

Hi, I’m trying to setup multiple switches on a single Modbus TCP device, but no matter how many I create they all turn on the first output. I can’t see where in the switch configuration I am supposed to set which output the switch refers to.

I am also unable to get any inputs working, I have created “Value as Contact” but it just keeps showing null.

I have used the modbus tester from https://www.modbustester.com/ and am able to drive outputs with command 05 (singe output only) and 15 (all outputs in the same message) and can read the inputs with command 2, so I know that the physical unit itself is working.

How do I connect OpenHAB to be able to communicate with multiple Modbus/TCP inputs and outputs?

Thank you.

The FC02 (“discrete” inputs) reads happens with poller thing, depending on device you can read all the inputs with one poller, or alternatively have several pollers, one for each input (more rare case)

FC05/FC15 writes are configured using data thing, with writeType=”coil”. You can also configure which input from the polled data populates the data thing channels

Finally you then create item bound to data thing’s switch channel. You command the modbus coil output with openHAB ON/OFF commands sent to the item. Item state reflects the polled value of the discrete input

In your case, you can probably have only one poller thing, reading all the discrete inputs, and then underneath having multiple data things, each commanding one specific coil and extracting one specific discrete input from the polled data

that is pretty much it. What is the issue you are encountering?

I have a Modbus TCP Slave thing, with the IP address of my physical device.

I then have a Regular Poll thing with the Bridge being the Modbus TCP Slave. This has a poll interval of 500ms and the start address of 0 and length 8 to read all the inputs (set to “discrete input, or digital in (DI)”)

I then have a Modbus Data thing with the bridge set to the Regular Poll. This has a Write address set to 0 and type “coil, or digital out (DO)”. with write value type “individual bit (bit)” and Wrtite multiple even with single register or coil on (I have tried off as well).

I have then created multiple “Value as switch” channels, however they all act on output 1 and cannot see any way to change this.

I have also created “Value as Contact” channels, however they show the value as NULL.

You need to have multiple data things, each having different write address

it sounds like you only have one data thing, with write address of zero, and all the channels and items hooked up to this data thing. Therefore they all write to address zero