logo elektroda
logo elektroda
X
logo elektroda

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

starob 125613 319
Best answers LABEL_AI_GENERATED

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]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #301 21024302
    hYP
    Level 11  
    Posts: 4
    Rate: 5

    >>20993833

    Hey @LordZiemniak, can you share how you read the information from DTSD422-D3
  • ADVERTISEMENT
  • #302 21024329
    LordZiemniak
    Level 15  
    Posts: 158
    Help: 8
    Rate: 51
    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?
  • RTU over TCP modbus.yaml for Sofar inverter

    #303 21048965
    laciaty1990
    Level 14  
    Posts: 189
    Help: 1
    Rate: 7
    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.
  • ADVERTISEMENT
  • #304 21049026
    LordZiemniak
    Level 15  
    Posts: 158
    Help: 8
    Rate: 51
    first of all, change the update time to 5s, because miracles happen in 1s
    take a look here https://forum.arturhome.pl/t/monitoring-sofar-solar-rs485/9251
    and check if your registers are correct,
    first, delete everything, put one register to read, one of which you are sure of the result and check if it works properly
  • #305 21049061
    laciaty1990
    Level 14  
    Posts: 189
    Help: 1
    Rate: 7
    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  
    Posts: 189
    Help: 1
    Rate: 7
    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  
    Posts: 158
    Help: 8
    Rate: 51
    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  
    Posts: 10
    Rate: 2
    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
    Posts: 7083
    Help: 878
    Rate: 1497
    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.
  • Negative total production from misread register scaling

    #311 21567878
    GP007
    Level 8  
    Posts: 16
    Rate: 7
    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
    Posts: 7083
    Help: 878
    Rate: 1497
    An incorrect variable type is declared in the script. It should be unsigned and is signed.
  • Signed 16-bit conversion may overflow above 2^16

    #313 21568198
    GP007
    Level 8  
    Posts: 16
    Rate: 7
    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  
    Posts: 165
    Help: 1
    Rate: 45
    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 16  
    Posts: 165
    Help: 1
    Rate: 45
    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.
  • ADVERTISEMENT
  • #317 21584892
    adrian512
    Level 11  
    Posts: 10
    Rate: 2
    >>21473304 Thank you ;) And do you know how to limit the power in the g3?
  • #318 21585276
    adrian512
    Level 11  
    Posts: 10
    Rate: 2
    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  
    Posts: 165
    Help: 1
    Rate: 45
    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.
  • Modbus write example for G3 inverter registers

    #320 21946829
    spin722
    Level 9  
    Posts: 27
    Rate: 9
    >>21585276 >>21584892
    To limit power in G3, you need to change register 0x1106 (Active_Power_Export_Limit). The register value is a percentage. Factory setting: 044Ch (1100 = 110.0%)

    Added after 22 [minutes]:

    adrian512 wrote:
    Does anyone know how to make a setting in the G3?


    I’ve figured it out. Today I was writing to a SOFAR 60KTLX-G3 (AZZURRO 3ph 60ktl-v3).

    The function number for writing is 10.
    For example, if you want to write to the inverter at function number 3 and change two registers: ConnectWaitTime and PowerUpSpeed, the starting register is 0800h.
    Set ConnectWaitTime to 60 seconds (003Ch)
    Set PowerUpSpeed to 15 (000Fh)

    It will look like this:
    03 10 08 00 00 02 04 00 3C 00 0F 1F DF (all in HEX)
    03 – inverter number
    10 – function number
    08 00 – start register
    00 02 – number of registers
    04 – number of bytes to write (00 3C 00 0F)
    00 3C – value of the first register
    00 0F – value of the second register
    1F DF – CRC checksum (low and high bytes)

    Once the data has been written correctly, you will receive a response from the inverter.

Topic summary

LABEL_AI_GENERATED
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.
AI summary based on the discussion. May contain errors.

FAQ LABEL_AI_GENERATED

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]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT