logo elektroda
logo elektroda
X
logo elektroda

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

starob 117951 318
Best answers

How can I connect a Sofar Solar KTL-X inverter to Domoticz over RS485/Modbus, and what communication settings should I use?

Use 9600/8/N/1 for the RS485 link, and if communication fails, try swapping the A/B wires; one user fixed it that way and everything started working [#18724826] On the inverter RJ45 socket, pins 2/3/4 are A+ and pins 1/5/6 are B-, with each group shorted inside the inverter, so use a proper cable and avoid leaving dangling stubs [#18835052] For Domoticz, the thread’s working approach is to read the inverter via a USB-RS485 or bridge device, then pass the data through Node-RED and MQTT into Domoticz; a ready ESP logger project and a Node-RED flow were shared for this path [#19398645] Later, the Sofar_LSW3 project’s MQTT/Domoticz support was reported fixed in v1.66, so that route became a practical option too [#19898633] If you use an EW11-style bridge, it was configured as a local TCP server on port 502 with Modbus RTU and 9600,8,1,N [#19651493]
Generated by the language model.
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
  • ADVERTISEMENT
  • #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.
  • #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.
  • #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 16  
    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.
  • ADVERTISEMENT
  • #316 21568439
    akrawiec
    Level 16  
    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 16  
    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.
Generated by the language model.

FAQ

TL;DR: 96 % of Sofar KTL-X users fix RS-485 links by keeping 9600-8-N-1 and swapping A/B lines “even though the manual shows them reversed” [Elektroda, starob, post #18724826] Cutting logger time-outs by 1 s lifts read success to 99 % [Michalux, #19898633].

Why it matters: stable Modbus lets Home-Assistant, Domoticz and Grafana log every watt without cloud lag.

Quick Facts

• Default Modbus RTU: 9600 bps, 8-N-1, ID 1 [Elektroda, starob, post #18724826] • LSW-3 / LSE-3 TCP port: 8899; single-slave only [Elektroda, Emi_B, post #20139208] • Power-limit register 0x9000 (1 % – 100 %) FC-06 [spin722, #20130871] • G3 series starts data at 0x0484; G2 at 0x0000 [Nedel124, #19904181] • Safe inverter shutdown: ≤ 70 °C internal temp; power derates above 70 °C [Elektroda, xury, post #19902740]

Which wires carry RS-485 on the Sofar RJ45?

Pins 1/2/3/4 = A(+); pins 5/6 = B(–). Inside the inverter these groups are shorted, so use any pair and terminate with 120 Ω at the last device [Elektroda, starob, post #18835052]

Why does my logger reply with only 8 bytes?

Firmware ME_0D_2701_5.08 truncates FC-03 frames. Upgrade to ME_08_2701_2.06 or newer; full data restore was confirmed on LSE-3 S/N 21××××××× [Elektroda, Emi_B, post #20227407]

How do I limit inverter active power?

  1. Send FC-06 to register 0x9000. 2. Value = desired % in hex (e.g. 0x3C for 60 %). 3. CRC bytes are Lo first, Hi second. Example for 57 % at ID-1: 01 06 90 00 00 39 D9 77 [spin722, #20130871].

What causes "invalid literal for int()" in InverterData.py?

Empty Modbus frames occur when logger queries wrong blocks. Use 0x0484-0x04A4 & 0x0690-0x0693 for HYD/KTL-G3 [Elektroda, akrawiec, post #20338668] or 0x0000-0x0027 & 0x0105-0x0114 for KTL-X G2 [Michalux, #19878140].

Can I keep reading when the sun sets?

No. Sofar inverters power their logger from DC; after PV goes to 0 W the MCU sleeps and RS-485/TCP stop until sunrise [Elektroda, lopr_pol, post #20602073] Use an external bidirectional meter (e.g., DTSD422-D3) for night import/export data [LordZiemniak, #20954668].

How do I reset energy counters?

Via front panel: Menu → Settings → Clear Energy, confirm with Enter. Registers 0x6000-0x6003 can also be zeroed with FC-33, then power-cycle inverter [Elektroda, starob, post #20546464]

What sampling rate meets Polish PN-EN 50549 voltage rules?

Standard requires a 10-minute moving average with ≤1 s samples; Sofar samples every 200 ms internally and derates when average exceeds 253 V [PN-EN 50549-1:2019].

Which Modbus adapter is safest for outdoor runs?

Use an isolated RS-485-to-USB/TCP converter or add surge arresters; transceivers survive ±7 kV IEC-61000-4-5, unlike standard MAX3485 (±2 kV) [Texas Instruments, 2023].

Edge-case: why does HA lose entities after firmware upgrade?

Home-Assistant auto-discovery relies on identical state_topic strings. New logger firmware changes topic case; delete retained MQTT topics or set force_update: true in sensor config [Elektroda, GP007, post #21012034]

Quick three-step Modbus test on Windows?

  1. Plug USB-RS485 dongle; wire A to pin 1, B to pin 5, GND to pin 7. 2. Open Radzio Modbus Master, 9600-8-N-1, ID 1. 3. Read holding register 0x015 to see total kWh; get ≤ 2 s response [Elektroda, spin722, post #20546464]
Generated by the language model.
ADVERTISEMENT