logo elektroda
logo elektroda
X
logo elektroda

Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]

starob 99243 318
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #211 20130871
    spin722
    Level 9  
    Modbus TCP, as usual, will use port 502. Therefore, packets will not go through port 8899 to the inverter. But better check it out.

    I set the SOFAR 60000TL inverter power via RS485 port, Modbus RTU protocol. I hope this will be important for other SofarSolar inverters. For example, you need to set the power to 57%. Therefore, you send to port 01 06 90 00 39 D9 77 (hex meaning).

    Here 01 - ID (Modbus address) of the inverter 06 - function number 90 00 - starting register 00 39 - power meaning (57 dec = 39 hex) Power unit here 1%. 100% corresponds to 64 hex D9 77 - CRC (check sum)

    You can submit a different package for yourself, CRC can be counted online https://www.lammertbies.nl/comm/info/crc-calculation Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]

    CRC in Sofar go Lo byte, Hi byte - not standard. Therefore, the bytes in the counted CRC must be changed by place.
  • ADVERTISEMENT
  • #212 20130897
    starob
    Level 29  
    spin722 wrote:
    Therefore, packets to the inverter will not go through port 8899.


    .. and how are the inquiries going now? ;) Pure Modbus frames also pass through LWS3, additionally dressed with other data, the port is a conventional thing and in most cases configurable.

    As for the rest, I agree - first the method should be tested after the "cable". Another thing is that probably no one will risk experimenting with changing the settings on a working, only and not cheap device.
  • #213 20130910
    spin722
    Level 9  
    starob wrote:
    how are the inquiries now? Pure Modbus frames are also flowing through LWS3

    Unfortunately, I don't have an LWS3 logger. So I can't check how it works.
    In my case, the logger works as a separate device. First, it reads the data from the inverters. Then it sends them to the server. The logger-inverter system works autonomously, without a computer.
  • #214 20136148
    przemek219
    Level 11  
    Hello, I will ask a question if anyone has tried through lodger lws-3 by connecting two sofar inverters via rs485 to read data to solarman pc because lws 3 always reads from address 01
  • #215 20139208
    Emi_B
    Level 9  
    przemek219 wrote:
    Hello, I will ask a question if anyone has tried through lodger lws-3 by connecting two sofar inverters via rs485 to read data to solarman pc because lws 3 always reads from address 01


    That's right, it always reads one device, according to the specifications:

    https://www.solarman.cn/enproinfo_2.html

    "No. of Connections: One"

    For reading more than one device, the manufacturer has provided other models:

    https://www.solarman.cn/enproinfo_3.html

    "No. of Connections: 10, 32"

    https://www.solarman.cn/enproinfo_1.html

    "No. of Connections: 1-128"

    and:

    https://www.solarman.cn/enproinfo_4.html

    "No. of Connections: 1-16, 1-10, 1-20"
  • #216 20140769
    mariuszml
    Level 12  
    spin722 wrote:
    Modbus TCP, as usual, will use port 502. Therefore, packets will not go through port 8899 to the inverter. But better check it out.

    I set the SOFAR 60000TL inverter power via RS485 port, Modbus RTU protocol. I hope this will be important for other SofarSolar inverters.
    For example, you need to set the power to 57%. Therefore, you send to port 01 06 90 00 39 D9 77 (hex meaning).

    Here
    01 - ID (Modbus address) of the inverter
    06 - function number
    90 00 - starting register
    00 39 - power meaning (57 dec = 39 hex) Power unit here 1%. 100% corresponds to 64 hex
    D9 77 - CRC (check sum)

    You can submit a different package for yourself, CRC can be counted online https://www.lammertbies.nl/comm/info/crc-calculation
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]

    CRC in Sofar go Lo byte, Hi byte - not standard. Therefore, the bytes in the counted CRC must be changed by place.


    I checked functions 03, 04, 06 - only function 03 works through LSW3, i.e. reading, it is possible to set "Starting Address" and "Number of Registers" in accordance with the MODBUS specification and download data, i.e. the conclusion is simple - LSW3 implements functions other than 03 (realtime data) is simply blocked*.

    For example, when implementing the "example" function 01 04 20 00 00 10 FA 06 (downloading the serial and soft/hard version), the connection is correct, there is an answer, but with an empty frame characteristic for LSW3:



    A similar frame of the same length returns at function 06 with no power reduction effect.

    *possibly there is a "secret way" that we will find out about in the event of a regular war with China, when a lot of Sofars around the world turn off in one day ;)
  • #217 20141029
    spin722
    Level 9  
    mariuszml wrote:
    there is an answer but with an empty frame characteristic of LSW3:


    I don't understand what this information is. He's never met one. How did he read it?

    My inverter responds normally to functions 0x04. You always get an answer to the logger's query 01 04 20 00 00 10 FA 06 (for example 01 04 20 00 0D 5A 4A 31 45 53 32 36 30 4A 37 44 31 32 33 56 31 35 30 56 31 000 30 00 00 00 00 4F FD).
    But I ask/read via RS485. Maybe you don't get an answer because the logger does something wrong for this function?

    To check it thoroughly, I would first check how it works via RS485, without a logger. Maybe the logger just blocks the request with a number other than 0x03.
  • #218 20141067
    mariuszml
    Level 12  
    Because you read via RS485. LSW3 has its own "protocol" which is not fully figured out.
    A regular MODBUS request (logger request) is wrapped in a wider frame, and so are the responses.

    Quote:
    How did he read it?
    TCP request sent to the logger IP address, port 8899

    link
    link

    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]
  • #219 20141095
    przemek219
    Level 11  
    I have a question from such a barrel, is it possible to change the reading address of the inverter because it is factory set to 01 and I need to set it to 02
  • ADVERTISEMENT
  • #220 20141102
    mariuszml
    Level 12  
    If the question is about Sofar, you should be able to do it in the menu:
    1: Enter Settings:
    - 9:Set Modbus Address
    But whether the LSW3 will read this address or will it read at address 01 all the time, it would have to be checked.
  • #221 20141109
    przemek219
    Level 11  
    no I know it doesn't read only reads from address 01
  • #222 20141117
    mariuszml
    Level 12  
    The logger has a dedicated connector in the inverter, as a rule it is for a single device, so it is possible that it is "constant" and setting a different address has an effect only for the (separate) RS485 connector. In fact, it can be.
  • #223 20141271
    Emi_B
    Level 9  
    mariuszml wrote:
    The logger has a dedicated connector in the inverter, as a rule, it is for a single device, so it is possible that it is "constant" and setting a different address only affects the (separate) RS485 connector. In fact, it can be.


    Unfortunately, this is not the case with most inverters. For example, in Sofar a "dedicated connector" in the form of a DB9 connector is nothing more than RS232 with a voltage above 5V on one of the pins. After all, you have to power the logger somehow. The inverter can have any ID set, but the original LSE/LSW software only queries the device with ID=1.
    Use a different logger and you will ask for a different ID.
  • #224 20141869
    Emi_B
    Level 9  
    Michalux wrote:
    Emi_B wrote:
    starob wrote:
    Emi_B wrote:
    Does it matter that it's not LSW (wifi) but LSE (ethernet)?

    Doesn't matter.
    Maybe it's a network problem if it doesn't read the whole frame?
    In solarman do you get good readings?


    The problem with the network (range) would be on LSW, because the installation is far from the building. Hence the change to a twisted-pair version of the logger.
    So no, there are no network problems:

    11 packets transmitted, 11 packets received, 0.0% packet loss
    round-trip min/avg/max/stddev = 2.362/3.044/4.197/0.499ms

    In solarman all readings are OK:
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]
    And yet it shows an error:
    Code: Bash
    Log in, to see the code

    This is generally the most common effect of incorrect register numbers that we are trying to read.
    Try to change them based on, for example, the documentation I attached today (if you don't know how, write to priv).
    To do this, you need to change the numbers in SOFARMap.xml and modify the pini and pfin variables in the script (to the range of registers - after conversion from hex to dec) (initially, just change pini/pfin to see if the response from the logger/inverter is extends or not).


    The matter cleared up with the replacement of this particular LSE with another. Now everything is read correctly without changing registers:

    [code:1:735a202a30]Connecting to logger... connected successfully !
    *** Chunk no: 0
    Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00\xa3\x98[}\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15')
    Received data: b'\xa5c\x00\x10\x15\x00\x12\xa3\x98[}\x02\x01C\x05\x00\x00h\x03\x00\x00\x1d\x9a\xf7b\x01\x03P\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x1f\x00\\\x11\xcb\x00T\x00+\x00&\x00L\x00>\x13\x89\tD\x00\x8e\tf\x00\x8c\t0\x00\x8a\x00\x00_\xf0\x00\x00*(\x06=\x02\r\x00"\x002\x19\x86\x12\x12\x11\xb8\x00
  • ADVERTISEMENT
  • #225 20168482
    pabelo76
    Level 12  
    Hello
    I am looking for a pinout of the connector in LSW-3, does anyone have it?
  • #226 20168878
    spin722
    Level 9  
    pabelo76 wrote:
    Hello
    I am looking for a pinout of the connector in Lsw-3, does anyone have it?

    I think it's just a COM-port, standard RS232.
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]
    You can check it. Needed to measure the voltage between pins 2-5, 3-5. Must be something around -5...12 and 5...12 volts.
  • #227 20168884
    starob
    Level 29  
    spin722 wrote:
    I think it's just a COM-port, standard RS232.

    You're wrong. It's definitely RS485, note that it also supplies power to the module.
    I had a pinout somewhere that I can't find. hold on.
  • #228 20168888
    spin722
    Level 9  
    starob wrote:
    spin722 wrote:
    I think it's just a COM-port, standard RS232.

    You're wrong. It's definitely RS485, note that it also supplies power to the module.
    I had a pinout somewhere that I can't find. hold on.

    There is no RS485 in the LSW-3.
    See LSW-3 technical specifications in the datasheet https://www.sofarsolar.com/product-detail/499/Stick-Logger
    "Data interface - RS232"
  • ADVERTISEMENT
  • #229 20168910
    starob
    Level 29  
    Do not look at what LSW has, only the inverter.
    The data shows that LSW has it all ;)
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]
  • #230 20169871
    xury
    Automation specialist
    What a problem to check. Connect the USB-RS232 cable, configure the baud rate and try to read a modbus register using e.g. Radzio modbus master simulator.
  • #231 20196592
    xury
    Automation specialist
    spin722 wrote:
    Modbus TCP, as usual, will use port 502. Therefore, packets will not go through port 8899 to the inverter. But better check it out.

    I set the SOFAR 60000TL inverter power via RS485 port, Modbus RTU protocol. I hope this will be important for other SofarSolar inverters.
    For example, you need to set the power to 57%. Therefore, you send to port 01 06 90 00 39 D9 77 (hex meaning).

    Here
    01 - ID (Modbus address) of the inverter
    06 - function number
    90 00 - starting register
    00 39 - power meaning (57 dec = 39 hex) Power unit here 1%. 100% corresponds to 64 hex
    D9 77 - CRC (check sum)

    You can submit a different package for yourself, CRC can be counted online https://www.lammertbies.nl/comm/info/crc-calculation
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]

    CRC in Sofar go Lo byte, Hi byte - not standard. Therefore, the bytes in the counted CRC must be changed by place.

    Is this CRC correct for this. I do not want to leave D9 77
    It always comes out as pictured. Nodered counts the same.
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]

    Added after 5 [minutes]:

    And I already know. you counted
    01 06 90 00 39
    and according to the protocol it should be:
    01 06 90 00 00 39
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]
    The question is anyone know how to save custom FC 0x13 parameters?
  • #232 20197089
    spin722
    Level 9  
    Quote:
    And I already know. you counted
    01 06 90 00 39
    and according to the protocol it should be:
    01 06 90 00 00 39
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]
    The question is anyone know how to save custom FC 0x13 parameters?


    I'm sorry for my mistake.

    A few weeks ago I saw that one inverter did not start automatically after the error was removed. I found that registers 1009-100B are zero. Other inverters have different information. It must have changed the meanings of the registry, He wrote that by FC 13.

    B7 9F
  • #233 20197333
    xury
    Automation specialist
    I made an RS485-TCP bridge on ESP8266 and read the registers using NodeRed-contrib-modbus:
    So what the inverter gives me is directed to the TCP port, and what goes to this port goes through the UART and the RS485 converter to the inverter. I used the scheme:
    https://github.com/pawelka/sofarsolar_esp_rs485_logger except that I didn't use any of the solutions proposed by him, but I used Tasmota as serialbridge https://tasmota.github.io/docs/Serial-to-TCP-Bridge/
    As Tx and Rx pins I used D6 and D7 on hardware pins it didn't want to work well.
    One small note, this won't work on a compiled Tasmot, you need to compile your own with the Serialbridge option enabled. I can provide the binary if anyone needs it.
    Sometimes I have timeouts but generally reading is ok. Especially standard FC 3 registers.
    Attached is a picture of reading other registers that I managed to discover in my 4.4 KTL-X G2
    And a complete flow to NodeRed.
    When reading via cable, you need to set modbus-rtu in settings
    I use a combined RTU to TCP transition Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]
    Disabled first Inject gives us exactly the same values as the wifi loger.
    The only thing I can't do is write and read registers under non-standard function codes like 0x13 0x40 0x60 etc.
    Attention, an error has crept into the power control flow and instead of 100% it is 30%.
    You need to change the value from 30 to 100 in inject node.
  • #234 20197401
    spin722
    Level 9  
    xury wrote:
    I made an RS485-TCP bridge on ESP8266 and read the registers using NodeRed-contrib-modbus:
    So what the inverter gives me is directed to the TCP port, and what goes to this port goes through the UART and the RS485 converter to the inverter.

    I use a USB-RS485 converter
    Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]
    I normally read on the computer. I write the same through this converter.
  • #235 20197520
    xury
    Automation specialist
    I made a mistake in Node which sets the power to 100%. It should be 100 instead of 30.
  • #236 20209519
    ilex
    Level 11  
    Hello. I am looking for instructions on how to replace the lsw-3 logger with lse-3. For some time I have had a lot of problems with reading data from the logger over wifi. https://github.com/MichaluxPL/Sofar_LSW3/issues/46 Will all logger statistics disappear after replacing the logger? This is not a particular problem for me because I have them all in my Domoticz. Regards.
  • #237 20210057
    Emi_B
    Level 9  
    ilex wrote:
    Hello. I am looking for instructions on how to replace the lsw-3 logger with lse-3. For some time I have had a lot of problems with reading data from the logger over wifi. https://github.com/MichaluxPL/Sofar_LSW3/issues/46 Will all logger statistics disappear after replacing the logger? This is not a particular problem for me because I have them all in my Domoticz. Regards.


    Normally, you physically exchange at the inverter and add a new logger to the portal and make it active. All stats stay.
  • #238 20210060
    ilex
    Level 11  
    Emi_B wrote:
    ilex wrote:
    Hello. I am looking for instructions on how to replace the lsw-3 logger with lse-3. For some time I have had a lot of problems with reading data from the logger over wifi. https://github.com/MichaluxPL/Sofar_LSW3/issues/46 Will all logger statistics disappear after replacing the logger? This is not a particular problem for me because I have them all in my Domoticz. Regards.


    Normally, you physically exchange at the inverter and add a new logger to the portal and make it active. All stats stay.


    Thanks for the info, I'm working tomorrow :)
  • #239 20217506
    ilex
    Level 11  
    Zamontowałem LSE-3. Inwerter widzi, przesyła dane do SOLARMAN niestety odczyt danych bezpośrednio z loggera nie działa.

    Próba odczytu danych daje następujący wynik:

    root@domoticz:/opt/domoticz/userdata/scripts/sofar# python3 InverterHWData.py
    Modbus request: 0104 2000 000e 7a0e
    Hex string to send: A5 1700 1045 0000 7c5b657d 020000000000000000000000000000 01042000000e7a0e 00 15
    Data sent: bytearray(b'xa5x17x00x10Ex00x00|[e}x02x00x00x00x00x00x00x00x00x00x00x00x00x00x00x01x04 x00x00x0ezx0ex00x15')
    Data received: b'xa5x17x00x10Ex03x00xfcx02'
    Hex string received: A5 17 00 10 45 03 00 FC 02
    Traceback (most recent call last):
    File "InverterHWData.py", line 121, in
    val1=chr(int(str(responsereg[0:2]),16))
    ValueError: invalid literal for int() with base 16: ''

    root@domoticz:/opt/domoticz/userdata/scripts/sofar# python3 InverterData.py
    Connecting to logger... connected successfully !
    *** Chunk no: 0
    Sent data: bytearray(b'xa5x17x00x10Ex00x00|[e}x02x00x00x00x00x00x00x00x00x00x00x00x00x00x00x01x03x00x00x00(Exd4x00x15')
    Received data: b'xa5x17x00x10Ex03x00xfcx02'
    No value in response for register 0x0000
    Check register start/end values in config.cfg

    Ktoś ma jakiś pomysł ?
  • #240 20217774
    starob
    Level 29  
    ilex wrote:
    Anyone have an idea?

    If it's Ktl-G3 or HYD, it has a different register addressing. Get the modbus register for your inverter and adjust config.cfg - if you have entered the login details correctly.

