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

Hello @ssalonen the fix did not solve the problem.

@Rado1 what is the problem?

You recently talked about TCP but the last error message in this thread (Reading data from Huawei inverter SUN 2000 (3KTL-10KTL) via modbus RTU - #16 by Rado1) clearly refers to modbus configured with serial.

The fix I linked above is related to TCP only (either Modbus TCP or Modbus RTU over TCP).

When i plug in the ethernet dongle of the inverter i get these errors.
When i plug it out restart openhab it works without errorā€™s.
De inverter is connected with a serial converter for the modbus read out.
De modbus connection is RTU.
The ethernet dongle is for the huawei read out software.

==> /var/log/openhab/openhab.log <==
2021-04-12 19:01:34.133 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,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: 3 bytes: 38 01 00  [operation ID 016949b8-2138-4896-b9e8-9f6dee84e370]
2021-04-12 19:01:35.449 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,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: 159 bytes: 00 03 9c b6 01 00 03 fc 00 8c d8 61 f5 01 41 33 11 00 05 27 10 07 27 76 06 27 d8 08 27 e6 04 28 3c 02 dc 62 01 41 33 47 00 05 27 10 07 00 00 02 bd 00 15 00 03 00 00 00 00 00 00 27 76 06 00 00 00 00 00 00 00 00 00 00 00 00 27 d8 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 e6 04 00 00 00 00 00 00 00 00 28 3c 02 00 00 00 00 70 f8 01 41 33 17 00 07 30 d4 21 30 f7 02 32 c8 21 34 bc 03 36 b0 0d 37 14 01 3a 98 12 f8 66 01 41 33 e5 00 07 30 d4 21 65 75 35 2e 66 75 73 69  [operation ID 016949b8-2138-4896-b9e8-9f6dee84e370]
2021-04-12 19:01:35.580 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint@b21f50[slaveId=10,functionCode=READ_INPUT_DISCRETES,start=0,length=16,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: 0 bytes:  [operation ID 2cdcc908-c489-45c3-a006-29b4c49f545c]
2021-04-12 19:01:36.589 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint@28e66e[slaveId=12,functionCode=READ_INPUT_DISCRETES,start=0,length=16,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: 0 bytes:  [operation ID 7bafe46e-cf56-4f25-b6b0-5b4a93ebff8c]
2021-04-12 19:01:37.752 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]). Aborting. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException CRC Error in received frame: 0 bytes:  [operation ID 016949b8-2138-4896-b9e8-9f6dee84e370]
==> /var/log/openhab/events.log <==
2021-04-12 19:01:37.665 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Pv_1_Voltage' changed from 456.2 to 460.1
2021-04-12 19:01:37.666 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ModbusDataPv1Voltage_ValueasNumber' changed from 456.2 to 460.1
2021-04-12 19:01:37.674 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ModbusDataPv1Current_ValueasNumber' changed from 5.04 to 4.98
2021-04-12 19:01:37.675 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Pv_1_Current' changed from 5.04 to 4.98
2021-04-12 19:01:37.826 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave11Inputs:di19' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null). Message: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null
2021-04-12 19:01:37.829 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave11Inputs:di31' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null). Message: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null
2021-04-12 19:01:37.833 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave11Inputs:di18' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null). Message: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null
2021-04-12 19:01:37.837 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave11Inputs:di30' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null). Message: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null
2021-04-12 19:01:37.839 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave11Inputs:di16' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null). Message: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null
2021-04-12 19:01:37.840 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave11Inputs:di29' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null). Message: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null
2021-04-12 19:01:37.842 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave11Inputs:di20' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null). Message: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null
2021-04-12 19:01:37.843 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave11Inputs:di28' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusReadRequestBlueprint@15877c9[slaveId=11,functionCode=READ_INPUT_DISCRETES,start=0,length=16,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame: 0 bytes: ', cause2=null). Message: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame:

Iā€™m not sure I follow, sorry :frowning:

Perhaps if you could share your modbus configuration in openHAB and schematic including all the dongles and devices?

The modbus connection is working fine configuration you can find at the top of this topic.
Just when i connect mij inverter to the internet with a ethernet dongle the errorā€™s come and finally the modbus connection fails completely.(I personly never used the dongle because of this)
I made this tutorial and many people are having the same problem when we connect the inverter with the internet the modbus connection fails.The internet conection is for the huawei app to read out your solar production.

