esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
285 stars 34 forks source link

unexpected results from polling heat pump modbus using ESP32-C with MAX485 #5723

Closed GtHbbrr closed 3 weeks ago

GtHbbrr commented 3 weeks ago

The problem

The problem Hey, i am using a ESP32-C with a MAX485 converter. I want to read the existing modbus communication between my heat pump and its controller. I am trying to reverse engineer the modbus protocol parameters as I do not have documentation on the modus implementation for my heat pump. I did find the modbus documentation for a similar heat pump that is using the same controller pcb (HiPlus5000-M by Megmeet.com)

This other modbus documentation specifies an 2400-8-E-1 connection:

With ESPHome on HA I did get the ESP32 board working and I do see data in the debug logs but this data does not appear to be consistent with the modbus protocol one would expect.

Which version of ESPHome has the issue?

2024.4.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.4.3

What platform are you using?

ESP32

Board

https://www.tindie.com/products/thehognl/esp32-c3-with-rs485-modbus-and-optional-touch-tft/

Component causing the issue

modbus rtu rs485

Example YAML snippet

esphome:
  name: uarttest
 # includes:
 #   - uart_read_line_sensor.h  

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino

# Enable Home Assistant API
api:
  encryption:
    key: "w5RnpSGntOERM33Vp25/4RT79aq687nQFF00aGI45N4="

ota:
  password: "3137d833afca740d60793653dc4c95cc"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:
  baud_rate: 0    ## Igor Ybema: ESPhome can also be installed but make sure to turn of logging via UART (set baudrate to 0) as the RS485 uses the onboard UART (tx/rx)
  level: 
    VERY_VERBOSE
#    NONE
#    DEBUG        #Everything up to this log level is logged. Debug messages include the current readings from a sensor and status messages. Color: cyan
#    VERBOSE      #Like debug, but a few more messages that are usually deemed to be spam are also included. Color: grey
#    VERY_VERBOSE #All internal messages are logged. Including all the data flowing through data buses like I²C, SPI or UART. Warning: May cause the device to slow down and have trouble staying connecting due to amount of generated messages. Color: white

uart:             ## Igor Ybema: The RS485 is connected to the hardware uart rx/tx (gpio20/gpio21).
  id: uart_bus
  # tx_pin: GPIO21      ## Boris: just listening: tx_pin not specified
  rx_pin: GPIO20
  baud_rate: 9600
  data_bits: 8
  parity: EVEN
  stop_bits: 1
  debug:
    dummy_receiver: true
    sequence:
    #  - lambda: UARTDebug::log_string(direction, bytes );
      - lambda: UARTDebug::log_binary(direction, bytes, ',');
      - lambda: UARTDebug::log_hex(direction, bytes, ',');
modbus:
  uart_id: uart_bus
  id: mod_bus
  send_wait_time: 200ms

modbus_controller:
- id: modbus_device
  address: 0x1   ## address of the Modbus slave device on the bus
  modbus_id: mod_bus
  setup_priority: -1000

Anything in the logs that might be useful for us?

