Trouble Setting Up Modbus RTU Sensor on Home Assistant

Hello everyone,

I’m currently having an issue setting up a Modbus RTU sensor with Home Assistant. I’ve connected my Modbus-USB converter to my Raspberry Pi (after trying it on my PC with success), where I have Home Assistant OS installed.

Here’s my current configuration.yml:

 modbus:
   - name: modbus_hub
     type: serial
     port: /dev/ttyUSB0
     baudrate: 9600
     bytesize: 8
     method: rtu
     parity: N
     stopbits: 1
 
 sensor:
   - platform: modbus
     scan_interval: 60
     registers:
       - name: "Temperatura"
         hub: modbus_hub
         unit_of_measurement: '°C'
         slave: 1
         register: 0
         scale: 0.01
         precision: 2
       - name: "Contenuto d'acqua volumetrico"
         hub: modbus_hub
         unit_of_measurement: '%'
         slave: 1
         register: 1
         scale: 0.01
         precision: 2

After adjusting my configuration and rebooting, I still can’t see the device in my list of devices in Home Assistant. I’ve ensured the correct USB port is set in the configuration. I also tried enabling debug logging for Pymodbus and noticed an error related to the port /dev/ttyUSB1, but I’ve since corrected it to /dev/ttyUSB0. However, even after the correction, I still don’t see any device or errors in the log.

Any assistance or suggestions would be greatly appreciated. Thank you!

I solved it, identation was wrong and address was missing, that’s my new working configuration:

modbus:
-   name: hub1
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyUSB0
    stopbits: 1
    timeout: 1
    sensors:
    -   name: Temperature Sensor 1
        slave: 1
        address: 0
        scale: 0.01
        #offset: -100
        precision: 2
        scan_interval: 10
        unit_of_measurement: °C
    -   name: Moisture Sensor 1
        slave: 1
        address: 1
        scale: 0.01
        offset: 0
        precision: 2