Thanks, I completely misunderstood you before. This sounds more of an device issue, not related to the binding.

I think youā€™ve worked this out for yourself.
The openHAB end of the serial has no idea if your device has an ethernet connection or not. It behaves the same.
But when you plug it into your device, the device no longer works with serial. It behaves differently.
Conclusion; the device has trouble doing serial and ethernet at the same time.

Most likely the device firmware is having trouble doing two things at once in timely fashion. It doesnā€™t fail every transfer.
If you do some more technical stuff like looking at the serial bus with a line analyzer,you might spot something like pauses in data transmissions.
Or maybe it puts noise on the serial line while doing ethernet stuff, who knows.
There may or may not be a way around whatever is found.

Youā€™ve got multiple slaveid numbers involved, whatā€™s that about?

I have several modbus devices on the same bus, but I already tested them with just the inverter connected and it gave the same errors.

Iā€™m trying to interpret what this means.
From the log earlier, you have multiple devices reporting CRC errors.

From earlier descriptions, the Huawei works okay over serial with no ethernet module fitted, but when the ethernet is installed it throws CRC.
I assume the last message means you get Huawei serial CRC when it is connected on its own, without the other devices.

A missing puzzle piece would be if the other devices also work fine with no ethernet on the Huawei, but Iā€™ll assume that is the case.

Taken all together ā€¦ the Huawei craps on the serial bus when ethernet is fitted.

Where/how does this ā€œHuawei dongleā€ actually fit? Is it in fact an ethernet-RS485 gateway? If that were the case, then yes it will crap on the bus, you can only have one Modbus-RTU master.

i can actually confirm that the binding is working under the condition that only one serial modbus is used

smart dongle and modbus serial cannot be used in parallel as the communication is not stable.
Modbus tcp on the Ethernet cable is not accessible.
Wifi is not accessable when Ethernet cable is connected
All these constrains are not documented in the manual and doc.

i do have the following firmware in inverter V100R001C00SPC133 and wifi dongle V100R001C00SPC118.

I have opened a discussion in the huawei forum. There are rumors that a new firmware soon will allow connecting modbus tcp via smartdongle ethernet

1 Like

Now Iā€™ve poked around and have a better idea of what this ā€œdongleā€ is, this all makes sense.
The SmartLogger dongle connects to same RS-485 bus that you would use for connection to openHAB Modbus-RTU.
It acts as a gateway, the important part being that it acts as a Modbus-RTU bus master - and so does openHAB. You can only have one master on a bus, so connecting this way is just doomed to failure.

2 Likes

Hi ,

currently try to define semantic model of the inverter and also try to use unit of measurement in the item definition.

I do get the following error when i open the OH 3 ui with a cell representing the voltage

[WARN ] [se.internal.SseItemStatesEventBuilder] - Exception while formatting value '532.2' of item Pv_1_Voltage with format '%.1f %unit%': Conversion = 'u'

This is the modus definition

Thing data Pv_1_Voltage                    [ readStart="32016", readValueType="int16",readTransform="JS(divide10.js)",updateUnchangedValuesEveryMillis="5000000" ]

here the item definition. to my understanding it would make sense to use [%.1f %unit%] instead of [%.1f V]

Number:ElectricPotential Pv_1_Voltage "Strang 1 Spannung [%.1f %unit%]" <energy> (gSolar) ["Measurement", "Voltage"] {channel="modbus:data:slave100:slave104holding:Pv_1_Voltage:number"}

i also like to use the data to calculate the current power consumption
the rule is like this with EnergiemessungDeviceAccumulatedWatts in ā€œWā€ and Active_power in kW.

rule "verbrauch"
when
    Item EnergiemessungDeviceAccumulatedWatts changed
then
    var power = EnergiemessungDeviceAccumulatedWatts.state as QuantityType<Power>

    if (power < 0.0) {
        NetzModus.sendCommand(ON)
        logInfo("energie.rules","Netzmods {}", NetzModus)
    }

    if (NetzModus.state == ON && Active_power.state != NULL ) {
        var solar = Active_power.state as QuantityType<Power>
        //var solarW = solar.toUnit("W")
        //logInfo("energie.rules","solarW: {}",solarW)
        //logInfo("energie.rules","solar:{}",solar)
        power = power + solar
    }    
    logInfo("energie.rules","Verbrauch neu berechnet {} !", power)
    postUpdate(AktuellerVerbrauch, power as Number)

