EIB/KNX: KNXNet/IP Gateway with calimero server on Raspberry Pi/Orange Pi PC

Hi,

as an alternative to knxd the calimero project also supplies an KNXnet/IP server.


The calimero server is based on Java so you have to ensure that the device which should host the server has enough CPU/RAM. A Raspberry Pi or Orange Pi PC should be sufficient.

I’ve written a script which do all necessary tasks to get the server running.

The requirements:

  • A running Debian 9 installed, i.e. raspbian (Raspberry Pi) or armbian (Orange Pi),
  • A TPUART modul as descripted here is connected. PCB and schematic
    Raspberry KNX IP Gateway/Router

    Raspberry KNX IP Gateway/Router

    Raspberry Pi KNX Board Schematic

    Raspberry Pi KNX Board Schematic

  • You can also use KNX USB devices or an IP Tunnel connection but I have not tested it yet. Any experiences or feedback are welcome.

What the script does:

  • Recognition on which platform the script runs
  • Setup the serial device depending on the platform
  • Gets all sources for calimero server and –tools from github
  • Complies all sources
  • Patches calimero server to run in background(detached stdin)
  • Installs binaries to /opt/calimero-server
  • Moves/installs config files to /etc/calimero
  • Alters config to use a TPUART Module
  • Adds 8 KNX Client Addresses
  • Sets the Servername
  • Creates a user and group knx under which the server runs
  • Adds a systemd service knx.service
  • Installs calimero tools and a wrapper script knxtools to /usr/local/bin
  • New: The script can configure calimero to use a KNX USB device or a Tunnel connection

To install calimero KNXNet/IP server download the script. In the header adjust the variables

  • KNX_ADDRESS
  • KNX_CLIENT_ADDRESS_START
  • LISTEN_NETWORK_INTERFACE
  • KNX_SERVER_NAME
  • ….

to your needs and run it as root. It can configure calimero server for using TPUART- or KNX USB device and for establish a Tunnel connection. To use a TPUART Module start the script without a parameter

michael@debdev ~ # sudo su -
root@debdev ~ # wget https://michlstechblog.info/blog/download/shell_scripts/calimero.sh
root@debdev ~ # bash calimero.sh

For the use of the first found USB Device:

root@debdev ~ # bash calimero.sh usb

To establish a tunnel connection to 192.168.56.200 start it with:

root@debdev ~ # bash calimero.sh tunnel 192.168.56.200

After script has finshed. Reboot your device. The calimero server starts automatically at boot.

The location of the config file is /etc/calimero/server-config.xml

OrangePi PC with TPUART

OrangePi PC with TPUART

Some basic checks after reboot
Check if the java process is running

