Modbus rtu - issue with disconnecting

Hi,
I’m new with HA, so I’m still learing it but step by step is going better now I have an issue and I stuck on it.
I have home server on Ubuntu, with VirtualBox for HAOS, into the server I have connected USB → RS485 converter which hostOS recognized like /dev/ttyUSB0, and I can connect with my device without any issue there. I have share /dev/ttyUSB0 into the VM with HA, and now in HA I can see it like /dev/ttyS0 (as host OS recognized it like ttyUSB0, I can share only it like a ttyS0 - I can’t share USB with HA).

In HA I added configuration like that:

configuration

modbus:

  • name: reku
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyS0
    stopbits: 1
    message_wait_milliseconds: 30
    sensors:
    • name: “Temperatura Czerpnia”
      slave: 10
      address: 16
      input_type: input
      scan_interval: 60
      unit_of_measurement: °C
      scale: 0.1
      precision: 1
    • name: “Temperatura Nawiew”
      slave: 10
      address: 17
      input_type: input
      scan_interval: 60
      unit_of_measurement: °C
      scale: 0.1
      precision: 1
    • name: “Temperatura Wywiew”
      slave: 10
      address: 18
      input_type: input
      scan_interval: 60
      unit_of_measurement: °C
      scale: 0.1
      precision: 1
    • name: “Temperatura za FPX”
      slave: 10
      address: 19
      input_type: input
      scan_interval: 60
      unit_of_measurement: °C
      scale: 0.1
      precision: 1
    • name: “Temperatura PCB”
      slave: 10
      address: 22
      input_type: input
      scan_interval: 60
      unit_of_measurement: °C
      scale: 0.1
      precision: 1
    • name: “Strumień nawiew”
      slave: 10
      address: 256
      input_type: holding
      scan_interval: 60
      unit_of_measurement: m3/h
      scale: 1
      precision: 1
    • name: “Strumień wywiew”
      slave: 10
      address: 257
      input_type: holding
      scan_interval: 60
      unit_of_measurement: m3/h
      scale: 1
      precision: 1

HA can communicate with device but it is almost not full communication - some data are lost and then in sensor it has status “unavailable”.


In the next minute some other values are “unavailable”, etc.

Log of HA:

logs

2022-01-06 14:36:07 WARNING (MainThread) [homeassistant.components.modbus.validators] Temperatura Czerpnia with int is not valid, trying to convert
2022-01-06 14:36:07 WARNING (MainThread) [homeassistant.components.modbus.validators] Temperatura Nawiew with int is not valid, trying to convert
2022-01-06 14:36:07 WARNING (MainThread) [homeassistant.components.modbus.validators] Temperatura Wywiew with int is not valid, trying to convert
2022-01-06 14:36:07 WARNING (MainThread) [homeassistant.components.modbus.validators] Temperatura za FPX with int is not valid, trying to convert
2022-01-06 14:36:07 WARNING (MainThread) [homeassistant.components.modbus.validators] Temperatura PCB with int is not valid, trying to convert
2022-01-06 14:36:07 WARNING (MainThread) [homeassistant.components.modbus.validators] Strumień nawiew with int is not valid, trying to convert
2022-01-06 14:36:07 WARNING (MainThread) [homeassistant.components.modbus.validators] Strumień wywiew with int is not valid, trying to convert
2022-01-06 14:36:08 ERROR (SyncWorker_0) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] device reports readiness to read but returned no data (device disconnected or multiple access on port?)
2022-01-06 14:36:13 ERROR (SyncWorker_1) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 2 bytes (0 received)
2022-01-06 14:37:11 ERROR (SyncWorker_2) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
2022-01-06 14:38:10 ERROR (SyncWorker_3) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
2022-01-06 14:38:23 ERROR (SyncWorker_4) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 2 bytes (0 received)
2022-01-06 14:39:13 ERROR (SyncWorker_1) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 2 bytes (0 received)
2022-01-06 14:39:20 ERROR (SyncWorker_1) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
2022-01-06 14:41:10 ERROR (SyncWorker_4) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
2022-01-06 14:41:15 ERROR (SyncWorker_4) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 2 bytes (0 received)
2022-01-06 14:43:07 ERROR (SyncWorker_4) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
2022-01-06 14:44:10 ERROR (SyncWorker_3) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
2022-01-06 14:45:10 ERROR (SyncWorker_2) [homeassistant.components.modbus.modbus] Pymodbus: reku: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response

I’m sure that the connection hostOS > device is working fully ok, I’m not sure about hostOS > VM sharing the COM port, but in other VM that way of sharing this port is working so it shouldn’t be an issue here too.
I tried to change message_wait_milliseconds (or remove - use default) and scan_interval (use different interval for different values, and etc), nothing help.
What did I wrong?

  message_wait_milliseconds: 500
  retry_on_empty: true

It is not helping… the same issue.

I have started GitHub - 3cky/mbusd: Open-source Modbus TCP to Modbus RTU (RS-232/485) gateway. on hostOS, and from HA I’m asking for modbus TCP and it is working now, but this is not a way to do it, and why it is not working over RTU by serial port ?

Are you sure it’s using the correct baud rate, i.e. that the serial port settings propagate from the VM to the host?

Why is that?

I have had in HA config:

configuration

type: serial
baudrate: 9600
bytesize: 8
method: rtu
parity: N
port: /dev/ttyS0
stopbits: 1
message_wait_milliseconds: 30

And now in mbusd to use it over TCP

mbusd

device = /dev/ttyUSB0
speed = 9600
mode = 8n1
trx_control = rts

So they are the same.

I have Home Assistant (HA) on Virtual Machine so I have to share COM (serial) port with VM, and I can’t share to HA VM my USB converter because in hostOS it is already like a serial port ttyUSB0, so when I’m sharing it to HA in the Virtual Box it is present like a COM port (ttyS0, not ttyUSB0). And I can establish the communication with RS485 but it is really unstable, no idea why.

You need pass usb not serial

Follow this partially

At least usb serial should appear there:

With USB it is not working, i have no USB devices on the list no idea why. I’ve tried also with Windows on the same VirtualBox and also I shared serial and there is no issue with.

adduser $USERNAME vboxusers

You’ll need to log out and back in afterwards.

I’m already there, all other USB (like HDD are working).

getent group vboxusers
vboxusers:x:127:dar3k

Today I have tried on other RS485 converter USB-485-IND (USB-232-IND, USB-422-IND, USB-485-IND, USB-422-485-IND - ACCES I/O Products), and that one was present in USB list on VirtualBox and I shared it to HAOS, and I used /dev/ttyUSB to communicate and now it is working. So @nikito7 thank you for sending me to that direction. Looks like that cheap Chineese converter wasn’t fully support by Ubuntu kernel.

1 Like