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

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.

finally got is running by restarting the inverter and also added
timeBetweenTransactionsMillis=1200 to the thing configuration
thx for the support

I am using a Huawei Sun2000-12KTL M2 with SmartDongle module. I would like to integrate this into Openhab. The Modbus query apparently only works with dongle version V100R001C00SPC120. How can I install this? Only versions 116 and 118 are offered to me in the upgrade portal

1 Like

You have to send a email to eu_inverter_support@huawei.com
And ask for the update for your dongle model.
Do make sure you send the SN nummer of the dongle and inverter.

1 Like

I received the firmware from support. How can I now install it? I can’t find the dongle under Upgrade in the Fusion app

Follow this guide
2020M0016 How to upgrade SDongle WLAN-FE locally using Fusion Solar App…pdf (843.6 KB)

i am currently try to fix my issue with the times coming from the inverter.
I like to update the system time and timezone of the inverter with the modbus interface

The definition of the modbus poller are defined like this and the data are coming from the inverter properly


Bridge poller slave108holding [ start=40000, length=2, refresh=60000, type="holding" ]{            
        
        Thing data SystemTimeNumber [ readStart="40000", readValueType="uint32", writeStart="40000", writeValueType="int32", writeType="holding", updateUnchangedValuesEveryMillis="5000000" ]  
    }

Bridge poller slave108aholding [ start=43006, length=1, refresh=360000, type="holding" ]{            
        
        Thing data TimeZone [ readStart="43006", readValueType="int16", writeStart="43006", writeValueType="int16", writeType="holding",updateUnchangedValuesEveryMillis="5000000" ]  
    }

in the modbus interface description we have

SN Signal Name    Read/Write  Type Unit Gain Address   Quantity Scope
42 System Time    RW          U32  N/A  1    40000     2        [946684800, 3155759999] Epoch seconds,local time
56 Time zone      RW          I16  min  1    43006     1        [-720,840]

if i send a item update via the karaf console for the item timezone
openhab:send TimeZone 120

12:02:45.812 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusWriteRegisterRequestBlueprint [slaveId=1, reference=43006, registers=ModbusRegisterArray(0078), maxTries=3, getFunctionCode()=WRITE_SINGLE_REGISTER]). Will try again soon. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 128 [operation ID c6f5634d-9ca7-420a-8f6f-4f7e224414b2]
12:02:47.037 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusWriteRegisterRequestBlueprint [slaveId=1, reference=43006, registers=ModbusRegisterArray(0078), maxTries=3, getFunctionCode()=WRITE_SINGLE_REGISTER]). Will try again soon. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 128 [operation ID c6f5634d-9ca7-420a-8f6f-4f7e224414b2]
12:02:48.259 [ERROR] [ort.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusWriteRegisterRequestBlueprint [slaveId=1, reference=43006, registers=ModbusRegisterArray(0078), maxTries=3, getFunctionCode()=WRITE_SINGLE_REGISTER]). Aborting. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 128 [operation ID c6f5634d-9ca7-420a-8f6f-4f7e224414b2]
12:02:48.260 [DEBUG] [ternal.handler.ModbusDataThingHandler] - Thing modbus:data:slave100:slave108aholding:TimeZone 'Modbus Data' had ModbusSlaveErrorResponseExceptionImpl error on write: ModbusSlaveErrorResponseException(error=128)
12:02:48.261 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave100:slave108aholding:TimeZone' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveErrorResponseExceptionImpl) with write. Request: ModbusWriteRegisterRequestBlueprint [slaveId=1, reference=43006, registers=ModbusRegisterArray(0078), maxTries=3, getFunctionCode()=WRITE_SINGLE_REGISTER]. Description: ModbusSlaveErrorResponseException(error=128). Message: Slave responsed with error=128

Has anybody successfully tried to write back the timezone or the time?
Any hint would be welcomed , thx

What numeric values do you actually want to write? You might need a transformation.

Your device might prefer “write multi”, Modbus FC16, indeed almost certainly needs that for the 32-bit value.