Modbus (parallel workers, serial RTU query)

Hello!
I had a problem with using one RS-485 channel, in this case I use USB SERIAL RS-485 to communicate with my devices. There are different devices on the network with different configurations (the stop bit is currently different). So, we made 2 modbus rtu on the port / dev / ttyUSB0.
I post the configuration below (part of configurations):

modbus:
  - name: hub1
    type: serial
    timeout: 1
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 1
    bytesize: 8
    parity: N
  - name: hub_wb
    type: serial
    timeout: 1
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 2
    bytesize: 8
    parity: N

sensor:
  - platform: modbus
    scan_interval: 60
    registers:
      - name: power_active
        hub: hub1
        unit_of_measurement: W
        slave: 1
        register: 12
        register_type: input
        count: 2
        data_type: float
        precision: 2
      - name: current
        hub: hub1
        unit_of_measurement: A
        slave: 1
        register: 6
        register_type: input
        count: 2
        data_type: float
        precision: 2
      - name: power_apparent

switch:
  - platform: modbus
    scan_interval: 10
    coils:
      - name: Hall
        hub: hub_wb
        slave: 127
        coil: 5
      - name: Hall (lights)
        hub: hub_wb
        slave: 127
        coil: 4
      - name: Kitchen
        hub: hub_wb
        slave: 95
        coil: 1
      - name: Kitchen2
        hub: hub_wb
        slave: 95
        coil: 0
      - name: Bedroom
        hub: hub_wb
        slave: 95
        coil: 5

Error Logs:

2020-03-26 10:06:40 ERROR (SyncWorker_9) [homeassistant.components.modbus.sensor] No response from hub hub1, slave 1, address 12
2020-03-26 10:06:40 ERROR (SyncWorker_3) [homeassistant.components.modbus.switch] No response from hub hub_wb, slave 95, coil 0
2020-03-26 10:06:42 ERROR (SyncWorker_5) [homeassistant.components.modbus.switch] No response from hub hub_wb, slave 127, coil 4
2020-03-26 10:06:42 ERROR (SyncWorker_11) [homeassistant.components.modbus.sensor] No response from hub hub1, slave 1, address 12
2020-03-26 10:06:43 ERROR (SyncWorker_1) [homeassistant.components.modbus.switch] No response from hub hub_wb, slave 95, coil 2
2020-03-26 10:06:43 ERROR (SyncWorker_6) [homeassistant.components.modbus.sensor] No response from hub hub1, slave 1, address 30
2020-03-26 10:06:43 WARNING (SyncWorker_15) [pymodbus.client.sync] Cleanup recv buffer before send: 0x7f 0x1 0x1 0x0 0x49 0xa0
2020-03-26 10:06:43 ERROR (SyncWorker_18) [homeassistant.components.modbus.switch] No response from hub hub_wb, slave 127, coil 4
2020-03-26 10:06:43 ERROR (SyncWorker_19) [homeassistant.components.modbus.switch] No response from hub hub_wb, slave 95, coil 1
2020-03-26 10:06:43 ERROR (SyncWorker_15) [homeassistant.components.modbus.sensor] No response from hub hub1, slave 1, address 18
2020-03-26 10:06:43 ERROR (SyncWorker_17) [homeassistant.components.modbus.switch] No response from hub hub_wb, slave 127, coil 5
2020-03-26 10:06:43 ERROR (SyncWorker_14) [homeassistant.components.modbus.sensor] No response from hub hub1, slave 1, address 342
2020-03-26 10:06:43 ERROR (SyncWorker_7) [homeassistant.components.modbus.switch] No response from hub hub_wb, slave 127, coil 0
2020-03-26 10:06:44 ERROR (SyncWorker_11) [homeassistant.components.modbus.switch] No response from hub hub_wb, slave 95, coil 5
2020-03-26 10:06:44 ERROR (SyncWorker_5) [homeassistant.components.modbus.sensor] No response from hub hub1, slave 1, address 6

But, during operation, very often there are errors during the day, and as I understand it, the worker calls both modbus in parallel (unfortunately there is currently no oscilloscope to check) and causes errors in the channel, and therefore it is not possible to get the correct data. How can you decide? For example, it’s somehow related what works on one port and parallel requests cannot be.

Here is the physical connection:

It works for me, just during the day, very often errors are shown. For example, all the lines:

I decided to solve the problem in one modbus, for the device I configured the same stop bit. But it’s interesting if there are different devices with different configurations that I can’t configure :(.
This is not considered as a solution, it is really interesting if 2 different configurations are used on the same bus. Or is it wrong to have different devices with different configurations?

Hi Anatolii,

I am using your configuration and I receive this message

Invalid config for [modbus]: [timeout] is an invalid option for [modbus]. Check: modbus->modbus->0->timeout. (See /config/configuration.yaml, line 23)

Can you please tell me what version of HA and Modbus library are you using?

I came to your topic because I am investigating this issue:Modbus configuration error. KeyError: delay

Thanks.

Hello Marcos.

“Home Assistant 0.107.6”
and
“pymodbus 1.5.2”
python 3.7

In my opinion, such architecture is wrong. Since 2 different MASTER devices need different link configuration, they should be 2 different devices - 2 MODBUS dongles.

After all, when service X calls hub1, it must first program the RS485 controller to work with stopbits 1 and when service Y calls hub_wb, it must first reprogram the controller to work with stopbits 2.

If the creators of this library would allow it, calls from one hub would have to be synchronized with the second hub which would slow down the whole thing.

I propose to add an additional modbus dongle and create an additional configuration on it.

Regards,
Andrew

1 Like