Issue with Modbus serial RTU when using Rpi5 /Rpi500

Hello

I am quite new to the HA environment; however, I do have a good background in C/C++ .

I have an Rpi500 with a USB to RS485 dongle connected to two Modbus thermostats. Hardware is all tested separately and is working.

When I write my code in the configuration.yaml, everything works fine


configuration.yaml

Loads the default set of integrations. Do not remove.

default_config:

Load frontend themes from the themes folder

frontend:
themes: !include_dir_merge_named themes

automation: !include automations.yaml

script: !include scripts.yaml

scene: !include scenes.yaml

modbus:

  • name: RS485_hub
    type: serial
    baudrate: 38400
    bytesize: 8
    method: rtu
    parity: E
    port: /dev/ttyUSB0
    stopbits: 1
    timeout: 1
    sensors:
    • name: TT1000_1_addr
      slave: 170
      address: 0
      scan_interval: 10
    • name: TT1000_1_SP
      slave: 170
      address: 7
      scan_interval: 10
    • name: TT1000_1_FS
      slave: 170
      address: 8
      scan_interval: 10
    • name: TT1000_2_addr
      slave: 171
      address: 0
      scan_interval: 1


The code loads properly, and the data is read and displayed on the frontend

However, I would like to separate the serial initialisation and the Modbus registers declaration.

I am trying to do as follows:


configuration.yaml

Loads the default set of integrations. Do not remove.

default_config:

Load frontend themes from the themes folder

frontend:
themes: !include_dir_merge_named themes

automation: !include automations.yaml

script: !include scripts.yaml

scene: !include scenes.yaml

modbus: !include Modbus_serial/modbusRTU.yaml
sensor: !include Modbus_serial/ThermostatsTT1000.yaml


################################################################################

Filename: modbusRTU.yaml

Author: Joseph Agius

Email: [email protected]

Created: 02/07/2025

Edited last: 03/07/2025 08:00am

Description: Serial connection code via RS485 for Modbus RTU data

################################################################################

Modbus RTU connection

  • name: RS485_hub
    type: serial
    baudrate: 38400
    bytesize: 8
    method: rtu
    parity: E
    port: /dev/ttyUSB0
    stopbits: 1
    timeout: 1

##################### END OF CODE ########################################

################################################################################

Filename: ThermostatsTT1000.yaml

Author: Joseph Agius

Email: [email protected]

Created: 02/07/2025

Edited last: 03/07/2025 08:00am

Description: Declaration of sensors - starting with TT1000 thermostats

################################################################################

TT1000 by Thermostat declaration

  • platform: modbus
    scan_interval: 10
    registers:
    • name: TT1000_1_addr
      hub: RS485_hub
      slave: 170
      register: 0
      register_type: holding

##################### END OF CODE #########################################

Can anyone guide me and maybe point out what I am doing incorrectly?

Is there a debugger that I can use on the RPI500 directly?

Errors

Thanks in advance

JA