INFO ESPHome 2024.4.0
INFO Reading configuration /config/esphome/modbus.yaml...
INFO Starting log output from 192.168.178.121 using esphome API
INFO Successfully connected to uarttest @ 192.168.178.121 in 0.026s
INFO Successful handshake with uarttest @ 192.168.178.121 in 0.072s
[19:17:20][I][app:100]: ESPHome version 2024.4.0 compiled on Apr 22 2024, 19:16:19
[19:17:20][C][wifi:580]: WiFi:
[19:17:20][C][wifi:408]:   Local MAC: DC:DA:0C:C5:6E:98
[19:17:20][C][wifi:413]:   SSID: [redacted]
[19:17:20][C][wifi:416]:   IP Address: 192.168.178.121
[19:17:20][C][wifi:420]:   BSSID: [redacted]
[19:17:20][C][wifi:421]:   Hostname: 'uarttest'
[19:17:20][C][wifi:423]:   Signal strength: -58 dB ▂▄▆█
[19:17:20][V][wifi:425]:   Priority: 0.0
[19:17:20][C][wifi:427]:   Channel: 6
[19:17:20][C][wifi:428]:   Subnet: 255.255.255.0
[19:17:20][C][wifi:429]:   Gateway: 192.168.178.1
[19:17:20][C][wifi:430]:   DNS1: 213.46.228.196
[19:17:20][C][wifi:431]:   DNS2: 62.179.104.196
[19:17:20][V][modbus:042]: Modbus received Byte  0 (0X0)
[19:17:20][C][logger:166]: Logger:
[19:17:20][C][logger:167]:   Level: VERY_VERBOSE
[19:17:20][C][logger:169]:   Log Baud Rate: 0
[19:17:20][C][logger:170]:   Hardware UART: USB_CDC
[19:17:21][C][uart.arduino_esp32:137]: UART Bus 0:
[19:17:21][C][uart.arduino_esp32:139]:   RX Pin: GPIO20
[19:17:21][C][uart.arduino_esp32:141]:   RX Buffer Size: 256
[19:17:21][C][uart.arduino_esp32:143]:   Baud Rate: 2400 baud
[19:17:21][C][uart.arduino_esp32:144]:   Data Bits: 8
[19:17:21][C][uart.arduino_esp32:145]:   Parity: EVEN
[19:17:21][C][uart.arduino_esp32:146]:   Stop bits: 1
[19:17:21][V][modbus:042]: Modbus received Byte  93 (0X5d)
[19:17:21][C][modbus:143]: Modbus:
[19:17:21][C][modbus:145]:   Send Wait Time: 200 ms
[19:17:21][C][modbus:146]:   CRC Disabled: NO
[19:17:21][V][modbus:042]: Modbus received Byte  8 (0X8)
[19:17:21][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'Heat Pump Buiten Temp'
[19:17:21][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[19:17:21][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: '°C'
[19:17:21][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[19:17:21][C][mdns:115]: mDNS:
[19:17:21][C][mdns:116]:   Hostname: uarttest
[19:17:21][V][mdns:117]:   Services:
[19:17:21][V][mdns:119]:   - _esphomelib, _tcp, 6053
[19:17:21][V][mdns:121]:     TXT: version = 2024.4.0
[19:17:21][V][mdns:121]:     TXT: mac = dcda0cc56e98
[19:17:21][V][mdns:121]:     TXT: platform = ESP32
[19:17:21][V][mdns:121]:     TXT: board = esp32-c3-devkitm-1
[19:17:21][V][mdns:121]:     TXT: network = wifi
[19:17:21][V][mdns:121]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[19:17:21][V][modbus:042]: Modbus received Byte  93 (0X5d)
[19:17:21][C][ota:096]: Over-The-Air Updates:
[19:17:21][C][ota:097]:   Address: uarttest.local:3232
[19:17:21][C][ota:100]:   Using Password.
[19:17:21][C][ota:103]:   OTA version: 2.
[19:17:21][C][api:139]: API Server:
[19:17:21][C][api:140]:   Address: uarttest.local:6053
[19:17:21][C][api:142]:   Using noise encryption: YES
[19:17:21][C][modbus_controller:298]: ModbusController:
[19:17:21][C][modbus_controller:299]:   Address: 0x01
[19:17:21][C][modbus_controller:301]: sensormap
[19:17:21][C][modbus_controller:305]:  Sensor type=3 start=0x7DD offset=0x0 count=1 size=2
[19:17:21][C][modbus_controller:307]: ranges
[19:17:21][C][modbus_controller:310]:   Range type=3 start=0x7DD count=1 skip_updates=0
[19:17:21][D][uart_debug:196]: <<< 0b01001001 (0x49),0b01001001 (0x49),0b01001001 (0x49),0b01111001 (0x79),0b01011011 (0x5B),0b01101101 (0x6D),0b01001001 (0x49),0b01001001 (0x49),0b01001001 (0x49),0b01001001 (0x49),0b11011011 (0xDB),0b01001101 (0x4D),0b10001000 (0x88),0b01001101 (0x4D),0b11111111 (0xFF),0b01011101 (0x5D),0b11111111 (0xFF),0b00000000 (0x00),0b01011101 (0x5D),0b00001000 (0x08),0b01011101 (0x5D)
[19:17:21][D][uart_debug:114]: <<< 49,49,49,79,5B,6D,49,49,49,49,DB,4D,88,4D,FF,5D,FF,00,5D,08,5D
[19:17:21][V][modbus:042]: Modbus received Byte  73 (0X49)
[19:17:21][V][modbus:042]: Modbus received Byte  73 (0X49)
[19:17:21][V][modbus:042]: Modbus received Byte  73 (0X49)
[19:17:21][V][modbus:042]: Modbus received Byte  121 (0X79)
[19:17:21][V][modbus:042]: Modbus received Byte  91 (0X5b)
[19:17:21][V][modbus:042]: Modbus received Byte  109 (0X6d)
[19:17:21][V][modbus:042]: Modbus received Byte  73 (0X49)
[19:17:21][V][modbus:042]: Modbus received Byte  73 (0X49)
[19:17:21][V][modbus:042]: Modbus received Byte  73 (0X49)
[19:17:21][V][modbus:042]: Modbus received Byte  73 (0X49)
[19:17:21][V][modbus:042]: Modbus received Byte  219 (0Xdb)
[19:17:21][V][modbus:042]: Modbus received Byte  77 (0X4d)
[19:17:21][V][modbus:042]: Modbus received Byte  136 (0X88)
[19:17:21][V][modbus:042]: Modbus received Byte  77 (0X4d)
[19:17:21][V][modbus:042]: Modbus received Byte  255 (0Xff)
[19:17:21][V][modbus:042]: Modbus received Byte  93 (0X5d)
[19:17:21][V][modbus:042]: Modbus received Byte  255 (0Xff)
[19:17:21][V][modbus:042]: Modbus received Byte  0 (0X0)
[19:17:22][V][modbus:042]: Modbus received Byte  93 (0X5d)
[19:17:22][V][modbus:042]: Modbus received Byte  8 (0X8)
[19:17:22][V][modbus:042]: Modbus received Byte  93 (0X5d)

Additional information

The problem Hey, i am using a ESP32-C with an MAX485 converter. I want to read the existing modbus communication between my heat pump and its controller. I am trying to reverse engineer the modbus protocol parameters as I do not have documentation on the modus implementation for my heat pump. I did find the modbus documentation for a similar heat pump that is using the same controller pcb (HiPlus5000-M by Megmeet.com)

This other modbus documentation specifies an 2400-8-E-1 connection:

Modbus protocal V2.0 1. Communication rules communication mode: Halfduplex asynchronous serial communication Baud rate: 2400bps Data bit: 8 bit, low bit first Parity: EVEN Start bit: 1BIT (low level) Stop bit: 1BIT (high level)

With ESPHome on HA I did get the ESP32 board working and I do see data in the debug logs but this data does not appear to be consistent with the modbus protocol one would expect. I did run some alternative settings with the results below Schermafbeelding 2024-04-22 om 19 27 22

ssieb commented 3 weeks ago

Github issues are not for support requests. Come ask on the esphome discord server or one of the forums.