Modbus RTU TCP using Virtual Serial Port

Hi all!

I’m a beginner with openHAB and I’m triying to configure it to read values from my solar inverter using Modbus.

The inverted accept only Modbus RTU and it’s connected to the ethernet network (into the device is installed an interface serial-to-ethernet).
I read that openHUB does not supporto modbus RTU over TCP but there is a workaround using virtual serial port, so I tried to start with this solution:

  • OpenHUB v2 installed on a Windows machine
  • Virtual Serial Port installed on Windows (http://www.hw-group.com/products/hw_vsp/index_en.html) and configured to create COM3 and forward all data to the inverter ip address (ip:port)
  • Installed “openHAB ModbusTCP Master Binding - version 1.10.0” and I configured it as follow:
serial.inverter.connection=COM3:9600:8:none:1:rtu
serial.inverter.id=1
serial.inverter.start=16
serial.inverter.length=1
serial.inverter.type=input

I’m getting this error and after reading a lot of articles I cannot find a solution:

2017-08-24 15:35:40.047 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 10 00 01 30 0f
2017-08-24 15:35:40.048 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2017-08-24 15:35:40.062 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@4903d8b8 (unit id 1 & transaction 9). Serial parameters: SerialParameters@52c9b2de[portName=COM3,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

I already checked that the request is correct and equal using another tool (speaking with rtu over TCP, but the modbus request format and values are the same and correct)

Could someone help me?

thanks in advance!
Simone

Solved by myself, hope this can be useful for someone else.

WINDOWS
I used Serial/IP redirector - Free trial 30 days

Software settings:

OpenHAB settings:

modbus.cfg ( just to read only one value -> output power in my case)

poll=2000
serial.inverter.connection=COM4:9600:8:none:1:rtu
serial.inverter.id=1
serial.inverter.start=16
serial.inverter.length=1
serial.inverter.type=input

item:

Number InverterWatts "My Counter high [%d]" (All) {modbus="inverter:0"}

Sitemap

sitemap default label="My first sitemap"
{
	Frame label="Fotovoltaico"{
		Text item=InverterWatts icon="solarplant" label="Potenza istantanea (W)"
	}
}

LINUX
I used “socat” as follow:

socat -d -d pty,link=/dev/ttyS0,raw tcp:192.168.xxx.xxx:7128

modbus.cfg ( just to read only one value -> output power in my case)

poll=2000
serial.inverter.connection=/dev/ttyS0:9600:8:none:1:rtu
serial.inverter.id=1
serial.inverter.start=16
serial.inverter.length=1
serial.inverter.type=input

items and sitemap files are equal to WINDOWS section

Here the result:

NOTE 1
The invertes is an Ingeteam Ingecom Sun Lite with Ethernet card

NOTE 2
On QNAP NAS, in order to use socat I installedEntware and then:

opkg install socat
1 Like