Compiling and Running EnOcean Sensor Kit Example Code

In my previous post, I took a quick look at the EnOcean sensor kit from Newark for Raspberry Pi and tested its basic functionalities using the Fhem home automation software. In this blog post, I will walk you through the process of compiling and running the example code that comes with the EnOcean Link library. While there are instructions on how to do this, some of the information is out-dated and hard to follow. So I will provide my own step-by-step instructions here.

Raspberry Pi uses ARM architecture, so you cannot compile the code on your PC directly as most of the PCs are based on x86. Basically, there are two ways compile the code. One way is to cross-compile using the gcc arm tool chain (such as linaro). If you are interested in setting up a cross-compiling environment using Eclipse, you can take a look at this article here for detailed information.

The other way is to compile the code natively. In this blog post we will compile the code on the Raspberry Pi directly via command line. The benefit is that you don’t need any IDE setup. I assume that you are using Raspberry Pi’s default OS (Raspbian) and using the latest version of EnOcean Link source code (you will need to first register on EnOcean’s webite before you can download the latest code). Also, if you had installed Fhem before, you will need to uninstall it as it is also using the serial port that we will be using.

First, download from EnOcean (an earlier version can be found on element14’s website) and unzip it to your user directory. After unzipping, you should see three sub-directories (EOLink, examples, Tutorial) created.

All the tools necessary for building the source code can be installed via the following command on the Raspberry Pi:

sudo apt-get install build-essential libtool autoconf

Before building the example code, we need to first build the EOLink library:

cd EOLink
make all
sudo make install

configure and make each takes a couple of minutes to execute. After “make install”, you should see libEOLink libraries installed in /usr/local/lib:


Now we can go ahead and build the tutorials and examples.

The default source code for the tutorials and examples assume that you are using the USB300 gateway. When using the EnOcean Pi adapter board for the Raspberry Pi, we will need to change the port from /dev/ttyUSB0 to /dev/ttyAMA0

#define SER_PORT "/dev/ttyAMA0"

After making changes to all the source files (*.cpp), you can compile the ones you want to test with using the following command:

gcc Tutorial1.cpp -lEOLink -lrt -I../EOLink/ -o Tutorial1

This should be done within the Tutorial directory (see screenshot below):

The code under the examples directory compiles slightly differently. Each example is in its separate source cpp file and the examples are then run from sandbox.cpp.

In the following demonstration, I only enabled the gatewayExample() function inside the sandbox.cpp.

#include <stdio.h>
#include "examples.h"

int main(  int argc, const char* argv[]  )
	return 0;

I also modified the Gateway_example.cpp a bit and removed portions of code that was not used in our example. Here is the full code listing of the modified source:

#define SER_PORT "/dev/ttyAMA0"
#include "./eoLink.h"
#include <stdio.h>

void gatewayExample() {
    eoGateway gateway;
    uint16_t recv;


    //we set now the automatic RPS-Teach-IN information
    //Activate LearnMode

    while (1) {
        recv = gateway.Receive();

        if (recv & RECV_TELEGRAM) {

        if ((recv & RECV_TEACHIN)) {
            eoProfile *profile = gateway.device->GetProfile();
            printf("Teachin>Profile: Device %08X Learned-In EEP: %02X-%02X-%02X\n", gateway.device->ID, profile->rorg, profile->func, profile->type );

            for (int i = 0; i<profile->GetChannelCount(); i++) {
                printf("Teachin>Channel Count %s %.2f ... %.2f %s\n", profile->GetChannel(i)->ToString(NAME), profile->GetChannel(i)->min, profile->GetChannel(i)->max, profile->GetChannel(i)->ToString(UNIT));

        if (recv & RECV_PROFILE) {
            printf("Profile Device %08X\n", gateway.device->ID);
            eoProfile *profile = gateway.device->GetProfile();

            uint8_t t;
            for (int i = 0; i<profile->GetChannelCount(); i++) {
                if (profile->GetValue( profile->GetChannel(i)->type, t) ==EO_OK)
                    printf("--%s %u \n", profile->GetChannel(i)->ToString(NAME),t);

To comiple this example code, use the command below to generate the example binary under examples directory:

gcc sandbox.cpp Gateway_example.cpp -I../EOLink/ -lrt -lEOLink -o example

Here is a short video showing the output messages when the four buttons on the pushbutton transmitter module are pressed sequentially and the last two messages were sent from the temperature module and the reed relay module. Note that button push and button release messages are sent separately.

View on YouTube in a new window

EnOcean Serial Protocol

Because the data coming out from the EnOcean Pi is serial (via UART), we can easily capture the output data packets using a standard serial port terminal (such as GtkTerm). The following screenshot shows some captured data when the four buttons on the switch module are pressed. As you can see there are altogether eight messages because each button generates two separate events (push/release).


Let’s take a look at the first message and compare it to the EnOcean serial protocol specifications:

55 00 07 07 01 7A F6 30 00 29 49 93 30 01 FF FF FF FF 2E 00 A8

According to the specifications, all communications begin with a sync byte (0x55) and the following 4 bytes are the header (00 07 07 01). 0x7A is the CRC8H byte. Following the CRC byte are the data bytes. In the example above the data being transmitted are:

SrcID = 00294993
Status = 30
SubtelCount = 1
dBm = -46 (-2E)

Again the last byte A8 is the message checksum. So, you can easily create your own libraries and use EnOcean sensors with other MCU platforms (e.g. Arduino, MSP430, PIC, 8051, etc.).

Be Sociable, Share!


  1. Jorg says:

    Hi Kerry,
    Very nice steps but i have a problem compiling with “gcc”. So it compiled the EOLink library with CXX=g++ flag. This is the only way from cli on the pi that i have. I am then able to compile the examples but whenever i run the program it claims it is missing the library files.
    any idea’s?
    Greetz Jorg

  2. Sikit says:


    I had follow this nice tuto and I had a problem when I want compiling

    pi@raspberrypi ~/EOLink/Tutorial $ gcc Tutorial1.cpp -I../EOLink/ -lrt -lEOLink -o Tutorial1

    /usr/bin/ld: /tmp/ccjYpMow.o: undefined reference to symbol ‘operator new(unsigned int)@@GLIBCXX_3.4’
    //usr/lib/arm-linux-gnueabihf/ error adding symbols: DSO missing from command line
    collect2: ld returned 1 exit status

    I don’t understand this problem and I search a solution. I take gladly or even if there is only the beginning of explanation!!!:)


  3. Jable says:

    I have compiled the Tutorial1.cpp, and I can run it correct.
    But when I closed it by Ctrl+C, run it again ./Tutorial1 , found it cann’t myGateway.Open(SER_PORT)
    the program is just stoped there.

    • kwong says:

      Hi, since this is a demo project, I didn’t handle the Ctrl+C signal. So after you hit Ctrl+C, the serial port wasn’t properly closed and that’s why you can’t run it again using the same serial port. You will need to call gateway.Close() to properly close the connection before exiting so the next time you start the program the same serial port is available.

      • Jable says:

        Realy thanks for your help, and I know why it can’t run correctly.
        The myGateway.close() should be used in the process.
        But I am a beginner, ofen need to modify the program and run it to detect whether the code is correct.
        So can you help me or give me advice how I can easy debug my progress about the Enocean PI?

  4. Jable says:

    With your step by step,the example code can run it.
    But I don’t know why I can’t received the RECV_PROFILE in this example code , only RECV_TELEGRAM can recevied.
    The code: gateway.TeachInModule->SetRPS(0x02,0x01); is also set.

    Could you tell me what’s wrong with this problem?

  5. caesarce says:

    Thanks for the tutorial – may need an update? I’m getting the following error after running ./configure and then make all:

    /bin/bash: line 4: automake-1.14: command not found

    current apt-get installs automake-1.11 on raspbian. apt-get reports everything is at latest version. Any ideas on how to fix?

Leave a Reply to Jorg