root@debdev ~ # ps ax|grep tuwien.auto.calimero.server.Launcher
 429 ? Ssl 0:04 /usr/bin/java -cp /opt/calimero-server/* tuwien..........

Check systemd log

root@debdev ~ # journalctl -xu knx
java[429]: 19:02:45:852 WARN calimero.server - network interface eth0 not found, using system default
java[429]: 19:02:47:090 INFO calimero.server - KNXnet/IP discovery network interfaces: listen on [all], send on [all]
java[429]: 19:02:47:127 INFO calimero.server - Service container '/dev/ttyS0':
java[429]:         listen on any, KNXnet/IP routing multicast group 224.0.23.12
java[429]:         tpuart connection: TP1 medium, device 3.1.0
java[429]:         Group address filter []
java[429]: 19:02:47:178 INFO calimero.server - connect to /dev/ttyS0
java[429]: 19:02:47:378 INFO calimero.serial.tpuart:/dev/ttyS0 - setup serial port: baudrate 19200, even parity, 8 databits, 1 stopbits, timeou
java[429]: 19:02:47:393 INFO calimero.link.tpuart:/dev/ttyS0 - hop count set to 6
java[429]: 19:02:47:579 INFO calimero.server.gateway.knx-server - main-line group address forward setting set to 1
java[429]: 19:02:47:581 INFO calimero.server.gateway.knx-server - sub-line group address forward setting set to 1
java[429]: type 'stop' to stop the gateway and shutdown the server
java[429]: Detached from STDIN. Running in daemon mode
java[429]: 19:02:47:587 INFO calimero.server.knx-server - launch KNXnet/IP server 'Calimero KNXnet/IP Server'
java[429]: 19:02:47:724 INFO calimero.knxnetip.KNXnet/IP routing service 224.0.23.12 - multicast loopback mode enabled
java[429]: 19:02:47:726 INFO calimero.server.knx-server - KNXnet/IP discovery listens on interface enp0s8
java[429]: 19:02:47:739 INFO calimero.server.knx-server - KNXnet/IP discovery listens on interface enp0s3
java[429]: 19:02:47:739 INFO calimero.server.knx-server - KNXnet/IP discovery listens on interface lo

Check if the KNXnet/IP gateway is found.

root@debdev :~# knxtools discover
Using /127.0.0.1 at lo
----------------------
Control endpoint 192.168.200.1:3671 (IPv4 UDP) "Calimero KNXnet/IP Server"
KNX address 1.1.150
KNX medium TP1
Installation 0 - Project 0 (ID 0)
KNX IP multicast address 0.0.0.0
MAC address 8a:e4:30:04:f1:81
S/N 0x000000000000
Supported services: Core (v1), Device Management (v1), Tunneling (v1)

Using /172.16.1.200 at eth0
---------------------------
Control endpoint 192.168.200.1:3671 (IPv4 UDP) "Calimero KNXnet/IP Server"
KNX address 1.1.150
KNX medium TP1
Installation 0 - Project 0 (ID 0)
KNX IP multicast address 0.0.0.0
MAC address 8a:e4:30:04:f1:81
S/N 0x000000000000
Supported services: Core (v1), Device Management (v1), Tunneling (v1)

Check if groupmonitor can connect and see packets on the bus.  Replace 192.168.200.1 with the IP Address of your calimero server.

root@debdev :~# knxtools groupmon -m knxip 192.168.200.1
19:26:50:994 INFO calimero.knxnetip.KNXnet/IP Tunneling 192.168.200.1:3671 - establish connection from /127.0.0.1:58235 to /192.168.200.1:3671
19:26:51:123 INFO calimero.knxnetip.KNXnet/IP Tunneling 192.168.200.1:3671 - connection established (channel 1)
19:26:51:132 INFO calimero.knxnetip.KNXnet/IP DevMgmt 192.168.200.1:3671 - establish connection from /127.0.0.1:58045 to /192.168.200.1:3671
19:26:51:137 INFO calimero.knxnetip.KNXnet/IP DevMgmt 192.168.200.1:3671 - connection established (channel 2)
19:27:03.600 0.0.1->5/3/1 A_Group.write 00: 0 counter pulses [5.010], 0 % [6.001], 0 [17.001], activate 0 [18.001], inactive (no message sent) [20.606], [21.106], [28.001]
19:27:03.745 1.1.59->2/2/26 A_Group.write 0c 7c: 31960 ms [7.003], 22.96 mV [9.020]

This is the first release. Script is also available at github. Any feedback is welcome. If you have improvments feel free to send a pull request.

Michael

Advertisment to support michlstechblog.info

Script to install calimero KNXnet/IP Server
Script to install calimero KNXnet/IP Server
calimero.sh
Version: v20190318-124500
29.3 KiB
496 Downloads
Details...

Add a comment »30 comments to this article

  1. I am from China. Where I can buy the Siemens Bustranceiver Module BTM UP117 5WG1117-2AB11 ?

    It is appreciate that you could give a directly web address to buy it.

    THX!

    Reply

  2. Hello Michael,
    So I tried installing your script but it seems it’s not working for me.
    ps ax|grep tuwien.auto.calimero.server.Launcher gives me:
    1503 pts/1 S+ 0:00 grep –color=auto tuwien.auto.calimero.server.Launcher

    journalctl -xu knx gives:
    no entries
    and when I make knxtools discover:
    bash: knxtools: command not found
    so apparently it’s not installed.

    I’m a complete beginner with calimero and knx. How can I solve this ?
    Thanks in advance.

    yassin

    Reply

    • Hi Yassin,

      is the script ran completely until the end?

      What was the last line of screen output: Please reboot your device?

      Please rerun the script.

      Michael

      Reply

      • Hello,
        Apparently it doesn’t run until the end, there is an error :

        Package setserial is not available, but is referred to by another package.
        This may mean that the package is missing, has been obsoleted, or
        is only available from another source
        E: Package ‘setserial’ has no installation candidate

        it stops there

        Yassin

        Reply

      • Hello,
        It doesn’t complete until the end, it stops with this error:

        Package setserial is not available, but is referred to by another package.
        This may mean that the package is missing, has been obsoleted, or
        is only available from another source

        E: Package ‘setserial’ has no installation candidate

        Yassin

        Reply

        • Hi Yassin,

          which linux distribution and which version do you use ?

          Try the following before running the script (Update and reboot)

          sudo apt-get update 
          sudo apt-get upgrade
          sudo reboot
          

          Michael

          Reply

          • Hello,
            I’m running raspbian stretch on rpi3, I tried installing the missing package manually and now it’s working.
            So I connected my rpi to a simple knx home system through ip router IN00A01RIP from eelectron, I can find its mac address when I do knxtools discover but I can’t see any packets on the bus. Also I don’t know how to send commands to turn on/off lights.
            can you help me please ?

            Besides here is my email : yassinegouja@gmail.com could you please send me yours to detail problem and for further queries.
            Sorry for the inconvenience.

            Yassin.

          • Hi Yassin,

            any more Details? Command line which you are using? Calimero server-config.xml file? Error Messages?

            Michael

  3. as knxd did not succeed, i tried to install this one on a blank raspberry 2 with brand new jessie image.
    This is the result

    knxtools discover
    Error: A JNI error has occurred, please check your installation and try again
    Exception in thread “main” java.lang.NoClassDefFoundError: tuwien/auto/calimero/KNXFormatException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
    Caused by: java.lang.ClassNotFoundException: tuwien.auto.calimero.KNXFormatException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

    I had to add a line 117 :

    export IS_RASPBERRY_3=0

    otherwise that variable was not initiated and failed @line 645

    I upgraded and updated jessie to latest version and ran the script again, but same result.

    Reply

    • Hi Kurt
      create an symlink:

      ln -s /opt/calimero-server/calimero-core-2.4-rc1.jar /opt/calimero-server/calimero-core-2.4-SNAPSHOT.jar

      and try to run knxtools again.

      BTW: Why you are still on debian jessie 🙂 ?

      Michael

      P.S. Script is adjusted

      Reply

      • it seems to work now

        knxtools groupmon -m knxip 192.168.1.23
        13:26:11:153 INFO calimero.knxnetip.KNXnet/IP Tunneling 192.168.1.23:3671 – establish connection from /127.0.1.1:59760 to /192.168.1.23:3671
        13:26:11:208 INFO calimero.knxnetip.KNXnet/IP Tunneling 192.168.1.23:3671 – connection established (channel 5)
        13:26:11:218 INFO calimero.knxnetip.KNXnet/IP DevMgmt 192.168.1.23:3671 – establish connection from /127.0.1.1:51606 to /192.168.1.23:3671
        13:26:11:226 INFO calimero.knxnetip.KNXnet/IP DevMgmt 192.168.1.23:3671 – connection established (channel 6)

        But i do not see any message appearing on the bus.
        Is there somewhere a user manual for calimero knxtools ?

        Reply

        • update : just received my busware.de/tiki-index.php?page=POD and after installation and without touching anything, the script of michael did do the job activating the whole interface
          Magnificent job michael !

          Reply

  4. > Task :compileJava FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ‘:compileJava’.
    > Could not target platform: ‘Java SE 9’ using tool chain: ‘JDK 8 (1.8)’.

    Reply

    • Hi Lukasz,

      the calimero is under development and they switch to Java 9. I must alter my script to just use the 2.4 release (based on Java 8) for the projects (if available) branch… I think tomorrow….

      Update: Script is altered. Please cleanup your build directory and try again.

      Michael

      Reply

      • Dear Michael,

        I also have the same Java error – but even with the current version of the script. What can I do?

        Michael

        Reply

        • Hi Michael,

          is fixed. Please rerun the script.

          Michael

          Reply

          • Dear Michael,

            finally I managed to get everything working – but I had to change your script a little bit. Here is the diff:

            root@raspberrypi:~# diff calimero.sh calimero.sh.1
            373c373
            cp ./build/libs/calimero-core-2.4-*.jar $CALIMERO_SERVER_PATH
            380c380
            cp ./build/libs/calimero-device-2.4-*.jar $CALIMERO_SERVER_PATH
            403c403
            cp ./build/libs/calimero-rxtx-2.4-*.jar $CALIMERO_SERVER_PATH
            455c455
            cp ./build/libs/calimero-server-2.4-*.jar $CALIMERO_SERVER_PATH
            488c488
            cp ./build/libs/calimero-tools-2.4-SNAPSHOT.jar $CALIMERO_SERVER_PATH

            Thank you very much for your great work,
            Michael

          • Diff output doesn’t work here…

            In fact I had to change all ./build/libs paths to something like that ~/calimero-build/calimero-core/build/libs (for core, server, tools, etc.) and also the calimero-tools-2.4.-SNAPSHOT.jar name to *.rc1.jar

            Michael

          • Hi Michael,

            thx for the hint. I changed the copy command of the calimero tools jar to calimero-tools-2.4-*.jar but a change to ~/calimero-build/calimero-core/build/libs isn’t necessary because the working directory is always changed to the root of the package before building it and therefore the relative path should work.

            Michael

  5. hello , Hello. I did all the steps. looks ok. (comunication etc).
    But i do not see any message appearing on the bus.
    KNX/Interface Thing it is online.

    Reply

  6. Hi Michael.

    I’ve followed your guide(s) setting up my BTM UP117 5WG1117-2AB12 with a 1201 between the RPI and KNX bus. I’ve tried eibd, knxd, and calimero, but all seem to fail.

    I checked if there is traffic between serial and the knx, and i get some “garble” when i press my light switch on and off.

    I can get calimero to start, but get ADPU errors, and generally no sensible info when monitoring the bus.
    Ive tried to connect the 1201 to both 3.3 and 5.0 v (some suggested 3.3 v )

    What might i be doing wrong?

    Reply

    • Hi Per-Arne,

      do use the 1201 on a PCB I’ve provided or have you wired it manually? Any error messages when knxd or calimero starts?

      Michael

      Reply

  7. Hi There,

    I came across this github project (Race666/calimero-server) and this blog post linked.

    We are trying to make a gateway that can talk to existing KNX system. As I read, this project talks about the same. Can you please let me know if the project will cater to our needs.

    Thanks
    Rahul
    +61 45-21695

    Reply

    • Hi Rahul,

      yes this should fit your needs.

      Michael

      Reply

  8. Hi,

    Thanks for your tutorial.

    I’m trying to use it. I have installed the server and I get a good response from knxtools discover command:

    root@raspberrypi:/home/pi# knxtools discover
    13:30:38:673 INFO calimero.knxnetip.Discoverer – search on eth0 /192.168.1.11:3671
    13:30:38:693 INFO calimero.knxnetip.Discoverer – search on lo /127.0.0.1:3671

    Using 192.168.1.11 at eth0
    ————————–
    “Calimero KNXnet/IP Server” endpoint 192.168.1.11:3671 (IPv4 UDP)
    KNX address 2.1.0
    KNX medium TP1
    Installation 0 – Project 0 (ID 0)
    KNX IP multicast address 224.0.23.12
    MAC address b8:27:eb:a6:5f:92
    Supported services: Core (v1), Device Management (v1), Tunneling (v1), Routing (v1)

    Using 127.0.0.1 at lo
    ———————
    “Calimero KNXnet/IP Server” endpoint 192.168.1.11:3671 (IPv4 UDP)
    KNX address 2.1.0
    KNX medium TP1
    Installation 0 – Project 0 (ID 0)
    KNX IP multicast address 224.0.23.12
    MAC address b8:27:eb:a6:5f:92
    Supported services: Core (v1), Device Management (v1), Tunneling (v1), Routing (v1)
    13:30:41:721 INFO calimero.knxnetip.Discoverer – search stopped after 3 seconds with 2 responses

    The problem is when I try to listen from the bus:

    root@raspberrypi:/home/pi# knxtools groupmon -m knxip 192.168.1.11
    13:32:35:488 INFO calimero.knxnetip.KNXnet/IP Tunneling 192.168.1.11:3671 – establish connection from /192.168.1.11:49043 to /192.168.1.11:3671
    13:32:35:511 ERROR calimero.knxnetip.KNXnet/IP Tunneling 192.168.1.11:3671 – could not accept new connection (maximum reached)
    13:32:35:512 ERROR calimero.knxnetip.KNXnet/IP Tunneling 192.168.1.11:3671 – establishing connection failed, error response from control endpoint /192.168.1.11:3671: could not accept new connection (maximum reached)
    13:32:35:513 ERROR calimero.tools.ProcComm – completed with error
    tuwien.auto.calimero.KNXRemoteException: error response from control endpoint /192.168.1.11:3671: could not accept new connection (maximum reached)
    at tuwien.auto.calimero.knxnetip.ClientConnection.connect(ClientConnection.java:201)
    at tuwien.auto.calimero.knxnetip.KNXnetIPTunnel.(KNXnetIPTunnel.java:158)
    at tuwien.auto.calimero.link.KNXNetworkLinkIP.newConnection(KNXNetworkLinkIP.java:309)
    at tuwien.auto.calimero.link.KNXNetworkLinkIP.(KNXNetworkLinkIP.java:201)
    at tuwien.auto.calimero.link.KNXNetworkLinkIP.newTunnelingLink(KNXNetworkLinkIP.java:132)
    at tuwien.auto.calimero.tools.ProcComm.createLink(ProcComm.java:487)
    at tuwien.auto.calimero.tools.ProcComm.start(ProcComm.java:323)
    at tuwien.auto.calimero.tools.ProcComm.run(ProcComm.java:274)
    at tuwien.auto.calimero.tools.ProcComm.main(ProcComm.java:260)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at tuwien.auto.calimero.tools.Main.main(Main.java:117)

    Do you know what is can be wrong?

    Thanks in advance.

    Reply

    • Hi Sergio,

      Error Message: “could not accept new connection (maximum reached)

      Can you restart your system and try again?

      Michael

      Reply

  9. Thank you for the script. Maybe you could change the wget command to get the github version because the version at michlstechblog.info/blog/download/shell_scripts/calimero.sh doen’t work (Maven too old).

    I had another problem. My raspberry pi is only connected with by wlan0 so calimero failed to start. sed s/eth0/wlan0/g on /etc/calimero/server-config.xml
    fixed it.

    Reply

  10. hi michael,
    i can install it on openhabian, but not work….

    [20:36:53] root@openHABianPi:~# ps ax|grep tuwien.auto.calimero.server.Launcher
    1201 pts/0 S+ 0:00 grep –color=auto tuwien.auto.calimero.server.Launcher
    [20:37:15] root@openHABianPi:~# journalctl -xu knx
    — No entries —
    [20:37:33] root@openHABianPi:~# knxtools groupmon -m knxip 192.168.82.101
    -su: knxtools: command not found

    Reply

    • Hi Alberto,

      I’ve updated to the script the latest version. Please try again.

      Michael

      Reply

Time limit is exhausted. Please reload CAPTCHA.

Original Theme by Schiy · Powered by WordPress