In my last couple of blog posts, I did a brief overview of the EnOcean Pi sensor kit from Newark and demonstrated how to compile and run the example code using a Raspberry Pi. In this blog post, I will show a real world example – a four-channel remote control built using the EnOcean Pi in conjunction with the EnOcean pushbutton module.
Each pushbutton on the module is used to control a separate channel. When a button is being pushed, the duration of the hold time is used to determine whether it is an “on” command or “off” command. If the hold duration is short (e.g. <1s) the load on the corresponding channel is turned on and if the hold duration is long (e.g >1s), the load is turned off. If an “on” command is send when the channel is already in “on” state, the channel will remain be on. The same goes for the “off” state.
Because the output current is limited for the IO pins, a transistor is added to drive each load for each channel. In this case the load used are four LEDs (one for each channel). Technically speaking, they could be powered directly using the IO pins with proper current limiting resistors. Also, the output voltage is limited to 3.3V. With the circuit provided, you can easily change the LED to a relay for controlling power devices.
The code for this simple remote control can be downloaded towards the end. To compile the code, you will need to copy the source code into the example folder (where other EnOcean link example code is located) and use the following command to compile. If you are using other directory structures, you may need to copy the eoLink.h header file to the directory where your source file is located or you can add the EOLink directory to your include path.
gcc switchtest.cpp -I../EOLink/ -lrt -lEOLink -lwiringPi -o switchtest
This code uses WiringPi, an Arduino like library for Raspberry Pi. The picture below shows the experiment setup. From the phone screen on the left you can see the SSH session output from the Raspberry Pi. If you look closely you can see each message when a button is pressed or released.
Here is a short video showing the remote control in action:
View on YouTube in a new window