Successfully Setting Up Modbus RTU Communication with OpenHAB

After struggling for a while with setting up Modbus RTU communication for my Systemair ventilation system, I thought I’d share my journey and solution. Hopefully, this can help others who might be facing similar challenges!

The Challenge:
I was trying to connect my Systemair ventilation system to OpenHAB using the Modbus binding. The system uses a TCP gateway (USR-232/485-950), but getting OpenHAB to communicate with it was proving tricky. I tried several setups with socat and ser2net, but nothing seemed to work. The logs just kept showing connection issues, and I was stuck.

The Solution:
After some research and reaching out to the community, I found that the key was to configure the serial-to-TCP redirection correctly. Here’s what worked for me:

  1. Install ser2net: I used this tool to handle the serial-to-TCP conversion. It’s lightweight and works well for this purpose.

  2. Configure ser2net: I set up a simple configuration file to redirect the serial port to a TCP port. Here’s an example of the config I used:

    2391:raw:tcp:192.168.1.100:502

    This sets up a listening port (2391) that connects to the Modbus device on TCP port 502.

  3. OpenHAB Configuration: I then configured the Modbus binding in OpenHAB to connect to the newly created TCP port. Here’s a snippet of my .things file:

    ModbusTcp {
    ipAddress=“192.168.1.100”
    port=2391
    slaveId=1
    }

  4. Testing: After applying these changes, I restarted both ser2net and OpenHAB. The connection finally worked, and I could see data flowing into OpenHAB!

Lessons Learned:

  • Documentation: Make sure to thoroughly check the documentation for both ser2net and the Modbus binding. Sometimes the smallest details can make a big difference.
  • Community Support: Don’t hesitate to reach out to the community. Forums and Discord channels are goldmines of information and support.
  • Patience: Debugging communication issues can be frustrating, but taking it step by step and systematically testing each component helps a lot.

If anyone has further questions or needs help with similar setups, feel free to reach out! I’d be happy to share more details or troubleshoot together.

Happy automating! :rocket: