Smart home is a growing domain where many manufacturers are developing their own products. These devices must send data to be “smarter” and to meet the user’s needs. However, if we want to connect a smart switch of a brand A to a roller shutter of a brand B, the two products must be able to understand each other. That’s why KNX Association established an open communication standard that does not depend on the manufacturer.
Unlike the vast majority of systems, KNX does not use a master / slave architecture. Instead, the “smartness” of the system is distributed across all devices. The data exchange is made in the form of telegrams containing actions to be carried out. For example, if a user presses a switch corresponding to the closing of a shutter, a microcontroller embedded in the switch will send a “telegram” (KNX data packet) to the microcontroller embedded in the shutter’s controller to ask him to close it. The latter will then use this information to control the motor that will lower the shutter. This example is very basic but we could imagine some application like automatically closing the shutter after a specific hour of the day or when there is nobody in the house.
To program these algorithms, KNX provides a software tool called ETS, which can recognize and program all the components in the network simultaneously, according to a user-defined scenario.
Can I setup my own KNX network ?
Yes! That’s what we are going to do in this tutorial, using only off-the-shelf products, and the official software. Then, in our next tutorial we will look at how you can connect your own device to the bus to listen to the telegrams, and even send your own telegrams.
In this tutorial, we will use 4 devices:
- The power supply: KNX-20E-640
- The USB interface: 5WG1148-1AB12
- A push button with built-in LED: 5WG1115-3AB21
- An Input/Output interface: 5WG1220-2AB21
Obviously, we need some cables to connect the devices together. We used a 4-wire cable even if we only need two of them. The PHN811300 is made for KNX applications and can be used to connect to any KNX device.
The KNX Association developed a software tool called ETS, to program all the devices connected to the bus at the same time. You have to sign up at my.knx.org (it’s free) to be able to download ETS. After logging in, go to Downloads > Software and download the ETS5 Professional executable. Install it on your computer.
We want to make a smart house model as simple as possible using the devices mentioned above. At our disposal, we have a switch with an integrated LED and an Input/Output Interface. The easiest way is to configure the system so that a push on the button turns on a LED connected to an output. The principles is exactly the same for more complex scenarios, involving more elaborate input or output (fan, blinds, valve, heater…).
To communicate with the KNX bus, we must use the USB interface. Moreover, the bus must be powered by the power supply listed above.
The electrical grid represented in this schema is a 220V power outlet. Depending on the power supply you chose, the adapter connecting the two might differ. In our case, the adapter is a neutral/line two cables to power outlet connection.
The USB interface is connected to the computer by a type B USB cable.
The LED connected to the input/output interface called “GPIO” in the schema above, will be connected to the channel A in our case. See the interface datasheet linked above for further details.
Setting up ETS
Once the wiring is done, launch ETS and start a new project by clicking the ‘+’ button.
ETS works with different panels, when it opens for the first time, the “Buildings” panel appears. This panel is useful for large projects where you want to divide it into rooms. This panel is not interesting in our case, so we can close it. The first one we are going to look at, is the “Catalogs” panel. Open it by clicking Workplace in the menu toolbar. Then select Catalogs.
Here, we have to import the devices we are going to use. Go to the manufacturer product page and download the .knxprod file.
For example, the USB interface files can be found here by clicking ETS4/5. We have to download this file for each device (use the device’s manufacturer’s name)
Then go back to ETS, click “Import…” and select the .knxprod file. Choose the correct device when asked to import multiple ones, choose the desired language when asked and install the plug-ins if prompted. Some plugins may require .NET framework 1.1 which you can download from Microsoft official site. Close ETS before launching the setup.
Once the import is done for each device, open the “Devices” panel: in the menu toolbar click Workplace > Open new panel > Devices. Drag and drop the devices you want to use in the project:
We are done with the “Catalog” panel and we can close it now. The next step is to virtually connect these devices by using the panel named “Topology”. Open the panel by clicking Workspace > Open New Panel > Topology. Drag and drop the devices into the new window, into New area > New line. Note that an individual address is attributed to the device when you add it to the “Topology” panel.
To configure the devices, hit the “Parameter” tab beside Associations (bottom of the screen) and customise the desired behaviour. In our case, we choose to switch on the push button built-in LED when the light is on.
For the Input/Output block, we want to set a channel as an Output. We chose Channel A then we set it up as a LED output.
In order to tell ETS how these devices will interact, we need to create “Group Addresses”. Open it (Workspace > Open new panel > Group addresses) and create a “Main group”, a “Middle group” and a “Group address”. You should see something like:
In this group address, we have to put devices that are related to the same function. For instance, in our case, the function “switch on/off the LED” involve the push button and the LED. Drag and drop the push button and the LED interface from the Topology window into the Group Address we just created.
Now everything is set up, let’s start by connecting the computer to the USB interface. Switch on the power supply and go to the bus settings (Click ETS on the menu toolbar then, choose the Bus tab).
If everything is OK, ETS will recognize the interface automatically. We are now ready to upload the “program” into the devices. Go back to the project view, select the line in “Topology” and press the “Download” button.
ETS will ask to press the programming button (also called learning button sometimes) for each device. You can find where this button is located by taking a look at the product’s datasheet.
For the devices we used, we will put pictures of where the programming button is so it is easy to use.
For the input/output interface:
And for the push-button (after dismounting the button on top, the device will look like this):
When the upload is done, the LED connected to the Output bloc (on channel A in our case) and the built-in LED of the push button should be turned on when pressing the push button and turned off if pressed again.
That’s it! We just completed our first KNX network, and in our next article we will hack it an Arduino to read and send telegrams.