Modbus error

hello, i need help with modbus 1.x binding.
I have 9 relay boards with id: 2,3,4,5,7,8,9,10,11 ( https://www.aliexpress.com/item/Modbus-RTU-4-Way-Relay-Module-DIY-STM8S103-System-4-Road-Input-485-Communication/32831233056.html)
Conect via ttyUSB0 usb modbus adapter (https://www.aliexpress.com/item/Usb-to-usb-485-USB-to-RS485-Adapter-converter-plc-modbus/1694879877.html)

example modbus.cfg with modbus slave ID 11:

modbus::serial.r11.connection=/dev/ttyUSB0:9600:8:none:1:rtu
modbus::serial.r11.id=11
modbus::serial.r11.start=0
modbus::serial.r11.length=4
modbus::serial.r11.type=coil
modbus::serial.r11.valuetype=int8

example Items with first relay of board with id11:

Switch          LightR11                    "R11"          <light>         (VA_StorageRoom, gLight)         ["Lighting"]  {modbus="r11:0"}`

log Error:
2018-11-06 22:49:18.084 [WARN ] [org.apache.karaf.services.eventadmin] - EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=openhab/command/LightR11] {item=LightR11, bridgemarker=true, command=OFF, timestamp=1541540958082} | {org.osgi.service.cm.ManagedService, org.osgi.service.event.EventHandler}={service.id=356, service.bundleid=255, service.scope=bundle, event.topics=openhab/*, service.pid=org.openhab.modbus, component.name=org.openhab.binding.modbus, component.id=230} | Bundle(org.openhab.binding.modbus_1.12.0 [255])]

java.lang.NullPointerException: null

at org.openhab.binding.modbus.internal.ModbusBinding.internalReceiveCommand(ModbusBinding.java:209) [255:org.openhab.binding.modbus:1.12.0]

at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:94) [197:org.openhab.core.compat1x:2.4.0.201808120805]

at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:45) [197:org.openhab.core.compat1x:2.4.0.201808120805]

at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415) [3:org.apache.karaf.services.eventadmin:4.1.5]

at org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutBlacklistTiming(HandlerTask.java:82) [3:org.apache.karaf.services.eventadmin:4.1.5]

at org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:104) [3:org.apache.karaf.services.eventadmin:4.1.5]

at org.apache.felix.eventadmin.impl.tasks.AsyncDeliverTasks$TaskExecuter.run(AsyncDeliverTasks.java:166) [3:org.apache.karaf.services.eventadmin:4.1.5]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

at java.lang.Thread.run(Thread.java:748) [?:?]

==> /var/log/openhab2/events.log <==

2018-11-06 22:49:18.106 [GroupItemStateChangedEvent] - gLight changed from ON to OFF through LightR11

2018-11-06 22:49:18.112 [vent.ItemStateChangedEvent] - LightR11 changed from ON to OFF

thanks for help

although I don’t use modbus and most likely this is not the root-cause of your problems, modify your modbus.cfg to exlude the modbus:: part. They are not needed in OH2 when using compat1x binding configs

(add also the first line… .it helps)

pid:org.openhab.modbus
serial.r11.connection=/dev/ttyUSB0:9600:8:none:1:rtu
serial.r11.id=11
serial.r11.start=0
serial.r11.length=4
serial.r11.type=coil
serial.r11.valuetype=int8

https://www.openhab.org/addons/bindings/modbus1/

Have you tried out the v2 version of the binding? Modbus - Bindings | openHAB

thanks, it works.
now have next error in log:

now in modbud.cfg

pid:org.openhab.modbus
serial.r11.connection=/dev/ttyUSB0:9600:8:none:1:rtu
serial.r11.id=11
serial.r11.start=0
serial.r11.length=4
serial.r11.type=coil
serial.r11.valuetype=int8


serial.r5.connection=/dev/ttyUSB0:9600:8:none:1:rtu
serial.r5.id=5
serial.r5.start=0
serial.r5.length=4
serial.r5.type=coil
serial.r5.valuetype=int8


serial.r7.connection=/dev/ttyUSB0:9600:8:none:1:rtu
serial.r7.id=7
serial.r7.start=0
serial.r7.length=4
serial.r7.type=coil
serial.r7.valuetype=int8```

error in log:

2018-11-06 23:26:23.600 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 05 01 00 00 00 04 3c 4d
2018-11-06 23:26:23.603 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2018-11-06 23:26:23.606 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadCoilsRequest@7de502 (unit id 5 & transaction 779). Serial parameters: SerialParameters@186e48[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-11-06 23:26:25.200 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 07 01 00 00 00 04 3d af
2018-11-06 23:26:25.203 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2018-11-06 23:26:25.207 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadCoilsRequest@1067ee9 (unit id 7 & transaction 781). Serial parameters: SerialParameters@186e48[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-11-06 23:26:27.020 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 05 01 00 00 00 04 3c 4d
2018-11-06 23:26:27.024 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2018-11-06 23:26:27.029 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadCoilsRequest@16e7a0b (unit id 5 & transaction 784). Serial parameters: SerialParameters@186e48[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

do i have to add some resistance on modbus bus? or am I wrong in modbus config? relays work.

over my head… :stuck_out_tongue:
wait for more modbus users to offer some suggestions

Are you sure about your the device ID for r5 and r7… It seems like it refuses to read them. But 11 woks fine, right?

The reported errors all worked on a retry.
I’m assuming you have no “try 3/3” etc. in your logs.

So … it’s a transient problem. As you seem to have several serial devices on one bus you really really need to see about proper termination. RS485 lines need bias as well, but most gizmos like USB adaptors take care of that for you.

It’s also possible your mystery devices are a bit slow to respond, and you may need to allow a longer timeout, or a longer inter-transfer gap.

EDIT - the 1500 timeout you have is plenty long enough, I would think.

If this is a new setup you really should be working towards using Modbus binding v2, available in OH 2.4 onwards. Set up is quite different.

i try 100ms an 10 000ms.

2018-11-07 00:52:45.547 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 09 01 00 00 00 04 3c 81

2018-11-07 00:52:45.549 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

2018-11-07 00:52:45.552 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadCoilsRequest@14aad78 (unit id 9 & transaction 2823). Serial parameters: SerialParameters@ba1bce[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=10000]

2018-11-07 00:52:55.662 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 05 05 00 01 ff 00 dc 7e

2018-11-07 00:52:55.667 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

2018-11-07 00:52:55.671 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.WriteCoilRequest@9c8046 (unit id 5 & transaction 2825). Serial parameters: SerialParameters@ba1bce[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=10000]

2018-11-07 00:53:05.876 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 0a 01 00 00 00 04 3c b2

2018-11-07 00:53:05.878 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

2018-11-07 00:53:05.881 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadCoilsRequest@c7d863 (unit id 10 & transaction 2829). Serial parameters: SerialParameters@ba1bce[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=10000]

2018-11-07 00:53:16.047 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 05 01 00 00 00 04 3c 4d

2018-11-07 00:53:16.049 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

2018-11-07 00:53:16.052 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadCoilsRequest@1886e1a (unit id 5 & transaction 2832). Serial parameters: SerialParameters@ba1bce[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=10000]

2018-11-07 00:53:26.136 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 08 01 00 00 00 04 3d 50

2018-11-07 00:53:26.139 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

2018-11-07 00:53:26.142 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadCoilsRequest@1cc7d4e (unit id 8 & transaction 2834). Serial parameters: SerialParameters@ba1bce[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=10000]

always only error 1/3

how to disable logging errors from modbus?

Modbus 1.x binding its for me simpler then modbus binding 2.4
Thanks

Bad move, fix the error don’t hide it. You will have limited performance if every attempted transfer fails at the first attempt, waits for the timeout period, then tries again.

My modbus connection:

if I only have 1 relay board, everything is fine.
If I connect two relay boards, I see “error response EOF” in the openhab log. Only 1/3.
Where and what resistors to use? Is Connection Right? USB (openhab) should be Modbus serial Master.

Thanks for help.


Here its relay board doc.

I’ve only just seen this (was not reply to me)

At the least, put a 120R resistor at the end of your Modbus. The USB adaptor probably includes one at the other end already.

You are using twisted pair wiring, right?

Yes, twisted pair wiring.

if I divided into 2 bus (2x usb modbus converter), one connected 8 channel relay boards, the other 4 channel relay boards, then everything is ok. 4 channel and 8 channel relay boards do not work on one bus.

Now it’s ok, once per minute / 2 minutes it still displays an EOF error.

Did you manage to get rid of the modbus EOF errors?

I have 12 separate energy meters connected via modbus protocol reading 10 items from eaxch sensor, and openhab generates EOF errors on average between 20-30 an hour.

I don’t have 120 Ohm R at the end of the line, as they are not needed for <50m.