end

here is do get the following problem in the rule editor VS code.
Type mismatch: cannot convert from QuantityType<?> to QuantityType(org.eclipse.xtext.xbase.validation.IssueCodes.incompatible_types)

What would be the right way to define the thing, item properly with unit of measurement that also allows to use is in the calculation considering the UoM.

thx

Iā€™m afraid that only makes sense when the incoming data comes with units, and %unit% represents ā€œuse what you haveā€. In this case, there is no ā€œwhat you haveā€.
Try [%.1f V]

Okay, so if power is 300W are we comparing with X mW or X kW or X horsepower ā€¦
if (power < 0.0 | W) {

many thanks for the explanations for the item definition.
So the thing definition does not have a unit today. Is this something I can achieve by a different thing definition and already define the UoM there?

Concerning the rule, actually then

if (power < 0.0)

is working .

The problem in VS code is on the

power = power + solar

here the power value is QuantityType but the solar is seems to be the problem even if i try to give it a type in the declaration. But this seems not to work with the current thing an item definition.

Modbus by its nature has no place for units.
The binding can pass quantities (with units) to Items, however.
So you could modify your divide10.js transformation to return ā€œ252.0 Vā€ for example.

Iā€™d advise against that for now, a new feature is in development that would provide a simple way to both scale and add unit.

Trust me, itā€™s not working as you think.

See the link I gave you.
You can add 300W and 22kW, thatā€™s fine.
You canā€™t add 300W and 22kWh, youā€™d get a message like
Type mismatch: cannot convert from QuantityType<?> to QuantityType(org.eclipse.xtext.xbase.validation.IssueCodes.incompatible_types)
but Iā€™m just guessing, your Item types and states are secret.

no there are not secret.
just recognized that i pasted the working item definition for the solar power. sorry
i now tried this:

Number:Power        Active_power "Aktive Einspeisung [%.2f W]" <energy> (gInverter) ["Measurement", "Power"] {channel="modbus:data:slave100:slave105holding:Active_power:number"}

i removed the readtransform.

    Thing data Active_power                   [ readStart="32080", readValueType="int32",updateUnchangedValuesEveryMillis="5000000" ]

So now both number in the rule are ā€œWā€, but the VS code problem remains. even if the calculation is correct.
i think i can life with it as long as the rule executes
looking forward for the new feature you mentioned

I can confirm that Modbus TCP works with the Smart Dongle-WLAN-FE and update SDongle_V100R001C00SPC120_package.

1 Like

I today updated the SDongle to the new version.
I have connected the LAN cable to a switch and the SDongle has ip 192.168.1.171"


Bridge modbus:tcp:sun2000 [ host="192.168.1.171", port="502" ,id=1 ]{

Bridge poller slave107holding [ start=32114, length=2, refresh=60000, type="holding" ]{            
        
        Thing data E_day                         [ readStart="32114", readValueType="uint32",readTransform="JS(divide100.js)",updateUnchangedValuesEveryMillis="5000000" ]  
    }
}

i have only defined one register and do get the following message:

21:46:33.459 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ā€˜modbus:poller:sun2000:slave107holdingā€™ changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
21:46:33.468 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ā€˜modbus:poller:sun2000:slave107holdingā€™ changed from INITIALIZING to ONLINE
21:46:33.469 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ā€˜modbus:data:sun2000:slave107holding:E_dayā€™ changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
21:46:33.470 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ā€˜modbus:data:sun2000:slave107holding:E_dayā€™ changed from INITIALIZING to ONLINE
21:46:36.475 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=32114, length=2, maxTries=3]). Will try again soon. Error was I/O error, so res
eting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID 3d755496-3838-4705-9b21-71e4bf974c25]
21:46:39.540 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=32114, length=2, maxTries=3]). Will try again soon. Error was I/O error, so res
eting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID 3d755496-3838-4705-9b21-71e4bf974c25]

Anything i am doing wrong?
Could you please share a bridge configuration ?
thx

Hello,

I configure everything with the GIU now.


This is a picture of the bridge code.
I also had to restart the inverter.

It didnā€™t connect. Thereā€™s not much more you can say.