Reading data from Huawei inverter SUN 2000 (3KTL-10KTL) via modbus TCP and RTU

If you want you can make rules that send e-mail’s or send push messages when the inverter is giving an error.Then you can contact your installer.every installer does this without any effort, because the alarms come in automatically.I am planning to make this rules for error notification when i have some free time.
You can see the alarms with the modbus connection.normal state is 0 and error is 1
In my site map the alarms are visual.

Thanks for this critical information.

Test setup was on a crappy W10 2.5.2, now on a fresh installed RPI3b potential free setup; powerbank fueled, wifi and only usb-RS485 short wired 2 cm, not even 1 error.
Pushed it to the limit by increasing the poll freq to 1000 ms and all is running fine now!

@Rado1 for easy use I crammed all pollers under 1 serial brigde in the things file and added ‘reconnectAfterMillis=500’ to it

So it is running fine with the WLAN module?
If i read the docs the ‘reconnectAfterMillis=500’ is a TCP bridge parameter.
And we are using a serial bridge?
Does this parameter work on a serial bridge?
If you remove it do you get error’s?
Maybe I should also take a look at my cabling because I have not used a shielded cable.
Thanks for the tip i set all pollers under 1 serial bridge :grinning:

It’s not generally needed except in adverse environments e.g. heavy machinery. Twisted pair usually suffices, but much depends on the wiring route.and electrically noisy neighbours.
Do pay attention to RS485 termination.

A screaming WLAN antenna on 2 cm might be too close?

@Rado1 all is in place and both active. Embedded the usb-rs485 (allmost) in the COM-connector.

It might well be, you wouldn’t really expect 9600 serial to care, but RFI is weird.

Dropped the ‘reconnectAfterMillis=500’ without errors @ 1000 ms for all readings.
To be sure all detection is done correctly, unplugged a few seconds and got noticed in the log.

Bridge modbus:serial:slave100 [ port="/dev/ttyUSB0" ,id=1 , baud=9600, stopBits="1", parity="none",dataBits=8, encoding="rtu"]

Nice
I am going to replace my cable to the inverter with a shielded one and see what it gives. I can’t bring everything close to the inverter because I have multiple modbus modules on the RS485 bus.

I removed the timeBetweenTransactionsMillis= parameter from the tutorial it got in there because i used it for testing with my other DI and DO modbus modules.There is no need for it in reading out the inverter.

1 Like

Big thanks for this. Have a SUN2000-15KLT-M0 and modbus definitons are nearly the same (some modifications/additions on error and warning codes)

Two points:
The bigger Huawei inverters have DC input sockets which are internally connected e.g. 15KTL has PV1 - PV4, where PV1+PV2 and PV3+PV4 are in parallel. In this example PV1 and PV2 show the same voltage, but only PV1 is showing the current (PV2 current = 0)

Not sure about modbus binding, but when I change something the modbus is waiting the defined time updateUnchangedValuesEveryMillis until I get another reading of data. Also most of the time the first polling ends with an error (CRC, try 1 of 3,…) Afterwards everything runs smoothly. Maybe my wiring isnt professional enough?

Would need to know the “something” - something that you expect to change a register value on the device?
The intent of this parameter;
When 0, every poll reading a register will issue an update to Item.
When set to some value greater than your poll interval, if the poll data would not cause an Item change, the update is skipped until time expires.

(Note this old/new comparison is done before any transformation if I recall - it actually works on register value, not Item state)

Example:
poll every 5 seconds, updateUnchanged set to 6 seconds
first poll, read “xx”, update Item
second poll, read “xx”, no update due to updateUnchange
third poll, read “xx”, update Item (to same), timer starts over
fourth poll, read “yy”, immediate update as changed, timer starts over

Purpose is to reduce traffic on openHAB event bus, persistence thrashing about, etc.

Possibly. You can see this effect when floating lines pick up noise. Usual checks - twisted pair, termination. Less obvious check for bias (which your host RS485 adaptor normally takes care of)

But can also be due to too-short time from last transaction. Bit rare, as a minimum is set in Modbus specs and everyone should adhere to that. However, a sluggish/busy slave may not be able to respond that quick, so there is a serial parameter timeBetweenTransactionsMillis that you could try exending, say to 100 for a test.
Careful as this limits poll rate.

thx for the answer, but I think I have a basic problem --> modbus noob

Inverter Modbus KNX cable (twisted pair) to my shuttle pc DL10J (has a RS485 interface integrated so no idea about termination? how to do it or needed?)

I get data for a couple of minutes until this error shows up.
What I dont understand: after nearly exactly an hour I get live data and then again the errors below show up and data stops. Another hour later same thing

2020-06-22 11:04:03.589 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 7d 72 00 02 7c 7c

2020-06-22 11:04:03.593 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 6 bytes: ff 01 03 04 00 00 

