How do I connect rs232 port to RPI 3 Openhabian?

Subject: Issues Connecting RS232 Port to OpenHAB on Raspberry Pi

I’ve encountered some challenges while attempting to connect an RS232 port to my OpenHAB setup on a Raspberry Pi, and I’m hopeful that someone here can provide guidance.

Hardware Details:

  • Raspberry Pi (OpenHABian):
    • Release: Raspbian GNU/Linux 11 (bullseye)
    • Kernel: Linux 6.1.21-v7+
    • Platform: Raspberry Pi 3 Model B Rev 1.2
    • OpenHAB version: 4.02
    • Linux version: openhabian 6.1.21-v7+ #1642 SMP Mon Apr 3 17:20:52 BST 2023 armv7l
  • Rego 6xx heat pump controller
  • RS232 Board: Manufacturer - Renkforce, Model - RF-4011279

Steps I’ve Undertaken:

  1. I’ve identified the serial port using dmesg | grep tty, which showed /dev/ttyS0 and /dev/ttyAMA0.
  2. Tried to connect to both /dev/ttyS0 and /dev/ttyAMA0 in OpenHAB. For /dev/ttyAMA0, I received “Serial port does not exist”, and for /dev/ttyS0, I initially got a connection but subsequently encountered an error: “Inappropriate ioctl for device in nativeavailable”.
  3. Added openhab user to dialout and tty groups.
  4. Modified boot/cmdline.txt to prevent the Raspberry Pi from using the serial port for console logging.
  5. Double-checked the connection between the add-on board/port and the RPI.

Despite these efforts, I continue to encounter error messages. An external RS232 to USB converter is an option I’m considering, but I would genuinely like to get the integrated port operational.

Additional Information:

  • The Rego 6xx device operates at 19200 bps, 8 bits, no parity, 1 stop bit.
  • A user review of my RS232 board mentioned that one must disable boot-time logging on the Raspberry Pi GPIO to function correctly.

Are there any known tweaks or adjustments that might help? Are there specific hardware components known to work better or worse with OpenHAB and Raspberry Pi? Would an RS232 to USB converter be a more reliable option to explore? Any assistance or advice would be highly appreciated!

Thank you in advance!

I’d first confirm the serial port is working outside of openHAB.

Connect Tx & Rx pins together. Open 2 terminals, in one enter cat /dev/ttyAMA0 and in the other echo "Hello World" > /dev/ttyAMA0. You should see Hello World in terminal 1.

If not check permissions on the serial port; ls -l /dev/ttyAMA0. Obviously whichever user you’re running the test commands as also needs to be in the relevant group. Running them as sudo should work as I think root should already be listed there.

Thank you very much for your response.

It appears that I failed to activate the options in the openhabian-config / system settings / serial section. Now I have a stable connection, although it randomly goes offline once a day, indicating that the serial is occupied. I’m not sure why this happens. Restarting the addon works, but it’s not a sustainable solution. So I’m currently struggling with that issue.

Additionally, I purchased another RS232 HAT (Waveshare) for my Raspberry Pi, which has two RS232 ports. It seemed to be installed correctly, but I couldn’t get it to work with my Rego Heatpump. I keep getting an ‘occupied port’ message, but I can’t find anything on the Raspberry Pi that indicates what’s causing this or why. I suspect it might be related to Java or OpenHAB. I’m not certain.

To whom it may concern, I have discovered an additional sensitivity issue with the serial port on my Raspberry Pi and OpenHABian. A poorly shielded network cable caused the RS232 port to stop working and display an error message. This seems very strange to me since other network traffic, including the web server/interface, works perfectly. I can’t find any other problems, but when I switch between different network cables, it’s clear how the issue comes and goes.