In my last post, I discussed how to get OpenHAB up and running. For the "Forget me not" Design Challenge, one of the sponsors is EnOcean and they were gracious enough to supply us with a basic kit and EnOcean Pi. This is a brief write up of what "I think" is happening. If someone knows something I don't, please feel free to comment and I will be more than happy to make corrections.

2014-08-06 14.28.25.jpg


EnOcean Pack


The EnOcean Sensors are Energy harvesting modules. This means that they don't need (standard) batteries. They either have a solar panel or some other way of generating the required amount of energy. I won't go into the details but I personally think it's brilliant. Each sensor is able to transmit it's data such as contact, switch or temperature data by default and they all talk to a "Mother Node" called the EnOcean Pi. You can buy sensors individually as well as the EnOcean Pi module which you can mount onto your application board. The output of the EnOcean Pi is a Serial(UART) data stream when events occur. To my understanding the EnOcean Pi listens to the wireless transmissions from sensors and if a VALID message is heard, it generates a message in a predefined format on a wired serial bus at a fixed baud rate. Hence the EnOcean Pi essentially validates wireless data and then funnels all the wireless data to a single two wire serial bus.


To my understanding the EnOcean Pi has just 4 pins which connect to the Raspberry Pi. They are the 3.3V, GND , UART TX and UART RX. I will be doing some experiments to verify the same very soon. I have not seen any reference for commands to be issued to the EnOcean Pi hence I assume it is not a programmable device. OpenHAB needs to essentially listen to the UART and parse messages to the Event Bus. That is what the bindings do... I think. The next section will document how to interface OpenHAB with the EnOcean Pi and Sensors.


Now since every sensor is talking to a single EnOcean Pi, we need a method by which we can distinguish between the sensors. By type? Yea but what if my system uses say 2 or more contact switches then what? To remedy this situation, each EnOcean sensor has a unique ID which looks like 12:34:56:AB. In addition to these IDs we also have something called an equipment profile or EEP. These tell us what kind of info will be generated by a sensor. Like a temperature sensor will generate numbers and contact sensors will generate OPEN/CLOSE data. Once you have these two pieces of information, we are good. So where do we get this info?


The ID is sent by each sensor to identify itself and the EPP is available in the documentation. I am attaching the files with this post for reference. Please note it may get outdated immediately or with time so google it if possible. In order to get the ID we will first install some thing called FHEM and the details are given in the proceeding section.


FHEM Adventure


FHEM is a perl based Home Automation Solution like OpenHAB but OpenHAB is way cooler  . We need FHEM to get the device IDs because EnOcean does not print them on every device. FHEM can be installed by executing the following commands at the command prompt.


sudo apt-get install perl libdevice-serialport-perl libio-socket-ssl-perl libwww-perl
sudo apt-get install –f
sudo dpkg –i fhem-5.5.deb


Now reboot. Once the system reboots, FHEM is automatically started. Point your favorite browser to http://raspberrypi:8083/fhem The screenshot below is what you should see.



(image from attached doc FHEM install)


Don't see the EnOcean link yet? Don't worry. Trigger one of the sensors liek the contact switch or the rocker. This will cause the EnOcean Pi to send a message over the uart which will make the FHEM system recognize your EnOcean Pi. Click on the EnOcean link and you should see the Sensors and their IDs. Great. In case you don't see anything, make sure your sensors are charged. The rocker works the best.


Now you have the IDs for YOUR PARTICULAR sensors. Next the EEPs. I'll make it simple. The profiles are as follows:


  • Rocker: F6:02:01 (Light and Blind Control - Application Style 1)
  • Contact sensor:D5:00:01 (Single Input Contact)
  • Temperature sensor: A5:02:05 (Temperature Range from 0° to 40°)


At this point FHEM will always start at startup and will lock the serial port. You can uninstall it OR disable autostartup by issuing the following command.


sudo update-rc.d fhem disable


Now we can start configuring OpenHAB. Let's go!


Configuring OpenHAB for EnOcean Pi and sensors


The first thing you need to do BEFORE you start OpenHAB is to modify the script to include info on the serial port. For the raspberry Pi, the serial port is /dev/ttyAMA0. Open the file in your favorite editor like nano or leafpad and add the following to the java command. 


save and close. Now additionally we need to tell the OpenHAB binding where the serial port is so we need to edit the openhab_default.cfg file and make changes to the following section.


################################# EnOcean Binding ##################################### 
# EnOcean USB adapter serial port 


Save and close. OpenHAB now knows where EnOcean Pi is connected so now we can start using the OpenHAB designer. Edit the existing demo.items file or create a new one and add the following.


Switch Rocker (All) {enocean="{id=FE:FF:FE:F0, eep=F6:02:01, channel=B}"} 
Number Temperature "Temperature [%.1f °C]" <temperature> (All) {enocean="{id=00:88:F0:3E, eep=A5:02:05, parameter=TEMPERATURE}"} 
Contact Window "Contact [%s]" <contact> (All) {enocean="{id=FE:FF:FE:FB, eep=D5:00:01, parameter=CONTACT_STATE"}


In the above, replace the id with your own sensor ids. Take a look at the bindings wiki for more details. (You need to have a Group All in the file as well.)


The Items file is basically a list of "items" including sensors and switches that are connected to OpenHAB. You can have dummy items with no bindings as well. Think of these as variables declarations in a program. Now we need to make OpenHAB display these items. The gui is generated by OpenHAB but what and how to be displayed are shown by the demo.sitemap. Note that both have the same name but different extensions. You can have multiple files like demo1.sitemap and demo1.items but on the RPi I recommend having just one. Additionally, just keep the bindings you need and delete the rest. Trust me on this...


In the demo.sitemap file, do the following:

sitemap demo label="Main Menu"
Frame label="EnOcean Pi"
  Switch item=Rocker label="Rocker" 
  Text item=Temperature valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"] 
  Text item=Window


Start OpenHAB is you have not started it yet and point your favorite browser to http://<address-of-pi:8080/

You should see the items in your browser and you should be happy


Now it's time for you to play with OpenHAB. Read the documentation and google for additional help. I myself will not be doing much with OpenHAB till I have the hardware ready so it will be a while before I post anything about software.


Kai sir has published a GREAT tutorial HERE which is better than what I have written so please feel free to refer it as well. Comments and Likes are appreciated. Lastly " "smart home" that only allows you to purchase one brand of device is not really Smart."  And hence I am preparing hardware that is really for the REAL Smart Home.

Catch you next time.




<< Previous Post | Table Of Contents | Next Post >>