logo elektroda
logo elektroda
X
logo elektroda

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

starob 100524 318
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #301 21024302
    hYP
    Level 11  

    >>20993833

    Hey @LordZiemniak, can you share how you read the information from DTSD422-D3
  • ADVERTISEMENT
  • #302 21024329
    LordZiemniak
    Level 15  
    Sure, I figured it out in two ways - by integrating Modbus TCP in HA, or through ESPhome, physically through ESP32 and UART to TTL, which way are you interested in?
  • #303 21048965
    laciaty1990
    Level 14  
    Hi, I have a home assistant server, a Sofar 8.8ktl-x inverter (2g with a large screen) and an RS485toETH waveshare converter, I made a cable, connected everything, configured the converter. the stairs started when looking for any working integration. Either they are written for a Wi-Fi logger or for Modbus but ESP32 + UART converter. There is no integration for native modbus, I found one ("SolaX Inverter Modbus") but after selecting the sofar_old profile, the entities are terribly mixed up, and with other profiles it returns nothing. For me it works using RTUoverTCP, I`m trying to create the modbus.yaml file, in the worst case I would only need:
    energy produced today,
    current power,
    AC voltage on 3 phases
    and status (normal/gridOVP)

    using https://www.linuxiarz.pl/2323/sofarsolar-ktl-...-monitoring-twojej-fotowoltaiki/?noamp=mobile
    and
    https://www.home-assistant.io/integrations/modbus/

    I made something like this:
    https://paste.linuxiarz.pl/view/f5052273

    Could someone help me standardize these first few lines to make it work?
    Now, at most, from existing integrations I get the following crap:
    Screenshot of Home Assistant interface for Sofar inverter with reading data.
  • #305 21049061
    laciaty1990
    Level 14  
    Screenshot of configuration warnings for Home Assistant.
    and this? rather, there is a problem at the beginning
    Besides, I don`t want to use mqtt or nodeRed here
  • ADVERTISEMENT
  • #307 21049124
    laciaty1990
    Level 14  
    If you read my post, you would know that the first thing I looked at was the documentation.

    If you don`t know how to help me, it`s hard. I was hoping for some tips.
  • #308 21049138
    LordZiemniak
    Level 15  
    well, if you looked at the documentation, you would know that you did the configuration under ESP and you do it in HA
  • #309 21472070
    adrian512
    Level 11  
    Can anyone advise how to modify the power limit in sofar 11 ktlx g2 via modbus? I am trying to read the contents of register 912 (holding registers) but no response
  • #310 21473304
    xury
    Automation specialist
    Why such a register number? The power limitation in the KTLX G2 is done by writing 0x9000 to the register (FC6) The stored value is a percentage of power. That is, by writing 10 you set 10% of the power of your inverter.
  • ADVERTISEMENT
  • #311 21567878
    GP007
    Level 8  
    I have myself an InverterData.py script from MichaluxPL querying Sofar's LSW3 logger, it worked for more than 2 years without any problems, but since last Thursday the total production has turned negative....

    It looks more or less like this:

    [ 21 ] Total production : -32396 .
    [22 ] Total working time : 15114
    [23 ] Daily production : 55090
    [24 ] Today's operating time : 855
    [25 ] Module temperature : 35
    [26 ] Inverter temperature : 49
    [27 ] Inverter bus voltage : 640.2
    [28 ] PV1 voltage sampled by slave CPU : 437.8
    [29 ] PV1 current sampled by slave CPU : 456.8
    [30 ] Sampling time : 60
    [31 ] Alarm message : 0
    [32 ] Input mode : 1
    [33 ] Internal bus message : 0
    ....
    [42 ] String voltage 3 : 13.0
    [43 ] String 3 current : 0.0
    [44 ] String voltage 4 : -3239.6 .


    The production is growing properly every day, i.e. the values are getting less and less negative....
    On the display, website and in the Solarman app the total production is OK 33.14 MWh.
    I have not done any updates etc.
    Interestingly, the same figure (10 times less) is in the String 4 voltage position.

    What could have made this crazy?
  • #312 21568006
    xury
    Automation specialist
    An incorrect variable type is declared in the script. It should be unsigned and is signed.
  • ADVERTISEMENT
  • #313 21568198
    GP007
    Level 8  
    xury wrote:
    An incorrect variable type is declared in the script. It should be unsigned, and it is signed.


    Indeed, this could be a good clue, the value probably exceeded 2^16 and hence the circus.

    The only declaration I see there is:

    def twosComplement_hex(hexval, reg):
    if hexval=="" or (" " in hexval):
    print("No value in response for register " + reg)
    print("Check register start/end values in config.cfg")
    sys.exit(1)
    bits = 16
    val = int(hexval, 16)
    if val & (1 << (bits-1)):
    val -= 1 << bits
    return val
    .
    And how to change this to make it right?
  • #314 21568397
    akrawiec
    Level 15  
    comment this passage and check:
    #if val & (1 << (bits-1)):
    #val -= 1 << bits

    Only that other negative values will break.
    You have to write another function for UNSIGNED and call it for
    "Total Production"

    Added after 7 [minutes]:

    If it doesn't help, post the whole script on priv - I'll check with myself.
  • #316 21568439
    akrawiec
    Level 15  
    I tested the same one, once upon a time, but then there was little production yet.
    BTW, when it goes over 65,535 it will count from zero.
    I installed myself Home Assistant - there is a plug-in for Sofar and it works great, (reads about 140 parameters) but blocks access from other programs to LWS3.
  • #317 21584892
    adrian512
    Level 11  
    >>21473304 Thank you ;) And do you know how to limit the power in the g3?
  • #318 21585276
    adrian512
    Level 11  
    Maybe someone knows how to do a write in g3? I've been struggling a bit and reading works flawlessly, while writing 0x06 or 0x10 unfortunately fails. Connecting via COM input 1, 2, 3, 4 -.
  • #319 21586043
    akrawiec
    Level 15  
    adrian512 wrote:
    And do you know how to limit the power in the G3?
    .
    Write something more on priv (model, how you connect, what program) - will try to help
    I have a HYD 5KTL and have not practiced power limiting.

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