ESPhome Modbus pulls too many registers at one time

The Carlo Gavazzi EM24 energy meter can only handle 11 register per request. how do I force ESPhome to create multiple Modbus requests?

When I have 4 or 5 values it works great but when i have more some of the register values come back wrong. I have test each register independent through ESPhome and have gotten the value expected. I have also tested each register with a Modbus tester.

Here is my code:

uart:
  id: mod_bus
  tx_pin: 19
  rx_pin: 22
  baud_rate: 9600
  stop_bits: 1  


modbus:
  id: modbus1    

modbus_controller:
  - id: EM24
    ## the Modbus device addr
    address: 0x1
    modbus_id: modbus1
    setup_priority: -10
    update_interval: 10s
sensor:
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Voltage_L1_N
    name: "ESP_EM24_Voltage_L1-N"
    address: 0x00
    unit_of_measurement: "V"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Voltage_L2_N
    name: "ESP_EM24_Voltage_L2-N"
    address: 0x02
    unit_of_measurement: "V"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Voltage_L3_N
    name: "ESP_EM24_Voltage_L3-N"
    address: 0x04
    unit_of_measurement: "V"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Voltage_L1_L2
    name: "ESP_EM24_Voltage_L1-L2"
    address: 0x06
    unit_of_measurement: "V"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Voltage_L2_L3
    name: "ESP_EM24_Voltage_L2-L3"
    address: 0x08
    unit_of_measurement: "V"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Voltage_L3_L1
    name: "ESP_EM24_Voltage_L3-L1"
    address: 0x10
    unit_of_measurement: "V"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1


  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24__Current_L1
    name: "ESP_EM24_Current_L1"
    address: 0x12
    unit_of_measurement: "A"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.001
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Current_L2
    name: "ESP_EM24_Current_L2"
    address: 0x14
    unit_of_measurement: "A"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.001
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Current_L3
    name: "ESP_EM24_Current_L3"
    address: 0x16
    unit_of_measurement: "A"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.001
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24__Wattage_L1
    name: "ESP_EM24_Wattage_L1"
    address: 0x18
    unit_of_measurement: "W"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24__Wattage_L2
    name: "ESP_EM24_Wattage_L2"
    address: 0x20
    unit_of_measurement: "W"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: EM24
    id: EM24_Wattage_L3
    name: "ESP_EM24_Wattage_L3"
    address: 0x22
    unit_of_measurement: "W"
    register_type: read
    value_type: U_DWORD_R
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

Check:

I think changing the order of your sensor definition in your YAML or playing with the register_count for each sensor should then trigger one query per sensor (maybe)

  • force_new_range (Optional, boolean): If possible sensors with sequential addresses are grouped together and requested in one range. Setting force_new_range: true enforces the start of a new range at that address.
1 Like