syssi / esphome-smg-ii

ESPHome configuration to monitor and control a ISolar/EASUN SMG II inverter via RS232
Apache License 2.0
66 stars 12 forks source link

Easun SMW 11KW #72

Open Alexandros89 opened 1 month ago

Alexandros89 commented 1 month ago

hi, i'm using a k868 a6 board that have the rs232 port, i have connected to the inverter with his original cable. the firmware that i'm using is esphome with this configuration:

uart:
  - id: uart_0
    baud_rate: 9600
    debug:
    tx_pin: GPIO16
    rx_pin: GPIO17

modbus:
  - id: modbus0
    uart_id: uart_0
    send_wait_time: 200ms

modbus_controller:
  - id: smg0
    address: 0x01
    modbus_id: modbus0
    command_throttle: 200ms
    update_interval: 10s

and my output is this:

[11:17:05][D][uart_debug:114]: >>> 01:03:01:4B:00:07:75:E2
[11:17:05][D][uart_debug:114]: >>> 01:03:01:4B:00:07:75:E2
[11:17:05][D][uart_debug:114]: >>> 01:03:01:4B:00:07:75:E2
[11:17:05][D][uart_debug:114]: >>> 01:03:01:4B:00:07:75:E2
[11:17:05][D][modbus_controller:040]: Modbus command to device=1 register=0x14B countdown=0 no response received - removed from send queue
[11:17:05][D][uart_debug:114]: >>> 01:03:01:96:00:01:65:DA
[11:17:06][D][uart_debug:114]: >>> 01:03:01:96:00:01:65:DA
[11:17:06][D][uart_debug:114]: >>> 01:03:01:96:00:01:65:DA
[11:17:06][D][uart_debug:114]: >>> 01:03:01:96:00:01:65:DA
[11:17:06][D][uart_debug:114]: >>> 01:03:01:96:00:01:65:DA
[11:17:06][D][modbus_controller:040]: Modbus command to device=1 register=0x196 countdown=0 no response received - removed from send queue
[11:17:07][D][uart_debug:114]: >>> 01:03:00:64:00:02:85:D4
[11:17:07][D][uart_debug:114]: >>> 01:03:00:64:00:02:85:D4
[11:17:07][D][uart_debug:114]: >>> 01:03:00:64:00:02:85:D4
[11:17:07][D][uart_debug:114]: >>> 01:03:00:64:00:02:85:D4
[11:17:07][D][uart_debug:114]: >>> 01:03:00:64:00:02:85:D4
[11:17:08][D][modbus_controller:040]: Modbus command to device=1 register=0x64 countdown=0 no response received - removed from send queue
[11:17:08][D][uart_debug:114]: >>> 01:03:00:6C:00:02:04:16
[11:17:08][D][uart_debug:114]: >>> 01:03:00:6C:00:02:04:16
[11:17:08][D][uart_debug:114]: >>> 01:03:00:6C:00:02:04:16
[11:17:08][D][uart_debug:114]: >>> 01:03:00:6C:00:02:04:16
[11:17:09][D][uart_debug:114]: >>> 01:03:00:6C:00:02:04:16
[11:17:09][D][modbus_controller:040]: Modbus command to device=1 register=0x6C countdown=0 no response received - removed from send queue
[11:17:09][D][uart_debug:114]: >>> 01:03:00:C9:00:11:55:F8
[11:17:09][W][modbus_controller:183]: Duplicate modbus command found: type=0x3 address=201 count=17
[11:17:09][W][modbus_controller:183]: Duplicate modbus command found: type=0x3 address=219 count=2
[11:17:09][W][modbus_controller:183]: Duplicate modbus command found: type=0x3 address=223 count=5
[11:17:09][W][modbus_controller:183]: Duplicate modbus command found: type=0x3 address=229 count=1
[11:17:09][W][modbus_controller:183]: Duplicate modbus command found: type=0x3 address=232 count=3
[11:17:09][W][modbus_controller:183]: Duplicate modbus command found: type=0x3 address=300 count=4
[11:17:09][W][modbus_controller:183]: Duplicate modbus command found: type=0x3 address=420 count=1
[11:17:09][W][modbus_controller:183]: Duplicate modbus command found: type=0x3 address=643 count=1
[11:17:09][D][uart_debug:114]: >>> 01:03:00:C9:00:11:55:F8
[11:17:09][D][uart_debug:114]: >>> 01:03:00:C9:00:11:55:F8
[11:17:09][D][uart_debug:114]: >>> 01:03:00:C9:00:11:55:F8
[11:17:10][D][uart_debug:114]: >>> 01:03:00:C9:00:11:55:F8
[11:17:10][D][modbus_controller:040]: Modbus command to device=1 register=0xC9 countdown=0 no response received - removed from send queue
[11:17:10][D][uart_debug:114]: >>> 01:03:00:DB:00:02:B4:30
[11:17:10][D][uart_debug:114]: >>> 01:03:00:DB:00:02:B4:30
[11:17:10][D][uart_debug:114]: >>> 01:03:00:DB:00:02:B4:30
[11:17:11][D][uart_debug:114]: >>> 01:03:00:DB:00:02:B4:30
[11:17:11][D][uart_debug:114]: >>> 01:03:00:DB:00:02:B4:30
[11:17:11][D][modbus_controller:040]: Modbus command to device=1 register=0xDB countdown=0 no response received - removed from send queue
[11:17:11][D][uart_debug:114]: >>> 01:03:00:DF:00:05:B4:33
[11:17:11][D][uart_debug:114]: >>> 01:03:00:DF:00:05:B4:33
[11:17:11][D][uart_debug:114]: >>> 01:03:00:DF:00:05:B4:33
[11:17:12][D][uart_debug:114]: >>> 01:03:00:DF:00:05:B4:33
[11:17:12][D][uart_debug:114]: >>> 01:03:00:DF:00:05:B4:33
[11:17:12][D][modbus_controller:040]: Modbus command to device=1 register=0xDF countdown=0 no response received - removed from send queue
[11:17:12][D][uart_debug:114]: >>> 01:03:00:E5:00:01:95:FD
[11:17:12][D][uart_debug:114]: >>> 01:03:00:E5:00:01:95:FD
[11:17:13][D][uart_debug:114]: >>> 01:03:00:E5:00:01:95:FD
[11:17:13][D][uart_debug:114]: >>> 01:03:00:E5:00:01:95:FD
[11:17:13][D][uart_debug:114]: >>> 01:03:00:E5:00:01:95:FD
[11:17:13][D][modbus_controller:040]: Modbus command to device=1 register=0xE5 countdown=0 no response received - removed from send queue
[11:17:13][D][uart_debug:114]: >>> 01:03:00:E8:00:03:85:FF
[11:17:13][D][uart_debug:114]: >>> 01:03:00:E8:00:03:85:FF
[11:17:14][D][uart_debug:114]: >>> 01:03:00:E8:00:03:85:FF
[11:17:14][D][uart_debug:114]: >>> 01:03:00:E8:00:03:85:FF
[11:17:14][D][uart_debug:114]: >>> 01:03:00:E8:00:03:85:FF
[11:17:14][D][modbus_controller:040]: Modbus command to device=1 register=0xE8 countdown=0 no response received - removed from send queue
[11:17:14][D][uart_debug:114]: >>> 01:03:01:2C:00:04:84:3C
[11:17:14][D][uart_debug:114]: >>> 01:03:01:2C:00:04:84:3C
[11:17:15][D][uart_debug:114]: >>> 01:03:01:2C:00:04:84:3C
[11:17:15][D][uart_debug:114]: >>> 01:03:01:2C:00:04:84:3C
[11:17:15][D][uart_debug:114]: >>> 01:03:01:2C:00:04:84:3C
[11:17:15][D][modbus_controller:040]: Modbus command to device=1 register=0x12C countdown=0 no response received - removed from send queue
[11:17:15][D][uart_debug:114]: >>> 01:03:01:A4:00:01:C4:15
[11:17:16][D][uart_debug:114]: >>> 01:03:01:A4:00:01:C4:15
[11:17:16][D][uart_debug:114]: >>> 01:03:01:A4:00:01:C4:15
[11:17:16][D][uart_debug:114]: >>> 01:03:01:A4:00:01:C4:15
[11:17:16][D][uart_debug:114]: >>> 01:03:01:A4:00:01:C4:15
[11:17:16][D][modbus_controller:040]: Modbus command to device=1 register=0x1A4 countdown=0 no response received - removed from send queue
[11:17:16][D][uart_debug:114]: >>> 01:03:02:83:00:01:74:5A
[11:17:17][D][uart_debug:114]: >>> 01:03:02:83:00:01:74:5A
[11:17:17][D][uart_debug:114]: >>> 01:03:02:83:00:01:74:5A
[11:17:17][D][uart_debug:114]: >>> 01:03:02:83:00:01:74:5A
[11:17:17][D][uart_debug:114]: >>> 01:03:02:83:00:01:74:5A