2020-06-22 11:04:03.597 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException CRC Error in received frame: 6 bytes: ff 01 03 04 00 00 . Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@13fcf47 (unit id 1 & transaction 2). Serial parameters: SerialParameters@16f2065[portName=/dev/ttyS0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2020-06-22 11:04:03.602 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException CRC Error in received frame: 6 bytes: ff 01 03 04 00 00 . Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@13fcf47 (unit id 1 & transaction 2). Serial parameters: SerialParameters@16f2065[portName=/dev/ttyS0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2020-06-22 11:04:03.603 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@13a55f9[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=32114,length=2,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException CRC Error in received frame: 6 bytes: ff 01 03 04 00 00  [operation ID 19913118-9078-40cf-aa54-11d4000c7fbb]

2020-06-22 11:04:24.272 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 03 7d 10 00 08 5d a5

2020-06-22 11:04:24.274 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

2020-06-22 11:04:24.276 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@1584a05 (unit id 1 & transaction 41). Serial parameters: SerialParameters@16f2065[portName=/dev/ttyS0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2020-06-22 11:04:24.278 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@1584a05 (unit id 1 & transaction 41). Serial parameters: SerialParameters@16f2065[portName=/dev/ttyS0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2020-06-22 11:04:24.280 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@19f01b7[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=32016,length=8,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID 1d119faa-6835-4940-8576-0d0622953d5f]

used your things with small adjustments

Bridge modbus:serial:slave100 [ port="/dev/ttyS0" ,id=1 , baud=9600, stopBits="1.0", parity="none", dataBits=8, encoding="rtu", connectMaxTries=3, timeBetweenTransactionsMillis=50 ]{

Bridge poller slave101holding [ start=30073, length=10, refresh=10000, type="holding" ]{
        Thing data Rated_power                      [ readStart="30073", readValueType="uint32",readTransform="JS(divide1000.js)",updateUnchangedValuesEveryMillis="1800000" ] 
and so on

What openHAB sent over serial, a Modbus query

The response openHAB got, where an error was detected.
Of note - first byte FF, second byte 01. third byte 03
What we would expect to see in a response is a mirror of the first few bytes of the query … in this case 01 03
So it’s clear that noise or a glitch on the line has started the process of receiving bytes prematurely, inserting rubbish data in front of the real stuff.
FF is what you get from a glitch starting the UART, followed by normal idle line.

In short, yes the error here originates at your serial bus. If it seems periodic, it is most likely electrical noise picked upon the RS485 line. This wouldn’t be surprising near an inverter - lots of high current switching to generate noise.

Just written a spiel, won’t copy paste, latter part of this -

Hi,

This is a good explanation.

I am now connecthing my Huawei SUN2000L-3KTL type id 304 over TCP and have it working.

Only the transformation seems not to be working.
Is there somewhere more info on how to apply this and value the * .js files should be saved

regards
Ronny

People often forget to install the add-on transformation services.

The binding docs include examples of transformation

The general docs about transformation

The specific transformation doc about javascript

1 Like

Hi,
Thanks for the information.

I seems there is some delay when made changes to .things file before the are reflected to paperui

Bridge poller holding1 "HUAWEI inverter System" @ "sunpower" [ start=30070, length=14, refresh=100000, type="holding", timeBetweenTransactionsMillis=6000] 
{
    Thing data holding30070 "HUAWEI inverter adress 30070" @ "sunpower" [readStart="30070", readValueType="uint16", updateUnchangedValuesEveryMillis=5000000]
    Thing data holding30071 "HUAWEI inverter adress 30071" @ "sunpower" [readStart="30071", readValueType="uint16", updateUnchangedValuesEveryMillis=5000000]
    Thing data holding30072 "HUAWEI inverter adress 30072" @ "sunpower" [readStart="30072", readValueType="uint16", updateUnchangedValuesEveryMillis=5000000]
    Thing data holding30073 "HUAWEI inverter adress 30073" @ "sunpower" [readStart="30073", readValueType="uint32", readTransform="JS(divide1000.js)", updateUnchangedValuesEveryMillis=5000000]
    Thing data holding30075 "HUAWEI inverter adress 30075" @ "sunpower" [readStart="30075", readValueType="uint32", readTransform="JS(divide1000.js)", updateUnchangedValuesEveryMillis=5000000]
    Thing data holding30077 "HUAWEI inverter adress 30077" @ "sunpower" [readStart="30077", readValueType="uint32", readTransform="JS(divide1000.js)", updateUnchangedValuesEveryMillis=5000000]
    Thing data holding30079 "HUAWEI inverter adress 30079" @ "sunpower" [readStart="30079", readValueType="int32", readTransform="JS(divide1000.js)", updateUnchangedValuesEveryMillis=5000000]
    Thing data holding30081 "HUAWEI inverter adress 30081" @ "sunpower" [readStart="30081", readValueType="int32", readTransform="JS(divide1000.js)", updateUnchangedValuesEveryMillis=5000000]
}

Any idea why this is slow ?

Regards

Nope. Are we talking hours or minutes?

Editing Things files is a “legacy” technique really (even though it is more practical for us when dealing with Modbus, than PaperUI) and is not expected to be very “dynamic”.
Bear in mind that because of polling, the binding would need to cancel and stop scheduled independent poller jobs and build new ones to incorporate changes.
In particular, small edited changes to text Things (rather than wholesale additions and deletions) can be missed.
Standard advice is to restart the Modbus packages after editing, both to ensure new changes are picked up and old ones taken out.

It’s the openHAB framework that detects when a xxx.things file has been edited and needs working with. I believe it uses a file watcher, with a default period of 5 seconds or so from some setting somewhere. You get a message in your openhab.log when a file change has been spotted. Sometimes more than one, if whatever editor you are using saves in stages.

Hi thanks for the info,
but there be some delays for a long time before some change come visible in paperui
i think this come like you expalined from different basic delays in the base system.

I see the same delays when i update html page that i use in habpanel widgets.
When i inspect these widgets in the browser, it takes a while befoe the last version is used.

So it can also be a browser relate delay.

Regards
Ronny

Hi,

I’ve read this information, using the SmartLogger 3000 (I think the other smartlogger can work too), with modbus tcp.
With this, I can read, the smartlogger information, the meter information and the inverter information. If anyone wants the modbus configuration, please tell me.

Best Regards,
Fernando Gomes

Hi,
reading the data from my Huawei SUN2000 17KTL-M0 is working perfect. But the inverter shuts down at night to save energy. So the Modbus-Binding spams to the logs because it can’t read data. Is there a way to stop this?