Modbus TCP connection to EPEVER Solar controller

I’m trying to read data via modbus from the EPEVER wifi adapter. I’m trying to replicate the setup example given here:

I copied the Thing definition (updated IP, using same port):

    `Bridge modbus:tcp:EPEVER [ host="192.168.86.28", port=502, id=1,   timeBetweenTransactionsMillis=500, timeBetweenReconnectMillis=500, reconnectAfterMillis=0, connectTimeoutMillis=30000 ] {`

        Bridge poller realtime_data1 [start=12548, length=14, refresh=5000, type="input"] {

        Thing data 3104 "Battery voltage"       @ "EPEVER"  [readStart="12548", readValueType="int16"]
    }

(Just 1 data Thing for now, trying to get it to work first!)

I get the following in the log:

2020-08-26 22:12:47.356 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandler.ModbusPollerReadRequest@525403[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=12548,length=14,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: ModbusIOException Premature end of stream (Header truncated). [operation ID 1ec26de5-ade4-4405-94e3-a737c9dc1686]
2020-08-26 22:12:47.884 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusPollerThingHandler.ModbusPollerReadRequest@525403[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=12548,length=14,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: ModbusIOException Premature end of stream (Header truncated). [operation ID 1ec26de5-ade4-4405-94e3-a737c9dc1686]
2020-08-26 22:12:48.393 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusPollerThingHandler.ModbusPollerReadRequest@525403[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=12548,length=14,maxTries=3]). Aborting. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: ModbusIOException Premature end of stream (Header truncated). [operation ID 1ec26de5-ade4-4405-94e3-a737c9dc1686]

I can’t work out from the error if the issue is with the bridge link to the TCP server, or the read of the data from poller?

I realise that the original post i am copying from is 3 years old now, so maybe something changed in the Modbus binding and the Thing definition needs updating?

Any ideas greatly welcome!

I am able to connect to the modbus TCP server using NetBurner virtual COM port and the EPEVER Solar Station software, so i know the communication is working and data can be read… just can’t get OpenHAB to see it.

Looks to me like bad response from device. Suspect in a non-Modbus format, like “error blahblah” or something.

As ever, it is worth using a tool like modbus-poll to verify what you can do with your device, more interactively than Thing editing.

Some devices only manage one connection at a time - make sure only one of proprietary / openHAB / modbus poll in use.

Can you elaborate, where does this COM port come into it? The EPEVER device is what, RS485?
The poster you are taking cues from used a gateway - this talks Modbus-TCP to openHAB and Modbus-RTU to his device.
If the Netburner thing is a remote serial port (and not a true gateway) you will need to talk Modbus-RTU to it, presumably via a local virtual com port.

Here is a screenshot of my USR configuration:

Also power off the EPEVER completeley befor you give it a try…
It is also a bit tricky if you change the *.thing-File - it is not always refreshed/loaded as fast as you work.
Maybe restarting OH can help, to be sure, the correct configuration is loaded.

Here is my latest:

Bridge modbus:tcp:EPEVER [ host="192.168.125.74", port=502, id=1, timeBetweenTransactionsMillis=1000, timeBetweenReconnectMillis=1000, reconnectAfterMillis=0 ] {
Bridge poller realtime_data1 [start=12544, length=18, maxTries=2, refresh=10000, type="input"] {
	
	Thing data 3100 "PV Input Voltage"				@ "Modbus"	[readStart="12544", readValueType="int16", readTransform="JS(divide100.js)"]
	Thing data 3101 "PV Input Current"				@ "Modbus"	[readStart="12545", readValueType="int16", readTransform="JS(divide100.js)"]
	Thing data 3102 "PV Input Power"				@ "Modbus"	[readStart="12546", readValueType="int16", readTransform="JS(divide100.js)"]
	
	Thing data 3104 "Battery Voltage"				@ "Modbus"	[readStart="12548", readValueType="int16", readTransform="JS(divide100.js)"]
	
	Thing data 310C "Load Voltage"					@ "Modbus"	[readStart="12556", readValueType="int16", readTransform="JS(divide100.js)"]
	Thing data 310D "Load Current"					@ "Modbus"	[readStart="12557", readValueType="int16", readTransform="JS(divide100.js)"]
	Thing data 310E "Load Power"					@ "Modbus"	[readStart="12558", readValueType="int16", readTransform="JS(divide100.js)"]

	Thing data 3110 "Temperature Battery"			@ "Modbus"	[readStart="12560", readValueType="int16", readTransform="JS(divide100.js)"]
	Thing data 3111 "Temperature TRACER"			@ "Modbus"	[readStart="12561", readValueType="int16", readTransform="JS(divide100.js)"]
}

Bridge poller realtime_data3 [start=12570, length=1, maxTries=1, refresh=5000, type="input"] {
	Thing data 311A "Battery SOC"					@ "Modbus" [readStart="12570", readValueType="int16"]
}

Bridge poller realtime_status [start=12800, length=3, maxTries=1, refresh=5000, type="input"] {
	Thing data 3200 "Status Battery"				@ "Modbus" [readStart="12800", readValueType="int16"]
	Thing data 3201 "Status Charging equipment"		@ "Modbus" [readStart="12801", readValueType="int16"]
	Thing data 3202 "Status Discharging equipment"	@ "Modbus" [readStart="12802", readValueType="int16"]
}

Thanks for the info. I will try again. I’m using the EPEVER eBox-Wifi-01 to connect, is that the same hardware you are using or something else?

Cheers!

No, I use a USR-N540 for three modbus devices.
Just posted it as a help for you to see how it was configured.

Ah, OK, thanks… I will keep plugging away to get the data! I know it is being received as the EPEVER software is reading the data, i just need to workout how to pull it into OpenHAB!

You did not clarify, but if you are using a virtual COM port you will want to be using it as a COM port i.e. an openHAB binding serial Bridge Thing talking Modbus-RTU

Ah, sorry, my bad. I have 2 systems i’m using… 1) openHAB running on my Synology NAS, 2) PC that i’m working/writing on.

On my PC that i use to write/edit, i am running a virtual COM port and using the EPEVER solar station software… so i know that the device is communicating and sending the data (Solar Station updating every 10 seconds).

OpenHAB on the NAS, i’m just using the Modbus binding, with the TCP bridge setup as per your thing definition above.

On my PC i’ve installed Modbus Poll as you suggested. I can connect, but get ‘02 Illegal Data Address’ response. I’ve tried several different ways to update the data ‘address’ (referring to the PDF below), but can’t get any data to show in Modbus Poll. (Modbus poll is running on my PC, connected via the virtual COM port).

I also downloaded a modbus sniffer and monitored the traffic, there is a lot of traffic, so definitely connected and communicating modbus… I just can’t seem to get the settings right to read the data :frowning:

This is details about the Modbus addresses:

1 Like

So, I finally managed to get data reading into Modbus poll after some settings changes…

That’s using a serial format and talking via the virtual COM, right?

I think the thing that you are missing is that not all gateways are equal.

@Dragonfly gateway is configured as a true Modbus gateway. It translates Modbus-TCP to Modbus-RTU for serial. These are two different protocols.

You cannot throw Modbus-TCP at an ordinary serial gateway and expect Modbus-RTU to come out the other side.

You get round that with virtual COM port. Your host talks Modbus-RTU to the virtual port, which does its magic and replicates your serial data at the physical remote port.

So for openHAB, you need a virtual port installed and configure the binding to talk RTU with it.
Or you need a gateway that natively supports Modbus gateway mode.

Thank you! I will look into this. Not sure how easy it is to setup a virtual com port on my Synology - argh.

Really hope i can get this working! Thanks for all the suggestions!!

That’s using a serial format and talking via the virtual COM, right?

Correct.

The TCP-Server doesn’t seem to have option to RTU, so assumed it was just TCP-Modbus, which is what the Binding needs, yes?

There is option for UDP-Server, but not sure if that would help?

Your picture do look like RTU to me, (its serial for sure). Question is which interface beeing used.
I have a USR-TCP232-410S and it handles RTU on RS232 og RS485 interface.

Yeah, you are right. It is. Maybe i’ll have to buy one of the USR devices :slight_smile:

Hi @Dragonfly, quick question, the USR device you are using is a hard wired ethernet version, yes? I need Wifi as the solar system is about 80m down the garden!

I’ve seen this USR-W600: https://www.aliexpress.com/item/32858193435.html?spm=a2g0o.productlist.0.0.567c3fdcI8yVB5&algo_pvid=66e68dca-aa3b-4884-bd44-f2737dbc4359&algo_expid=66e68dca-aa3b-4884-bd44-f2737dbc4359-2&btsid=0b0a119a15986229407862470ed045&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

That looks like it could do the same thing. The USR device you’ve got can connect directly via the Shelly Modbus binding, yes? No need for virtual serial port on PC etc? (As i’m running OH on my Synology, i have limited options and need it to work with OH directly).

Cheers!

We don’t know what this propietary ‘TCP-server’ talks to the gateway. As it is offering serial config parameters, it most likely has its own built-in virtual com software.

You could ask your supplier.

There is sort-of standard for virtual serial, RFC-2217. Maybe your gateway allows that. You might find a RFC-2217 “driver” for whatever system you are trying to host on.

I don´t think the the USR-W600 is working.
You have to look for one which has this feature: Modbus RTU to Modbus TCP

Take a look at the USR-W610.

EDIT: And yes, mine works without any other hardware directly with the modbus-Binding.

3 Likes