Problem with Modbus serial RTU-> socat-> TCP

Hello to all
I have the following problem:
I have to communicate Openhab 2.5 installed on pi3 with an ABB aurora solar inverter. The connection to the inverter is in RS485 but due to the distance I have inserted a Wi-Fi gateway Rs485. According to my documentation, the inverter communicates via the Modbus RTU serial protocol. Since Openhab does not have the TCP RTU protocol, I configured everything as follows and I used the socat command, my configuration below:

Il comando su pi è il seguente:
socat -d -d pty,link=/dev/ttyS0,raw tcp:192.168.0.10:8899

if I look at the gateway I do not see the Tx led of the RS485 flashing as if the socat command does not work.

Can anyone help me?
Thank you.

You can run RS485 over a km, but it might be inconvenient to pull cables around between buildings etc…

Have a think about this. You need your gateway to use Modbus-RTU on the RS485 serial side talking to the inverter.
That’s the gateway’s business.

openHAB wants to know what language your gateway speaks on the ethernet (WiFi) side.
Tell us about the mystery gateway.
(If it is Modbus capable, it most lkely uses Modbus-TCP)

First of all thanks for your answer
actually I use a Rs485 Wifi converter which is more than mysterious it is stupid, it has no protocols inserted. I use this converter because the inverter is in the garage and is difficult to reach with a cable.
I also use this converter to connect to the inverter with its software (aurora communicator) installed on a PC.
Here is the link of the converter: Wifi to Rs485 converter

If you need it, I can attach the manual of the converter and the inverter.

Okay, it appears to be a USR-WIFI232-C device.

I’m afraid you chose the wrong one really. Some of these USR gateways have built-in Modbus features, some don’t. This one doesn’t.

I use USR gateways myself (wired models) and chose the Modbus types - these work great, you just set up openHAB for Modbus-TCP and the gateway converts to Modbus-RTU for multiple slave devices.

USR-W610 would be the current WiFi model you want for that feature.
There are other very similar manufacturer’s products.

I can’t help much if you are stuck with what you already have.
As a Wndows user, I’d need to use a manufacturer supplied driver to create a virtual COM port on my system, and then setup openHAB to talk Modbus-RTU to the virtual COM port - the driver taking care of delivering that to the gateway in a way the gateway can use.

I don’t know how you do that on a *nix type system - I see you are trying to use socat but I do not know if this gateway will ever understand socat messages.

You have to be careful about permissions when attempting any serial port connections, real or virtual, with openHAB. Make sure you look in openhab.log for connection messages.
The Modbus binding will not try to send something until/unless you have configured a poller Thing.

EDIT -might help

https://blog.febo.com/?p=457

or

Hello,
I did some tests.
1- I created the ttyS0 port, OpenHab recognizes it but does not communicate because it is obviously not connected to the device via wifi.
2- I did the command sudo socat pty, link = / dev / ttyS0, raw tcp: 168.192.0.10: 8899 & to connect the serial to the wifi converter Rs485
3- Note that the ttyS0 port is in use
4- OpenHab no longer sees the ttyS0 serial port so it does not communicate with the inverter.

Do you have any suggestions?

Permissions. I don’t know anything about that.

Try using the openhabian-config tool (sudo openhabian-config) and run fix permissions.

where is the permissions file? I installed openhab manually not with openhabian.
Do you need to change the permissions even if the ttyS0 file is set rwxrwxrwx?

As I said I don’t know much about this, but permissions are related to user so you need to consider what user your openHAB is running under.
There are notes here -

1 Like

You can add openhabian-config tool by following the doc’s found here:

After installing then run fix permissions from the openhabian-config tool menu.