but on home assistant i don't read anithyng.

syssi commented 1 month ago

This prefix (>>>) indicates outgoing traffic / requests. Your log doesn't show any responses (<<<). In other words: Your inverter does respond. Please double check your wiring and RS232 converter.

syssi commented 1 month ago

Do you know anything about the supported protocols of your inverter?

Alexandros89 commented 1 month ago

IMG_20240920_130635.jpg

I think that the cable shouldn't have problem.

I have asked the seller if he send me the modbus protocol

syssi commented 1 month ago

Why is a gender changer required if you use the original cable? Could you provide photos of the complete setup (Inverter<->RS232 converter<->ESP).

Alexandros89 commented 1 month ago

This is the board IMG_20240920_133524.jpg

This is the original cable IMG_20240920_133504.jpg

IMG_20240920_133511.jpg

The board has natively rs232 port

syssi commented 1 month ago

I've checked the description of the k868 a6 board:

esp32-kc868-a6

rs232

Using GPIO16 and GPIO17 looks good but I guess it doesn't work because RX & TX are swapped because of the wrong gender of the connector.

Alexandros89 commented 1 month ago

In fact I use this board for this reason. I have checked before to use. I have documented. I have try also to exchange on esphome the gpio but the result is the same. I will check the cable with the multimeter to understand the pin.

