Hi OpenHAB friends,
In this tutorial I wand to give you a step by step guide for installing KNXD in combination with a Raspberry 3 and the Busware One Wire & KNX header called “ROT”
I’m a Linux beginner and the most gides were not easy enough for me.
To avoid, that you need as much time and nerves as me…let’s go
The main goal of this tutorial is building a cheap and less space using KNX IP Gateway. Of course another goal is to connect your KNX System to openhab.
1. Genral conditions:
Hardware:
- Raspberry Pi 3B
- Busware ROT a RTC-OneWire-TPUART (EIB/KNX) extension for Raspberry Pi (New “Pigator” version)
busware.de : ROT
Software:
- openHABian image v.2.4.0
- KNXD master Branch v.0.14
2. Update System
sudo openhabian-config
choose "02 Upgrade System"
3. Install ROT Module
- Install Hardware
- Prepare Serial Interface
Disable the Bluetooth Modul of the Pi which is using the Serial interface you will need
sudo nano /boot/config.txt
add this at the end of the file
dtoverlay=pi3-disable-bt
save with ctrl+o and close with ctrl+x
sudo nano /boot/cmdline.txt
delete the following arguments
console=serial0,115200 console=tty1
save with ctrl+o and close with ctrl+x
disconnect the BT modem from the UART
sudo systemctl disable hciuart
Create the specific KNX Serial interface
First collect two parameters of the interface, we query them with:
sudo udevadm info -a /dev/ttyAMA0 | grep KERNELS.*serial
It is supposed to answer something like KERNELS=="3f201000.serial"
sudo udevadm info -a /dev/ttyAMA0 | grep {id}
The answer is most likely ATTRS{id}=="00241011"
Keep these two results in a handy place, you’ll need them in the next step: Edit the udev file for the knx interface:
sudo nano /etc/udev/rules.d/70-knxd.rules
The file contains of just one line. Insert the following line with your(!) results of KERNEL
request and ATTRS ID
That line look like
ACTION=="add", SUBSYSTEM=="tty", ATTRS{id}=="00241011", KERNELS=="3f201000.serial", SYMLINK+="ttyKNX1", OWNER="knxd"
Reboot the System
sudo reboot
Test the interface
ls -ahl /dev/ttyKNX1
Answer: lrwxrwxrwx 1 root root 7 Feb 1 14:20 /dev/ttyKNX1 -> ttyAMA0
ls -ahl /dev/ttyAMA0
Answer: crw-rw---- 1 knxd dialout 204, 64 Feb 1 23:42 /dev/ttyAMA0
4. Install KNXD
first, install build tools and dependencies
sudo apt-get install git-core build-essential
now get the source code
git clone GitHub - knxd/knxd
now build+install knxd
cd knxd
git checkout master
dpkg-buildpackage -b -uc
if this step fails (it will probably) because of missing dependencies,
“Unmet build dependencies”: data1 (>123) data2 (>123) data3 (>123) …
cd…
sudo apt-get install data1
sudo apt-get install data2
sudo apt-get install data3
…
and try that step again
Install KNX Tools
cd …
sudo dpkg -i knxd_.deb knxd-tools_.deb
reboot system
sudo reboot
4.1 Set the KNXD_OPTS
sudo nano /etc/knxd.conf
Add a # to the existing line and add the line below
# configuration for knxd.service
# KNXD_OPTS="-e 0.0.1 -E 0.0.2:8 -u /tmp/eib -b ip:"
KNXD_OPTS="-e 1.1.0 -E 1.1.100:28 -D -T -R -S -b tpuarts:/dev/ttyKNX1"
you can set several more options please look knxd --help
and check the github
5. Status & Start Stop of KNXD
Status:
systemctl status knxd.socket && systemctl status knxd.service
Answer should be:
(The Dots before knxd.socket and knxd.service must be green)
[10:33:10] openhabian@openHABianPi:~$ systemctl status knxd.socket && systemctl status knxd.service
● knxd.socket - KNX Daemon (socket)
Loaded: loaded (/lib/systemd/system/knxd.socket; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-02-02 23:25:47 CET; 3 days ago
Listen: /var/run/knx (Stream)
[::]:6720 (Stream)
Feb 02 23:25:47 openHABianPi systemd[1]: Listening on KNX Daemon (socket).
● knxd.service - KNX Daemon
Loaded: loaded (/lib/systemd/system/knxd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-02-04 11:21:29 CET; 1 day 23h ago
Main PID: 26315 (knxd)
CGroup: /system.slice/knxd.service
└─26315 /usr/bin/knxd -e 1.1.0 -E 1.1.100:28 -D -T -R -S -b tpuarts:/dev/ttyKNX1
Feb 04 11:21:29 openHABianPi systemd[1]: Starting KNX Daemon...
Feb 04 11:21:29 openHABianPi systemd[1]: Started KNX Daemon.
Start:
sudo systemctl start knxd.socket && sudo systemctl start knxd.service
Stop:
sudo systemctl stop knxd.service && sudo systemctl stop knxd.socket
6. Try it out
Now you should have a working KNX ETS5 Gateway and you can program your KNX System via your Raspberry
6.1 Test KNXD
Open the KNXD Busmonitor and watch what is happening when you send commands (by hardware) on the Bus
knxtool groupsocketlisten ip:localhost
you can close monitoring with ctrl+c
Now test if you can write something to the Bus
knxtool groupswrite ip:localhost 1/2/4 1
in this case 1/2/4 is the group Adress of ETS Sofware
and the last “1” set’s “on” ; “0” set’s “off”
7. Setup OpenHAB Gateway to KNXD
Install KNX Binding using Paper UI
You have two ways creating Devices and Items
- Using Paper UI
- Using the Text Editor Configunration
I would recomment 2. because of a better overview and better backup options.
In this Guide I show you only option 2
- Create a Items file in the Items folder named for example
knx.items
- Here my path of Windows Samba share:
\\OPENHABIANPI\openHAB-conf\items
-
Insert the Gateway configuration
Bridge knx:ip:bridge “KNXD Gateway” [
ipAddress=“192.168.1.101”, // Use LAN IP of your Raspberry Pi
portNumber=3671,
localIp=“192.168.1.101”, // Use LAN IP of your Raspberry Pi
type=“TUNNEL”,
readingPause=50,
responseTimeout=10,
readRetriesLimit=3,
autoReconnectPeriod=1,
localSourceAddr=“0.0.0”
]
8. Thanks to
Tutorial build together from several guides. Thanks to: