Raspberry Pi: eibd with a KNX USB Interface
a reader of my post asks me if it possible to connect the eibd bus with a KNX USB Interface instead of the TPUART board. These interfaces are available by several vendors(Siemens, Gira, Merten etc.).
I have no KNX USB Interface for testing and therefore Bastian Herzog did that part and supports me to improve the script. Very special thanks to him. Together we have get this started.
As descripted in the previous post setup your Raspberry Pi with raspbian:
Install Raspbian as operating system for the Raspberry Pi. All developing tools to compile the eibd daemon are already included. For the current version you need a SD card with at least 4GB. The installation of rapbian is described here in detail. Its simple:-)
When your operating system is up, login as user pi and set a static IP Address to ensure the gateway is always reachable at the same IP Address. Edit the following files with your favorite editor. For me its vi :-).
pi@raspberry~: $ sudo vi /etc/network/interfaces
comment the following line
# iface eth0 inet dhcp
insert your static TCP/IP parameter.
iface eth0 inet static
On Debian Jessie also add the route to the eibnet mulicast address (in debian wheezy this is set by the init script) and set the interface eth0 from “allow-hotplug” to “auto” so it will not be handled by systemd, to activate the old style debian network config.
iface eth0 inet static
post-up route add -net 184.108.40.206 netmask 255.255.255.255 eth0
pre-down route del -net 220.127.116.11 netmask 255.255.255.255 eth0
adjust address, subnetmask and gateway. Open /etc/resolv.conf to set a DNS Server. In home environments this is usually the DSL Router.
pi@raspberry~: $ sudo vi /etc/resolv.conf
Reboot your device and login again. I preferred a remote login over ssh from my workstation.
I wrote a script install_eibd_usb.sh which compiles and installs the eibd daemon. You can download it below. The script needs an active internet connection. Check the connection.
pi@raspberry~: $ ping -c 2 www.heise.de PING www.heise.de (18.104.22.168) 56(84) bytes of data 64 bytes from 22.214.171.124: icmp_req=1 ttl=128 time=8.551 ms 64 bytes from 126.96.36.199: icmp_req=2 ttl=128 time=9.680 ms --- 188.8.131.52 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1002ms rtt min/avg/max/mdev = 0.551/0.615/0.680/0.069 ms
Time to start installing eibd. The script must be run as root because some files are copied and modified in locations where only root have the appropriate permissions. The access to /dev/ttyAMA0 is not mandatory it is only for the TPUART backend.
What the script does:
- Check for root permissions
- Download and compile pthsem
- Download bcusdk, but compile eibd only
- installing eibd binaries to /usr/local/bin
- create a init script /etc/init.d/eibd
- Add a user and group eibd with group membership dialout (to access serial device /dev/ttyAMA0)
- Add user pi to eibd group
- Disable bootmessages on serial interface /dev/ttyAMA0
- Disable console on serial interface /dev/ttyAMA0
- Define udev rules to accessing the KNX USB Device at a low level layer by group eibd. I have added all interfaces for which I found a USB Vendor- and ProductID. Maybe your device is not in the list, then you have to add this manually to file /etc/udev/rules.d/90-knxusb-devices.rules. Determine the ID by lsusb.
For the following devices a udev rule is installed (Source KNX User Forum).
|KNX USB Interface||Vendor ID||Product ID|
|Siemens KNX/EIB-USB Interface (Flush mounted)||0e77||0111|
|Siemens KNX/EIB-USB Interface (DIN rail)||0e77||0112|
|Siemens OCI700 Service Interface||0681||0014|
|Merlin Gerin KNX-USB Interface (Flush mounted)||0e77||0141|
|Hensel KNX-USB Interface (Rail mounted)||0e77||0121|
|Busch-Jaeger KNX-USB Interface (Flush mounted)||145C||1330|
|Busch-Jaeger KNX-USB Interface (surface mounted)||145C||1490|
|ABB STOTZ-KONTAKT KNX-USB Interface (MDRC)||147B||5120|
|Feller KNX-USB Data Interface||135E||0026|
|JUNG KNX-USB Data Interface||135E||0023|
|Gira KNX-USB Data Interface||135E||0022|
|Berker KNX-USB Data Interface||135E||0021|
|Insta KNX-USB Data Interface||135E||0020|
|Weinzierl KNX-USB Interface (Flush mounted)||0e77||0102|
|Weinzierl KNX-USB Interface (RS232)||0e77||0103|
|Weinzierl KNX-USB Interface (Rail mounted)||0e77||0104|
|Tapko USB Interface||16D0||0490|
|Hager KNX-USB Data Interface||135E||0025|
|Preussen Automation USB2KNX||16D0||0492|
|Merten KNX-USB Data Interface||135E||0024|
|b+b EIBWeiche USB||04cc||0301|
If there are further more, please let me know and I will integrate them to script.
Start a root shell, get the script.
pi@raspberry~: $ sudo su root@raspberry~: # root@raspberry~: # wget http://michlstechblog.info/blog/download/shell_scripts/install_eibd_usb.sh
The highlighted eibd features are enabled. Alter the script if you need additional features.
–enable-ft12 enable FT1.2 backend
–enable-pei16 enable BCU1 kernel driver backend
–enable-tpuart enable TPUART kernel driver backend (deprecated)
–enable-pei16s enable BCU1 user driver backend (very experimental)
–enable-tpuarts enable TPUART user driver backend
–enable-eibnetip enable EIBnet/IP routing backend
–enable-eibnetiptunnel enable EIBnet/IP tunneling backend
–enable-usb enable USB backend
–enable-eibnetipserver enable EIBnet/IP server frontend
–enable-groupcache enable Group Cache (default: yes)
–enable-java build java client library
Start the script. This should be run about 20 minutes. Do not execute update-rc.d on debian jessie.
root@raspberry~: # chmod +x ./install_eibd_usb.sh root@raspberry~: # ./install_eibd_usb.sh && update-rc.d eibd defaults
After the script has finished. eibd, findknxusb, vbusmonitor2, groupwrite and some other stuff should be installed at /usr/local/bin, the init script eibd in /etc/init.d and the startup links in /etc/rc3.d must exists. At the end of the script a warning message “insserv: warning: script ‘mathkernel’ missing LSB tags and overrides” is shown. This can be ignored.
root@raspberry~: # ls -l /usr/local/bin ..... -rwxr-xr-x 1 root staff 471140 Feb 18 22:14 eibd -rwxr-xr-x 1 root staff 10788 Feb 18 22:14 vbusmonitor2 ..... root@raspberry~: # ls -l /etc/init.d/eibd -rwxr--r-- 1 root root 2142 Feb Feb 18 22:14 /etc/init.d/eibd root@raspberry~: # ls -l /etc/rc3.d/*eibd lrwxrwxrwx 1 root root 14 Feb 18 22:14 /etc/rc3.d/S18eibd -> ../init.d/eibd
Reboot your device
root@raspberry~: # reboot
The eibd options and features are defined at variable EIBD_OPTIONS in file /etc/init.d/eibd. Currently are defined:
- EIB Busaddress of the daemon 1.1.128
- EIBnet/IP server
- EIBnet/IP Routing
- EIBnet/IP Tunneling
- Answer discovery and description requests
- Listen on UNIX domain socket /tmp/eib
- Listen on TCP port, default 6720
- the USB device is automatically recognized by findknxusb
This gets a detail list of command line parameter
root@raspberry~: # eibd -?
After the reboot and if your Raspberry KNX USB Interface is connected the eibd should running. For example:
root@raspberry~: # ps ax|grep eibd 2996 ? Ss 0:00 /usr/local/bin/eibd -d -D -T -R -S -i -u --eibaddr=1.1.128 usb:1:6:1:0:0
If the process is running. Check if you see EIB packets on wire.
pi@raspberry~: # vbusmonitor1 ip:localhost LPDU: BC 11 17 00 03 C1 00 81 06 :L_Data low from 1.1.23 to 0/0/3 hops: 04 T_DATA_XXX_REQ A_GroupValue_Write (small) 01 LPDU: CC :ACK LPDU: BC 11 17 00 03 81 00 81 46 :L_Data low from 1.1.23 to 0/0/3 hops: 00 T_DATA_XXX_REQ A_GroupValue_Write (small) 01 LPDU: CC :ACK
Update 2 13.02.2015:A user reports that the USB devices (ID 0e77:0104) from Weinzierl or Lingg&Lanke has the problem that telegrams can be send to but no pakets are received from the KNX bus. This is a known issue and already discussed at the bcusdk mailing list.
Solution: Determine the current USB address of the KNX USB interface by query the eibd process. Login as root.
pi@raspberry~: $ sudo su - root@raspberry~: # ps ax|grep eibd 2901 ? Ss 0:00 /usr/local/bin/eibd -d -D -T -R -S -i -u --eibaddr=1.1.128 usb:1:4:1:0:0
root@raspberry~: # /etc/init.d/eibd stop
Query the size
root@raspberry~: # bcuaddrtab usb:1:4:1:0:0
If not a size of 0 is reported, means that telegrams are filtered, clear the address table size to receive everything from the bus. Specify only the first two digits of the USB Bus address!
root@raspberry~: # bcuaddrtab -w 0 usb:1:4
reboot your the PI. From now on you should receive all telegrams from the bus.
See also the post “EIB/KNX IP Gateway and Router with TPUART buscoppling unit”
Update 19.06.2016: I’ve added the first release of a script to compile and install knxd. knxd is a fork of eibd. Any comments are welcome. Configfile is /etc/default/knxd, Socket /tmp/knx. See this EIB/KNX Router with knxd