Topic summary

The discussion focuses on integrating the Sofar Solar KTL-X inverter with Domoticz via RS485 Modbus communication due to instability issues with the WiFi logger. Key technical details include the RS485 connection using RJ45 connectors with pins 2,3,4 shorted as A+ and pins 1,5,6 shorted as B-, and a communication speed of 9600 baud, 8 data bits, no parity, 1 stop bit (9600/8/N/1). Users shared experiences reversing RS485 wires to establish connection and scanning registers with various tools. The Sofar inverter’s Modbus register map is partially undocumented and varies by firmware and model, complicating integration. Solutions involve using ESP-based loggers (e.g., sofarsolar_esp_rs485_logger) that send data via MQTT to Domoticz or Node-RED, with some users developing Python plugins and Node-RED subflows for data parsing and visualization. Additional hardware like SDM72D-M or MEW-01 meters are used for accurate energy measurement and self-consumption calculation. Some users employ LAN controllers (e.g., TinyControl LK3.8) to aggregate Modbus data and forward via MQTT or HTTP. Challenges include handling different firmware versions (V4, V5 protocols), register addressing differences, and reading real-time inverter clock data, which appears unavailable. The community also discusses integrating other devices like Tauron meters and heat pumps, using MQTT brokers (e.g., Mosquitto), and visualization tools like Grafana and InfluxDB. The overall approach emphasizes custom, local data acquisition and processing to overcome limitations of official cloud services and proprietary protocols.
Summary generated by the language model.
ADVERTISEMENT