Homeautomation with KNX and Raspberry Pi (from 2013)

---- an old, but still interesting post from the year 2013 ----

As I enjoy IT related topics I like to automate things in my household. This is the reason why I have decided to use KNX for building automation in my house

Here is an image from my future visualization, runnable in every browser.

This visualization will be displayed on a wall-mounted Android tablet. However, basic controls (for example for switching of lights) will still be possible with normal physical switches.

I have decided to use KNX for the following reasons:
  • no single point of failure like with PLC solutions (example Loxone), beside the power supply
  • availability from various vendors
  • open source software available, for example the bcu-sdk

As a complete newb in this area I needed to read up lots of information. As I have experience as software developer in industrial automation, it was fairly easy. After a short period of time I had a list of components which I ordered from www.voltus.de .

Now my test setup looks as followed:


The following components are integrated:
  • Power supply
  • 20x switching actuator
  • 4x shutter actuator
  • 6x heating actuator
  • USB interface
  • IP interface
  • EIB-PC
  • 1 Gira smartsensor
  • 4 conventional switch, connected to the bus via a switching interface
  • 2 light bulbs
  • Raspberry Pi

The test setup is already configured. Beside using physical switches it is also possible to use a web interface to control the light bulbs. Controlling heating will only be possible via web interface, I think I won't change the setpoint temperature too often.

The necessary components are:

After some problems in the beginning I decided to note all the steps made as a reference for later:
  • Get the Raspberry Pi image for smarthome.py and smartVISU from the following link and install it: https://github.com/mknx/smarthome/wiki/SmartHome.pi
  • Use the preexisting eibd if an IP interface is used for communication. If USB is used, the eibd needs to be patched and recompile:
  • execute "apt-get install patch automake autoconf unzip libtool pkg-config" on the shell of the Raspberry Pis
  • create a directory /usr/local/src/bcusdk
  • If a cEMI USB interface is used (like MDT KNX USB Interface), download the cEMI patch from here or directly here and copy it to /usr/local/src/bcusdk,     
  • Download the USB patch from here or directly here and copy it to /usr/local/src/bcusdk   
  • execute the following commands:
export LD_LIBRARY_PATH=/usr/local/lib
cd /usr/local/src/
wget https://www.auto.tuwien.ac.at/~mkoegler/pth/pthsem_2.0.8.tar.gz
tar xvfz pthsem_2.0.8.tar.gz
cd pthsem-2.0.8
./configure
make
make install
cd ..
git clone git://bcusdk.git.sourceforge.net/gitroot/bcusdk/bcusdk
cd bcusdk/
patch -p1 < bcusdk-usb-cemi.patch
patch -p3 < read-within-callback.patch
autoreconf -fi
./configure --with-pth=yes --without-pth-test --enable-onlyeibd --enable-eibnetip --enable-eibnetiptunnel --enable-eibnetipserver --enable-usb
make
make install
cp /usr/local/bin/eibd /usr/bin/
  • in "/etc/default/eibd" adapt the entry EIB_IF, for me the correct entry looks as followed: "EIB_IF="usb:1:4:1:0:0""
  • Find the correct entry with the command "findknxusb".
  • create a files /etc/udev/rules.d/70-persistent-eib.rules with the following content, so eibd does not need to be running as root:
# MDT Technologies GmbH: KNX-USB Interface (REG)
SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",ATTR{idVendor}=="16d0", ATTR{idProduct}=="0491",GROUP="root",MODE="0666"
  • after a reboot the "new" eibd is used.
  • Android 4.0 does not support websockets, that is why in that case you cannot use smarthome.py as backend for the visualization. An alternative without websockets is LinKNX. smartVISU already ships with such a driver. LinKNX can be installed with the following commands:
  • Download of the sources from the link above
  • Extract the sources and run "./configure", "make", "make install"
  • Create the configuration in the XML-File
  • start the daemon with "linknx -c/usr/local/linknx/linknx.xml -d"
  • Finalize the configuration in smartVISU, including the website elements for controlling various bus components, and everything should start to work
In summary I am more than satisfied with the result. The USB interface is necessary anyway for the the configuration of the bus components, so with just a a Raspberry Pi for 35$ one can get a complete and great looking visualization.

The next steps:
  • search and order the remaining KNX-components, as well as regular components, like power sockets
  • Resettle the components to the new building and configuration of the components onsite
  • Completion of the visualization
  • Get an Android tablet and mount it on the wall
  • Verify what is possible with the EIB-PC from Enertex (http://www.enertex.de/d-eibpc.html) 
  • Finish my self developed WinCC OA driver for eibd
BR, Andreas

No comments:

Post a Comment