dala318 / esphome-rego600

ESPHome custom integration for Reg600 heat-pumps
2 stars 0 forks source link

Rego638 send some information back correct one #5

Open S4ube opened 1 year ago

S4ube commented 1 year ago

I tested implementation with few rego sensors and get some feedback from heat pump but not correct ones. Here is log information from few minutes test round:

----- 8< -------------------- 8< ----------------------- 8< -------------- [20:24:32][D][rego:114]: Command to send: 810200040a0000000e [20:24:32][E][rego:138]: No response after 2 attempts [20:24:32][E][rego.sensor:022]: Could not update sensor Outdoor GT2 [20:24:32][I][rego:031]: Data received from UART outside request: 2483c0002404ffe09480f064105b00100010006072000000802000800022304a060000006400000010000000000014002420000204ce22383695023404b40004900c880014019affff6b3134000484220790000000 80000000002080200000242c628be054600608810026004c9402005d20002000040400 [20:24:36][I][rego:031]: Data received from UART outside request: 00000c64840000200000000000000020040026000000000000a20000002020204042000000002400604e0000000000000020620000000000002200200000a2ca000010202002000000000000900000000000000100 0000000000000000002000004426000000006000022f08000c840000800326b0000000 [20:24:39][D][rego:114]: Command to send: 810200037e0000007d [20:24:39][E][rego:138]: No response after 2 attempts [20:24:39][E][rego.binary_sensor:021]: Could not update binary sensor Compresor [20:24:41][D][rego:114]: Command to send: 810200037d0000007e [20:24:41][E][rego:138]: No response after 2 attempts [20:24:41][E][rego.binary_sensor:021]: Could not update binary sensor Ground loop pump P3 [20:24:41][I][rego:031]: Data received from UART outside request: 000020a01400220001000000022030107c04000010040000000c00040000002400000000640200040002110000000025640080000020021c620000222010205e808280a20400820000000000002f08800008808001 00a00000809a20909004000000040a089084040000080000000002008826ffad048c08 [20:24:41][D][rego:114]: Command to send: 81020004090000000d [20:24:41][E][rego:138]: No response after 2 attempts [20:24:41][E][rego.sensor:022]: Could not update sensor Radiator return GT1 [20:24:42][D][rego:114]: Command to send: 810200040a0000000e [20:24:42][E][rego:138]: No response after 2 attempts [20:24:42][E][rego.sensor:022]: Could not update sensor Outdoor GT2 [20:24:44][I][rego:031]: Data received from UART outside request: 0088000608900000000100030000848400205c2400600640000000a6263406266005000480028010818021245034200000800000000000248400002000403da08d0204001c1e7e84803bf02000040c981000000000 0085020200040000000040000000002000000020002424808000008000000024008210 [20:24:49][D][rego:114]: Command to send: 810200037e0000007d [20:24:49][E][rego:138]: No response after 2 attempts [20:24:49][E][rego.binary_sensor:021]: Could not update binary sensor Compresor [20:24:50][I][rego:031]: Data received from UART outside request: 7404010000940800202020a100010204808400600006000000000000000000000000042004800124008000000000001e010000100000000000002600002400248084000089000000f08b77b500000084d26a010002 01800000040000008000044020008500000000000014000000040420205c0014000000 [20:24:51][D][rego:114]: Command to send: 810200037d0000007e [20:24:51][E][rego:138]: No response after 2 attempts [20:24:51][E][rego.binary_sensor:021]: Could not update binary sensor Ground loop pump P3 [20:24:51][D][rego:114]: Command to send: 81020004090000000d [20:24:51][E][rego:138]: No response after 2 attempts [20:24:51][E][rego.sensor:022]: Could not update sensor Radiator return GT1 [20:24:52][D][rego:114]: Command to send: 810200040a0000000e [20:24:52][E][rego:138]: No response after 2 attempts [20:24:52][E][rego.sensor:022]: Could not update sensor Outdoor GT2 [20:24:54][I][rego:031]: Data received from UART outside request: 6429a00c200020006000002c20bdf9d932a220043626216090000a00000090000000002020263c211db1fc00000040a0a0c080c000260004800200004040000000020eb7a781666004901042001480039400640100 00000000040000020000000000000000000000000000200000000000240000c04c0000 [20:24:59][D][rego:114]: Command to send: 810200037e0000007d [20:24:59][D][rego:126]: Response received: 0080362000000020000000240000000080a0a0024000000000000000000000002082404c806490ae6e0280b080000000900000000000242400002040000040000181200000200004000000000000002460102004002000000000000080b00000 0002000000000000000000e282040000000000003000b21e [20:24:59][E][rego:144]: Response wrong size [20:24:59][E][rego.binary_sensor:021]: Could not update binary sensor Compresor [20:25:01][D][rego:114]: Command to send: 810200037d0000007e [20:25:01][E][rego:138]: No response after 2 attempts [20:25:01][E][rego.binary_sensor:021]: Could not update binary sensor Ground loop pump P3 [20:25:01][D][rego:114]: Command to send: 81020004090000000d [20:25:01][E][rego:138]: No response after 2 attempts [20:25:01][E][rego.sensor:022]: Could not update sensor Radiator return GT1 [20:25:02][D][rego:114]: Command to send: 810200040a0000000e [20:25:02][E][rego:138]: No response after 2 attempts [20:25:02][E][rego.sensor:022]: Could not update sensor Outdoor GT2 [20:25:02][I][rego:031]: Data received from UART outside request: 427d26002674800020000004240024002040040000000efe72410024200000006004002400200017202000001000000000000004222000640000000000040090000000000020000080668bfc34006024007000400a 20252000a062fe3ad00002061401003400080084824000000066be2600002024002280 ----- >8 -------------------- >8 ----------------------- >8 --------------

dala318 commented 1 year ago

Thanks! I forgot to ask you but could you also share your yaml-config, at least the uart and rego600 parts.

From the log I see two things:

Timing to wait for answer is wrong (Data received from UART outside request), that means that the sensor update has given up reading reply once the rego600 answers. Can be solved by increasing this setting in yaml read_delay: 10ms # Optional, delay to first reading of UART

The response data is too long, should be about the same length as the request. One cause of this is that the baude_rate is wrong (too high), resulting that every byte received is interpreted as 4 or 8 bytes.

dala318 commented 1 year ago

I received the last piece of HW for my own setup yesterday, now I just need to find a time-slot to solder them together. Then I can start debugging the communication part on my own as well.

S4ube commented 1 year ago

Thanks! I forgot to ask you but could you also share your yaml-config, at least the uart and rego600 parts.

From the log I see two things:

Timing to wait for answer is wrong (Data received from UART outside request), that means that the sensor update has given up reading reply once the rego600 answers. Can be solved by increasing this setting in yaml read_delay: 10ms # Optional, delay to first reading of UART

The response data is too long, should be about the same length as the request. One cause of this is that the baude_rate is wrong (too high), resulting that every byte received is interpreted as 4 or 8 bytes.

Yes I can test by setting that delay setting and let you know. Here is my yaml-config file as well attached.

There only 2 sensors and 2 binary-sensors activated for now in my yaml-config file. hmm cannot paste yaml as file, so here it is below added as text:

substitutions:
  devicename: rego600-reader
  friendly_devicename: "Rego600 reader"
  device_description: "Rego600 reader for heat-pump communication"

esphome:
  name: ${devicename}
  friendly_name: ${friendly_devicename}
  comment: "${device_description}"

# esp8266:
#   board: d1_mini

esp32:
  board: nodemcu-32s
  framework:
    type: arduino

# Enable logging
logger:
  level: DEBUG
  baud_rate: 0 # disable logging over uart

# Enable Home Assistant API
api:
  encryption:
    key: !secret encryption_key

ota:
  password: !secret ota_password
# Enable Home Assistant API

web_server:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  #use_address: bluetooth-beacon.local

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "ESP-REGO600"
    password: !secret fallback_password
  manual_ip:
    static_ip: 192.168.1.131
    gateway: 192.168.1.1
    subnet: 255.255.255.0
captive_portal:

external_components:
  - source: github://dala318/esphome-rego600
    #  - source: github://oxan/esphome-stream-server

uart:
  id: uart_bus
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 19200

#stream_server:
  #uart_id: uart_bus
  #port: 6638

rego600:
  uart_id: uart_bus
  id: rego600_hub

binary_sensor:
  - platform: rego600
    # rego600_id: rego600_hub  # Optional if only one hub
    name: Ground loop pump P3
    rego_variable: 0x01FD

  - platform: rego600
    name: Compresor
    rego_variable: 0x01FE

sensor:
  - platform: rego600
    name: Radiator return GT1
    rego_variable: 0x0209
    value_factor: 0.1
    unit_of_measurement: °C
    state_class: measurement
    accuracy_decimals: 1

  - platform: rego600
    name: Outdoor GT2
    rego_variable: 0x020A
    value_factor: 0.1
    unit_of_measurement: °C
    state_class: measurement
    accuracy_decimals: 1
S4ube commented 1 year ago

Hi,

I find out from my configuration that there was wrong values in rego_variable or they was from older rego600-rego635 models, so I changed 0x1FD --> 0x1FF (P3), 0x01FE --> 0x0200 (Compressor), 0x0209 --> 0x020B (GT1) and 0x020A --> 0x020C (GT2). Still did not help or after that did not get any response from heat pump.

I also wondering here exactly I need add that read_delay: 10ms under uart: or?

There something what I can still test as one think came my mind from years back that if cables are too long it not working anymore. Other one needs to be also still checked if I have wrong pins set up as TX and RX pins as I am using nodemcu-32s board.

Do you have some progress in your site?

dala318 commented 1 year ago

You should probably resort to finding hardware errors before trying optimizing timing in software. Except the register values which of course should be corrected and as you did.

Read_delay shall be set in the hub-config section. As it uses the below values as default I then suggest increasing read_delay to at lest 30ms. For debugging increasing the retry_attempts might be a better way as it will abort once a reply is received (regardless if wrong content) so that it does not block when not needed. Could also be good to add the log_all: true to get a few additinal printouts

rego600:
  uart_id: uart_bus
  log_all: true
  id: rego600_hub
  log_all: true     # Optional, print some more
  read_delay: 10ms  # Optional, delay to first reading of UART 
  retry_sleep: 20ms # Optional, delay between read attempts
  retry_attempts: 1 # Optional, number of read retry attempts
dala318 commented 1 year ago

I added a small flow-chart in the readme.md that maybe explains the 3 setting in the hub config section image

dala318 commented 1 year ago

Finally got my device up and running and I get a very similar behavior as you. My suspicion is with the Serial RX-buffer on the device. That the uart_->available() does not really report any data being available until buffer is "almost" full and it not being released as populated as the resonse from the heat-pump is not terminated by newline.

S4ube commented 1 year ago

Yes that is possible as I also tested with different esp-32 nodemcu board and not get any answer from heat-pump. Then I just tested that board to shortcut RX and TX to make sure that I was using correct GPIO's. I get sent values just fine back as response, so problem is not there...

dala318 commented 1 year ago

Have been doing some more troubleshooting and on my side it seem to be hardware related. Connected an oscilloscope to the RX and TX wires on both sides of the level converter and it look like I have a distorted echo on the RX side to what I send on TX. I'm now waiting for new parts to build something similar as http://rago600.sourceforge.net/#ESP instead of using a pre-built as https://www.sparkfun.com/products/12009

S4ube commented 1 year ago

Unfortunately I do not have oscilloscope, so It make harder to test... But I using exactly this configuration https://rago600.sourceforge.io/generic_com.gif and that is connected to NodeMCU ESP32. Other working solution (taloLogger) is using similar configuration but instead of nodemcu there is Raspberry PI2...

dala318 commented 11 months ago

With hardware connection according to https://forum.arduino.cc/t/serial-communication-via-optocouplers/686872/26 and this basic config I finally got some values (one sensor) back from the heat-pump.

external_components:
  - source: github://dala318/esphome-rego600

# logger:
#   baud_rate: 19200  # Only if not using UART0 for heat-pump com

uart:
  id: uart_bus
  tx_pin:
    number: GPIO17
  rx_pin:
    number: GPIO16
  baud_rate: 19200
  debug:
    direction: BOTH
    dummy_receiver: false

