Modbus heatpump issue configuration Esphome

I have a heat pump boiler with modbus protocol but I can’t communicate with it, I attach my configuration: esphome side:
`esphome:

  name: esphome-web-f96b62
  friendly_name: ESPHome Web f96b62

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "XXXXXXXXXXXXXXAlvDLbWdJr3BxhnxchQCfMSQEDrBXPAZBnqs="

ota:


wifi:
  ssid: "XXXXXXXXXXXX"
  password: "XXXXXXXXXXXXXX"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "XXXXXXXXXXXX"
    password: "XXXXXXXXXXXX"

captive_portal:

uart:
  id: mod_bus
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
  stop_bits: 1
  #baud_rate: 115200
  
modbus:
  id: modbus1
  uart_id: mod_bus
  #send_wait_time: 200ms
  
modbus_controller:
  id: vlb
# the Modbus device addr
  address: 0x01
  modbus_id: modbus1
  update_interval: 5s
  #setup_priority: -10  

sensor:
  - platform: modbus_controller
    modbus_controller_id: vlb
    name: "maxa"
    id: maxa
    register_type: holding
    address: 2001
    value_type: U_WORD`

configuration.yaml:

modbus:
  - name: modbus1
    type: tcp
    host: 192.168.1.6
    port: 502

these are the moddbus addresses of the machine

error no response…

I know it’s been a while since you posted, but I managed to connect using an ESP32 with an RS485 module and set up the following configuration in case someone else needs it.

uart:
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
  parity: EVEN
  stop_bits: 1
  data_bits: 8

modbus:
  id: modbus1
  

modbus_controller:
  - id: heat_pump_modbus
    address: 0x01  ## address of the ModBUS slave device on the bus
    modbus_id: modbus1
    setup_priority: -10
    update_interval: 10s
    command_throttle: 2ms
1 Like

thanks for the reply, I only saw it now, I’ll try over the weekend, I wanted to ask you again, I have to replace this part of the code you sent with my parameters, in the sense: I have to leave (sensor:) etc. ?

yes, the sensors and other entities remain the same. The code above is only for connecting to the modbus controller.

1 Like

Here is an example for reading Alarms:

sensors:
### ALARMS
  - platform: modbus_controller
    modbus_controller_id: heat_pump_modbus
    name: "HP Status"
    address: 0x00C8
    value_type: U_WORD
    register_type: holding
    id: alarm1_raw
    on_value:
      then:
        - lambda: |-
            std::string state;
            switch ((int)id(alarm1_raw).state) {  // Cast to integer
              case 0:
                state = "High pressure - E001";
                break;
              case 1:
                state = "Low pressure - E002";
                break;
              case 2:
                state = "Compressor thermal protection - E003";
                break;
              case 3:
                state = "Fan theral protection - E004";
                break;
              case 4:
                state = "Frost - E005";
                break;
              case 5:
                state = "Lack of flow - E006";
                break;
              case 6:
                state = "ACC prepare low temperature - E007";
                break;
              case 7:
                state = "Lack of librication - E008";
                break;
              case 8:
                state = "High discharge temeperature of Cp 1 - E009";
                break;
              case 9:
                state = "Solar collector at high temperature - E010";
                break;
              case 12:
                state = "Compressor 2 thermal protection - E013";
                break;
              case 13:
                state = "Fan 2 thermal protection - E014";
                break;
              case 15:
                state = "Pump thermal protection - E016";
                break;
              default:
                state = "Unknown";
            }
            id(alarm1).publish_state(state);
1 Like