Openhab4 + Modbus via Waveshare RS485 TO POE ETH (B) + 2 slaves

Hi :wink:

I am trying to control the relay board and read data from the kWh meter via an rs485 to eth converter.
Everything works separately.
When I use both bridges at the same time, the relay plug loses connection with OH and starts turning random relays on and off on its own.
Hardware-wise, everything looks OK.
Below is the binding configuration.

Bridge modbus:tcp:LicznikkWh_Strych "kWh Strych Bridge" [ host="192.168.6.201", port=4196, id=1] {
    Bridge poller inputRegisters [ start=0, length=80, refresh=1000, type="input" ] {
    }
}

Bridge modbus:tcp:Przekazniki "PrzekaĆșniki strych Bridge" [ host="192.168.6.201", port=4196, id=3] {
    Bridge poller PkStrych "PKS" [ start=1, length=16, refresh=500, type="holding" ] {
    }
}

what am I doing wrong?

Are you using Modbus TCP or Modbus RTU Over TCP. The setting for this is ok?

RTU Encoding is activated?

in the converter yes.

In Openhab?

no, the bridge configuration does not have RTU enabled because it causes errors in OH communication with the converter

I do not know Modbus so I could be completely wrong about this, but shouldn’t you have some Things under the poller?

both bridges have things. The problem already appears at the poller stage. If the ID3 relay bridge is active, controlling it works, but when I turn on the ID1 bridge, ID3 stops working and it turns red.

There are no Things here, only bridges. Are you mixing managed Things and .things files?

It also seems odd to have two bridges connected to the same host and port. Usually that’s not allowed and it’s my understanding that this is why the binding uses nested bridges.

Based on the examples in the docs and on the forum it should be something like:

Bridge modbus:tcp:hostTCP [ host="192.1678.6.201", port=4196, id=1 ] {
    Bridge poller inputRegisters [ start=0, length=80, refresh=1000, type="input" ] {
        Thing data ...
        Thing data ...
    }
    Bridge poller PkStrych "PKS" [ start=1, length=16, refresh=500, type="holding" ] {
        Thing data ...
        Thing data ...
    }
}

The behavior you describe sounds a whole lot like the problem is the multiple connections to the same socket which isn’t allowed. When the second one tries to connect it replaces the connection of the first one perhaps or at least interferes with it.

No. If you have different Modbus IDs, you need to configure it like this. I have it working like this.

Bridge modbus:tcp:hostTCP [ host="192.1678.6.201", port=4196, id=1 ] {
    Bridge poller inputRegisters [ start=0, length=80, refresh=1000, type="input" ] {
        Thing data ...
        Thing data ...
    }
}

Bridge modbus:tcp:hostTCP [ host="192.1678.6.201", port=4196, id=2 ] {
    Bridge poller inputRegisters [ start=0, length=80, refresh=1000, type="input" ] {
        Thing data ...
        Thing data ...
    }
}

It is as STSC writes. Despite the theoretically correct configuration, I do not know where the problems come from.

Have you proved your ability to successfully read and control the devices in exactly the manner you expect from outside Openhab via a free Modbus test client? i.e. from simplymodbus.ca.

Can you set the logging level for the binding to TRACE to see if it reports why one of the Bridges or Things is going offline?

The things have error reason visible in UI as well

I am able to communicate with both modules via e.g. Modbus Poll. With OH I can also communicate with them, just not “simultaneously”.

Error in the log after running both bridges
“[ERROR] [ort.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=3, functionCode=READ_MULTIPLE_REGISTERS, start=1, length=16, maxTries=3]). Aborting. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID 85df160f-f35e-466b-802a-5413f5f739e0]”

If I use only one bridge there are no errors.

In my mind you have to give them individual names? hostTCP1 and hostTCP2?

They have individually named

Bridge modbus:tcp:LicznikkWh_Strych "kWh Strych Bridge" [ host="192.168.6.201", port=4196, id=1] {
    Bridge poller inputRegisters [ start=0, length=80, refresh=1000, type="input" ] {
    }
}

Bridge modbus:tcp:Przekazniki "PrzekaĆșniki strych Bridge" [ host="192.168.6.201", port=4196, id=3] {
    Bridge poller PkStrych "PKS" [ start=1, length=16, refresh=500, type="holding" ] {
    }
}

In cases like this, the device probably cannot handle the traffic openHAB is generating

  1. Are any of the reads successful?
  2. Is the error occurring right after the connection has been established (you might need to enable verbose logging)? You can give some breathing space for the device with “afterConnectionDelayMillis” parameter with tcp thing
  3. You can also try increasing “timeBetweenTransactionsMillis” from default 60 ms to, say, 150ms. This is the minimum time between requests giving some extra breathing space for the device when the 500ms and 1000ms polls would happen right after each another

I thought so too and tried various delays but the result was only a communication error.
Today I installed another module, the same parts, but probably different software.
The tests have been running for one hour without any errors for other modules and for itself.
The previous record on the old module was 10 seconds ;/. It seems that the relay module has something wrong with the software since everything is OK on another device

1 Like