rego600:
  uart_id: uart_bus
  id: rego600_hub
  log_all: true
  read_delay: 20ms
  retry_sleep: 50ms
  retry_attempts: 10

binary_sensor:
  - platform: rego600
    name: Ground loop pump P3
    rego_variable: 0x01FD

sensor:
  - platform: rego600
    name: Radiator return GT1
    rego_variable: 0x0209
    value_factor: 0.1
    unit_of_measurement: °C
    state_class: measurement
    accuracy_decimals: 1

image

S4ube commented 11 months ago

@dala318 Thanks, I will try to test is as well again... What was component values what you used, exactly those ones in picture you pointed and which optocoupler you used? I have tried with ILD2 and MCT6...

atliant commented 11 months ago

I used the same optocouplers as in the Arduino forum post and used the yaml config posted by dala318. This established a working connection.

However for the most part i get the message "Response from wrong address". image

dala318 commented 11 months ago

@dala318 Thanks, I will try to test is as well again... What was component values what you used, exactly those ones in picture you pointed and which optocoupler you used? I have tried with ILD2 and MCT6...

I used the "EL817C DIP" variant from here https://nl.aliexpress.com/item/1005005322528693.html

dala318 commented 11 months ago

I used the same optocouplers as in the Arduino forum post and used the yaml config posted by dala318. This established a working connection.

However for the most part i get the message "Response from wrong address".

The "Wrong address" state is correct on those responses received on UART. On those sensor addresses requested the response should start with 0x01 (while you seem to get 0xC0)

By the way, what Rego version do you have? Mine is in the range Rego600-635, if yours is above that you should use different register addresses (https://rago600.sourceforge.io/).

atliant commented 11 months ago

I used the same optocouplers as in the Arduino forum post and used the yaml config posted by dala318. This established a working connection. However for the most part i get the message "Response from wrong address".

The "Wrong address" state is correct on those responses received on UART. On those sensor addresses requested the response should start with 0x01 (while you seem to get 0xC0)

By the way, what Rego version do you have? Mine is in the range Rego600-635, if yours is above that you should use different register addresses (https://rago600.sourceforge.io/).

It says "Rego 600, FW 3.05" on the box. The thing is that it receives correct answers sometimes.

[08:22:51][D][rego:052]: UART bus free to use [08:22:51][D][rego:115]: Command to send: 81020004090000000d [08:22:51][D][rego:134]: No response yet, sleeping 50ms and retrying [08:22:51][D][rego:134]: No response yet, sleeping 50ms and retrying

[08:22:51][D][rego:128]: Response received: 0100014243 [08:22:51][D][rego:168]: Response decoded to 194 [08:22:51][D][sensor:094]: 'Radiator return GT1': Sending state 19.40000 °C with 1 decimals of accuracy [08:22:51][W][component:204]: Component rego600.sensor took a long time for an operation (0.18 s). [08:22:51][W][component:205]: Components should block for at most 20-30ms.

[08:24:21][D][rego:052]: UART bus free to use [08:24:21][D][rego:115]: Command to send: 81020004090000000d [08:24:21][D][rego:134]: No response yet, sleeping 50ms and retrying [08:24:21][D][rego:134]: No response yet, sleeping 50ms and retrying

[08:24:21][D][rego:128]: Response received: c000014243 [08:24:21][E][rego:156]: Response from wrong address [08:24:21][E][rego.sensor:022]: Could not update sensor Radiator return GT1 [08:24:21][W][component:204]: Component rego600.sensor took a long time for an operation (0.17 s). [08:24:21][W][component:205]: Components should block for at most 20-30ms.

dala318 commented 11 months ago

That's weird. And in that case when you get 0xC0 the remaining data seem to be correct so don't expect it to be HW related and interference on the RX-line. But 0x01 is the expected address for these messages, even implemented so in openhab regoxxx binding

dala318 commented 11 months ago

But I suppose I could just add 0x0C as an ok address to receive response from as the remaining payload seem ok. image

atliant commented 11 months ago

I managed to find an hour to resolder the board yesterday, I also used a new cable to the Rego interface. The responses are much more stable now so my guess is that I messed up a solder connection somewhere.