A system with support for 64 bit integer datatypes (C++ uint64_t) must be used. Usually, this is also the case for 32 bit architectures such as the Raspberry Pi or the Tinkerforge Red Brick. If 64 bit integers are not supported, Sensorlogger will show undefined behavior, because UNIX time stamps are processed with millisecond resolution.
Known software requirements for Linux:
- C++11 compiler, such as GCC 6 or higher
- Paho MQTT C and C++ libraries (and their dependencies)
- Libcurl and its C++ developer tools
The software is available on Github, or you can download the source code here.
The source code is available here under the MIT license. The following guide will give instructions on how to compile and run Sensorlogger.
sensorlogger.tar.gz Version 1.1 / 331 KB
There is no warranty given for correct operation of the software.
At first, the Paho MQTT libraries for C and C++ must be installed. You can get packages for Arch-based distributions for the AUR: paho-mqtt-c-git and paho-mqtt-cpp-git. For Debian-based systems (e.g. Raspberry Pi, Tinkerforge Red Brick) we have to compile and install the libraries on our own. To do this, we need to make sure that we already have all the required packages installed:
apt-get install libssl-dev build-essential gcc make apt-get install cmake cmake-gui cmake-curses-gui
We now use git to download the Eclipse Paho MQTT C library, and compile and install it according to its documentation:
git clone https://github.com/eclipse/paho.mqtt.c cd paho.mqtt.c make install
In the next step follows the Eclipse Paho MQTT C++ library. If you also want to install the documentation and compile the examples, set the corresponding flags in the following command in the third line to TRUE.
git clone https://github.com/eclipse/paho.mqtt.cpp cd paho.mqtt.cpp cmake -Bbuild -H. -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=FALSE sudo cmake --build build/ --target install sudo ldconfig
We need libcurl to establish HTTP(s) connections in order to fetch JSON structures or connect to a HomeMatic XML-API.
apt-get install libcurl4
In addition, the developer tools for libcurl are required:
apt-get install libcurl-dev
The virtual package libcurl-dev offers different implementations. All of them should work, I have tested:
apt-get install libcurl4-gnutls-dev
To download and compile Sensorlogger, run
git clone https://github.com/davidplotzki/sensorlogger cd sensorlogger make
To run Sensorlogger, you can pass the path to a configuration file:
If you don’t provide the path to a configuration file, Sensorlogger will look for one under the name sensorlogger.json in its current working directory. If it doesn’t find one, it will quit.
Sensorlogger as a service
It is recommended to run Sensorlogger with restricted privileges. The setup procedure for an automatic startup at boot time depends on the distribution. For Debian/Raspbian, I use a service file for systemd like the one shown below. It assumes that the executable file named sensorlogger is located in the user’s home directory at /home/username. The configuration file called config.json is also located there in this example.
# /etc/systemd/system/sensorlogger.service # ------------------------------------------ # systemctl daemon-reload # systemctl enable sensorlogger [Unit] Description=Sensorlogger [Service] WorkingDirectory=/home/username ExecStart=/home/username/sensorlogger /home/username/config.json User=username Group=users [Install] WantedBy=multi-user.target
You could then use the following two commands to load the service into systemd and enable its automatic startup:
systemctl daemon-reload systemctl enable sensorlogger