syssi commented 1 month ago

Swapping the GPIOs at the YAML won't work because the GPIOs are attached to the MAX3232 which has dedicated input and output pins. Do you remember the 0-modem cable from the 90s? ;-) This adapter did cross the RX/TX lines of a serial cable. Connecting two PCs using a RS232 cable + a gender changer won't work too.

Alexandros89 commented 1 month ago

In fact initially I was looking to use a old serial cable but some days ago I wasted all old cable :-( I can change the rj45 cable and crimp newer exchanging the cable 1 and 2?

syssi commented 1 month ago

I can change the rj45 cable and crimp newer exchanging the cable 1 and 2?

Please measure the lines first but I guess this would solve the issue.

Alexandros89 commented 1 month ago

I have tried this IMG_20240920_195125.jpg

IMG_20240920_195143.jpg

But I don't see anything

syssi commented 1 month ago

Could you try the PIP protocol as next step? F.e. using this YAML: https://github.com/syssi/esphome-pipsolar/blob/main/tests/esp8266-test-protocols.yaml

Do you have another ESP + RS232 converter so we could verify the setup is working in general?

Alexandros89 commented 1 month ago

IMG_20240920_215059.jpg

IMG_20240920_214625.jpg

IMG_20240920_215040.jpg

Seems that the inverter doesn't respond

syssi commented 1 month ago

Did you try to swap the GPIOs another time?

syssi commented 1 month ago

Could you bridge the TX to the RX pin of the DSUB connector and test using this loopback? Do you see the outgoing traffic as incoming traffic?

Alexandros89 commented 1 month ago

Yes, I have tried. Now I tried also to connect the rs485 of the inverter to the board but the result is the same

Alexandros89 commented 1 month ago

Screenshot_2024-09-20-22-52-23-263_io.homeassistant.companion.android.jpg

This is the log with the bridge and the dummy receiver and log both directions

Alexandros89 commented 1 month ago

I have done the bridge in this way IMG_20240921_062921.jpg

syssi commented 1 month ago

There is still no incoming traffic. Something is wrong with your setup. Did you try to swap the GPIOs assigned to the UART another time?

syssi commented 1 month ago

Feel free to ask more questions if something isn't clear yet.

Alexandros89 commented 1 month ago

I try to swap this morning without any good result. This evening searching at home I find 3 serial cable. Tomorrow I will try : Check the serial communication from the inverter, I will connect to the pc and open a serial terminal and look if it send any value Check the rs232 of the board with an original cable. I think that the wires inside the db9 pinout doesn't make good contact

syssi commented 1 month ago

I try to make some findings explicit to provide some guidance. Your ESP32+RS232 board doesn't work as expected at the moment. If you bridge TX and RX we should receive an echo (<<<) of every outgoing frame (>>>). Some ideas what needs to be checked:

  1. Please test the continuity between the DB9 pins (TXD (p2), RXD (p3), GND? (p5)) and the MAX3232 (R1OUT(p12) T1IN` (p11)).
  2. Test the continuity of the logic level signals of the MAX3232 (R1IN (p13), T1OUT (p14)) and GPIO16 + GPIO17.
  3. Power the k868 a6 board and measure the voltage between the DB9 pin2 (TXD) and pin5 (GND).
Alexandros89 commented 1 month ago

IMG_20240922_153637.jpg

I have check with the multimeter. If on the 3232 chip I bridge 13 and 14 pin I see on the log some code received. If I bridge the 11 an 12, I don't see anything in the log

syssi commented 1 month ago

max3232

Could you show your log? Your observation seems not logic.

Alexandros89 commented 1 month ago

With this bridge

IMG_20240922_160510.jpg I have this log

Screenshot_2024-09-22-16-04-56-335_io.homeassistant.companion.android.jpg


With this bridge

IMG_20240922_160551.jpg

I have this log

Screenshot_2024-09-22-16-05-43-084_io.homeassistant.companion.android.jpg

syssi commented 1 month ago

Okay. This makes more sense. In other words: If we bridge GPIO16 and GPIO17 directly (at logical level = 3.3V) the loopback works fine. The uart of your ESP32 works in general. The MAX3232 transforms the signal from logical level 3.3V to the RS232 voltage level of -12/+12V. If we bridge the RS232 TXD/RXD pins the loopback doesn't work.

As next step we have to make sure your MAX3232 is properly powered. Could you measure the voltage between pin 15 and 16? And could you measure the voltage between the RS232 TXD/RXD pins and GND (p13<->GND, p14<->GND)?

Alexandros89 commented 1 month ago

IMG_20240922_164324.jpg

These are the voltages

Alexandros89 commented 1 month ago

I have found an old rs232 module that I have used when I was very young. IMG_20240922_170325.jpg

I connect it and this is the log Screenshot_2024-09-22-17-03-43-552_io.homeassistant.companion.android.jpg

It works. Then the problem is the rs232 module of the board

Alexandros89 commented 1 month ago

Connecting this module ![Uploading IMG_20240922_173210.jpg …]() I have this output

Screenshot_2024-09-22-17-31-10-341_io.homeassistant.companion.android.jpg

syssi commented 1 month ago

This garbage happens most of the time if GND isn't connected properly.

Alexandros89 commented 1 month ago

Ok now I check better

Alexandros89 commented 1 month ago

Screenshot_2024-09-22-20-20-22-835_io.homeassistant.companion.android.jpg

I read this

syssi commented 1 month ago

This looks like garbage only. Please share plaintext logs instead of screenshots!

What are you doing exactly at the moment?

Alexandros89 commented 1 month ago

Hi, I want to tell you that I'm talking with kincony to test the rs232 port. Probably is my board with a problem