pawelka / sofarsolar_esp_rs485_logger

57 stars 21 forks source link

Check RS485 comunication #7

Closed cliffdude closed 2 years ago

cliffdude commented 3 years ago

Thank your work on this. Is there a way to test if the rs485 is working, and what would the baud rate be at the serial port to check comms with the uart to ttl adapter? My setup: I have the ESP-07 and an aliexpress rs485 adapter like the one in the photo, my inverter is a little different as the connection is a terminal block type not rj45. When I reset the ESP-07 I get an rs485 symbol on the display of the inverter but it goes out after a short time and I get nothing over MQTT. I am not sure if my adapter is ok or if something is not correct with programming of the ESP. Web interface is working and I can configure the device, I can also connect to the telnet.

pawelka commented 3 years ago

You can try this minimal python test. There is a binary command that should read register from inverter.

import serial import binascii port = '/dev/tty.usbserial-14310' serial_comunication = serial.Serial(port, baudrate=57600, timeout=0.75) serial_comunication.write(b'\x01\x03\x00\x00\x00\x01\x84\x0a') answer = serial_comunication.read(255) serial_comunication.close() print binascii.hexlify(bytearray(answer))

cliffdude commented 3 years ago

Hi thank you for your help and sorry for the late reply. Do you mean run the code on the ESP-07 via telnet or would I need to connect to the inverter with a PC or Rpi in order to run the python code?

cliffdude commented 3 years ago

Update: I have tried connecting the ESP-07+rs485 to a USB to rs485 adapter on my computer and run some modbus software, I can see the RX light flash and the TX also flashes at the defined interval of 10s. I cannot however get a response from the inverter to the PC or to the ESP so it looks like the problem is the inverter or I am missing something? The RS485 logo on the inverter display now stays on when the ESP is plugged in and polling for data but I get no response or activity on the RX led. Model is a HYD-4000-ES so maybe things are not the same as the models listed here. I really wanted this to work!!

pawelka commented 3 years ago

There is huge chance that registers are different and request to retrieve data should be different. Have you seen other software/source code which support this inverter? You can link for analysis if any exists.

cliffdude commented 3 years ago

Yes that is the conclusion I came to as well although I could not diagnose it properly. I have an RS485 to RS232 that I tried to connect to a PC and read the registers without success. I think I just do not know enough about modbus to get it working. I have since found a solution on github "cmcgerty/Sofar2MQTT" this works well. Perhaps you can take a look and find out what is the difference.

pawelka commented 2 years ago

Try to use ESPHome approach, there is seamless integration with HA or Tasmota approach if you are not using HA.