Smart Home Automation Forum

Full Version: Connecting Multiple Modbus Sensors to A16 (ESPHome)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'd like to greet all the forum members. I’m reaching out to ask for your help with an issue I’m experiencing.

I connected 7 sensors to an RS485 Modbus bus, but only 4 of them work simultaneously. When I connect each sensor individually, they all respond correctly. However, when I try to initialize more than 4 sensors in the YAML configuration (e.g., 1-2-3-4), they are displayed and work fine. But as soon as I add more sensors (e.g., 5-6-7), some of them stop responding or are not displayed at all.
I am using an A16 with ESPHome integrated into Home Assistant.


...
uart:
  - id: uart_modbus
    tx_pin: GPIO13
    rx_pin: GPIO16
    baud_rate: 4800
modbus:
  - uart_id: uart_modbus
    setup_priority: -10
    send_wait_time: 500 ms
    id: modbus1
modbus_controller:
  - id: modbus_sensor_2
    address: 0x02  
    modbus_id: modbus1
    update_interval: 5s
    offline_skip_updates: 2
    max_cmd_retries: 4
 
  - id: modbus_sensor_4
    address: 0x04  
    modbus_id: modbus1
    update_interval: 5s
    offline_skip_updates: 2
    max_cmd_retries: 4
  - id: modbus_sensor_7
    address: 0x07  
    modbus_id: modbus1
    update_interval: 5s
    offline_skip_updates: 2
    max_cmd_retries: 4
  - id: modbus_sensor_8
    address: 0x08  
    modbus_id: modbus1
    update_interval: 5s
    offline_skip_updates: 2
    max_cmd_retries: 4

...
...
sensor:
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor_2
    name: "t_2"
    id: temperature_sensor_2
    address: 0x0001
    register_type: holding
    value_type: U_WORD
    force_new_range: true
    unit_of_measurement: "°C"
    accuracy_decimals: 2
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor_2
    name: "h_2"
    id: humidity_sensor_2
    address: 0x0000
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "%"
    accuracy_decimals: 2
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor_4
    name: "t_4"
    id: temperature_sensor_4
    address: 0x0001
    register_type: holding
    value_type: U_WORD
    force_new_range: true
    unit_of_measurement: "°C"
    accuracy_decimals: 2
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor_4
    name: "h_4"
    id: humidity_sensor_4
    address: 0x0000
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "%"
    accuracy_decimals: 2
    filters:
      - multiply: 0.1
   
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor_7
    name: "t_i"
    id: temperature_sensor_7
    address: 0x0001
    register_type: holding
    value_type: U_WORD
    force_new_range: true
    unit_of_measurement: "°C"
    accuracy_decimals: 2
    filters:
      - lambda: |-
          if (x > 32767) {
          return (x - 65536) / 10.0;
          } else {
          return x / 10.0;
          }
   
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor_8
    name: "t_k"
    id: temperature_sensor_8
    address: 0x0001
    register_type: holding
    value_type: U_WORD
    force_new_range: true
    unit_of_measurement: "°C"
    accuracy_decimals: 2
    filters:
      - multiply: 0.1  
...
which sensor you are using? Can you take a photo.
(11-18-2024, 12:13 PM)админ Wrote: [ -> ]Какой датчик вы используете? Можно сделать фото.
i suggest you use a USB-RS485 adapter to test your sensor directly first step. if the sensor work well , then add to KC868-A16 board.
Maybe you misunderstood me.
I've already changed the addresses on all the sensors. All the addresses are different. The sensors are connected individually or in groups of less than 5 without problems. But when I initialize MORE than 5 sensors in YAML, the panel also shows 5 sensors (and the added sensors are not polled, I don't see them in the logs). And any 5 sensors are displayed, in any combinations.

My system needs a minimum of 6 sensors to work.
In general, I can connect an additional RSMAX module for one more sensor, but it is strange, because the bus is designed for a huge number of devices.
I apologize for the misinformation.
- It turns out that all sensors are displayed in the logs, but home assistant does not display them correctly. No more than 5 sensors.
next month when have free time, i will test 6pcs of RS485 temperature sensors with one bus in home assistant, then feedback to you.
(11-19-2024, 10:51 PM)admin Wrote: [ -> ]next month when have free time, i will test 6pcs of RS485 temperature sensors with one bus in home assistant, then feedback to you.

Thank you!
Moreover, I noticed that in the hass panel, while connecting more than 4 sensors, some sensors display their correct value or the one that was lost.
can you reduce the baud rate of sensor?
Pages: 1 2