RaspMatic + HomeMatic (IP)

Some time ago I bought a Raspberry Pi 3B with the RPI-RF-MOD extension module and the corresponding case. It’s also possible to buy all in a set: Buy link (I am not affiliated). There is an image available that works like a charm for this setup, whcih can be found here. Multiple models are supported, so make sure you download the correct release.

I am very happy with this setup. HomeMatic provides a multitude of different devices ranging from simple sensors (temperature, light, …) to quite sophisticated weather stations. There are also actuators available for heating control, blinds/shutters to alarm sirens. What is even more interetting is that general relays and comunication modules are available, so you can also build your own smart home devices!

Continue reading RaspMatic + HomeMatic (IP)

First Installation of OpenHAB2 and Homematic CCU2

OpenHAB supports a lot of different “bindings”, i.e., Hardware and Protocol solutions implemented by different companies. I started my home automation project with the Homematic binding. There are two tutorials I follow (german only):

  1. Setup of Homematic binding in OpenHAB2
  2. Implement a heating control

The first one was really easy to follow and worked straight away. I had to restart the OpenHAB service, though, which wasn’t mentioned in the documentation.

For the second tutorial I ordered the window sensor and the heating control as mentioned in the tutorial. They haven’t arrived yet, so I will post again when they arrive.

Home automation

I am currently looking into openHAB for a possible solution for our home automation. I do have an unused laptop that could easily be used for this.

What I would like to have control over:

  • room temperature
  • shutters
  • some lights
  • smoke detectors

There are different devices manufactured by different companies for each of the above. So its a question of finding the best hardware.

All of this needs to be accessible via an app on my phone.

  • notifications for alarms (smoke detectors)
  • control stuff

Seems like all of the above is provided by openHAB combined with a VPN solution, which is great!

Updates on the selected hardware and the integration will be given here in the future, stay tuned!

Render a video from a series of images

Maintained by the libav group there is a great tool called avconv. Every time I had to convert some video format to another avconv worked for me. This included being able to convert mp4 to (good quality) wmv or creating a video out of a series of images.

Imagine you want to create a timelapse and take a series of pictures to do so. Then you end up with images called something like: Capture_%09d.png. The %09d refers to an integer value with a padding of zeros so that the number will always have 9 digits. This follows the same definition as C printf() function. Creating a video from a series of images is now really easy:

avconv -r 60 -i Capture_%09d.png -s 1280x720 Video_720p.mp4

-r X : framerate of input stream is X fps
-i : define input video; a series of images in this case
-s WxH : set the resolution, can also be 1920x1080 for 1080p

And that is it! The neat thing about avconv is that the default values used for the output format are almost always on point for what you need.

But if you need to adjust something, like bitrate, avconv will always allow you to do that. Down to the rarest parameters!

Oh and about the conversion:

avconv -i video_in.mp4 -qscale 2 -s 1280x720 video_out_720p.wmv

-qscale 2 : ensure high quality. values in [2 5] seem to be fine
-s WxH : scale video (optional)


Simulated Inertial Measurement Unit (IMU)

The topic of my “Diplomarbeit” (comparable to a master thesis) was the design and implementation of a simulation environment that would allow to simulate multiple quadrotors.

It was important to get the behavior of the quadrotors as realistic as possible, since the decision to conduct experiments on real hardware was based on successful simulation results. It was therefore important for the user to be able to rely on the results. Furthermore, the simulation would be used in hardware-in-the-loop scenarios, e.g., real quadrotors avoiding collisions with simulated obstacles. Therefore, realism was a crucial aspect of the simulation environment.

Quadrotors were controlled by defining desired roll and pitch angles, a desired yaw speed, and a desired thrust of the propellers. The thrust vector stayed constant and perpendicular with respect to the quadrotor frame. Tilting the quadrotor frame would result in an acceleration in the direction of tilt. A PID controller actuated the motors in order to move the body frame accordingly. Feedback was provided by an Inertial Measurement Unit (IMU) that measured angular rates and accelerations. From these sensor readings, the orientation can be calculated and used as feedback to the PID controller. Therefore, a correct simulation of the IMU was key to a correct simulation of the flight behavior.

The requirements for a realistic simulation of the IMU were:

  1. Realistic IMU acceleration and angular velocity data that includes noise, biases, scaling, and quantization effects.
  2. Since the IMU is not always in the center of gravity, translations and rotations defined with respect to the quadrotor frame have to be taken into account.

The calculation of the simulated IMU was performed in four steps.

  1. Obtain quadrotor state information from simulation
  2. Calculate IMU acceleration and angular velocity measurements
  3. Perform scaling, add noise and biases
  4. Perform quantization and limit output

For the first step we obtained the acceleration of the quadrotor, (\(a_{local}\)), gravity (\(a_{G,local}\)), angular velocity (\(\omega_{local}\)), and the derivative of the angular velocity (\(\dot{\omega}_{local}\)) from the simulation environment.

In a second step the acceleration \(a_{1}\) and angular velocity \(\omega_{1}\) was calculated, with \(T^V_I\) being the translation and \(R^V_I\) the rotation from vehicle reference frame \(V\) to inertial reference frame of the IMU \(I\).

\(a_{1}=R^V_I (a_{local} + \omega_{local}\times (\omega_{local}\times T^V_I) + \dot{\omega}_{local} \times T^V_I -a_{G,local})\)

The angular velocity \(\omega_{1}\) was calculated by adjusting the frame of reference of the measurements obtained from simulation.

\(\omega_{1} =R^V_I (\omega_{local})\)

For the third step the measurements were scaled, biases introduced, and additive noise applied. Noise was defined using a gaussian distribution \(\mathcal{N}_{a}(0, \sigma_{a}), \mathcal{N}_{\omega}(0,\sigma_{\omega})\) for the acceleration and angular velocity. The scaling \(s_{a}, s_{\omega}\), biases \(b_{a}, b_{\omega}\), and deviations \(\sigma_{a},\sigma_{\omega}\) were defined by the user. \(\circ\) denotes point-wise multiplication.

\(a_{2} = ((a_{1}\circ s_{a}) + b_{a}) +\mathcal{N}_{a}\)

\(\omega_{2} = ((\omega_{1}\circ s_{\omega}) + b_{\omega}) +\mathcal{N}_{\omega}\)

The fourth and final step in the calculations was optional and allowed the user to simulate quantization and limit the output values of the sensor. Quantization was implemented by rounding the values to the nearest integer value. Real IMUs have an operating range and exceeding this will result in the sensor providing a maximum (or minimum) value. By defining limits this behavior can be reproduced.



A video that compares the virtual and real quadrotor flight and an analysis of the simulation environment including an in-depth comparison between simulated and real quadrotor flight can be found below.

Johannes Lächele, Antonio Franchi, Heinrich H. Bülthoff, and Paolo Robuffo Giordano (November-2012) SwarmSimX: Real-time Simulation Environment for Multi-robot Systems In: Simulation, Modeling, and Programming for Autonomous Robots, 3rd International Conference on Simulation, Modeling, and Programming for Autonomous Robots (SIMPAR 2012), Springer, Berlin, Germany, 375-387, Series: Lecture Notes in Computer Science ; 7628. Download

ps2pdf converter

converting ps or eps files to pdf always left me with the wrong cropping of the image/page and with a white border that messes up the formatiing. To avoid this I convert the files using the following command:

ps2pdf -dPDFSETTINGS=/prepress-dEPSCrop test.eps

Backup of Google Authenticator data

In case to got a new phone and want to move the Google Authenticator you will need to move the secrets from all the sites you added to the app. Or you are just curious what is actually being stored on your phone 🙂

Since I usually use the QR-code to create a new entry creating a backup is usually quite troublesome for me; I simply have no idea how to recreate the entries. But, its possible to download the apps database using adb. Well, that is if you have a rooted phone.

First you need to enable the adb USB-debugging somewhere in your settings. This depends on your phone, so you will need to look online on how to do it in your case.

After that you can connect using adb:

 :~$adb root

The root is important since otherwise you will not have access to the app-related database files. Next we can copy the authenticator database that includes all the entries of the app.

:~$ adb pull /data/data/com.google.android.apps.authenticator2/databases/databases
196 KB/s (16384 bytes in 0.081s)

Finally, we are able to open the sqlite3 database and print the info we need. I replace the actual output with some meaningless text, but its clear what the secrets are.

:~$ sqlite3 ./databases
SQLite version 2013-01-09 11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>select * from accounts;

And that was it. Now you only need to re-add the secrets in the new phones authenticator app and you’re done.


Arduino Pro Micro issues

I just spent at least two hours trying to figure out how to get the Arduino Pro Micro running again. I will spare you the details of how I figured out what to do, so here is the solution:

sudo mv /usr/share/dbus-1/system-services/org.freedesktop.ModemManager.service /usr/share/dbus-1/system-services/org.freedesktop.ModemManager.service.disabled

Lets hope it keeps on working 🙂

Reading RC Receiver values (version 2)


in a previous post I briefly showed how to read the sum signal of a receiver that is able to output the signal. Although the code works quite well there are several issues with the code:

  1. calling pulseIn(SignalPin, HIGH) blocks until the corresponding pin is set to HIGH, which is a major waste of time, because no other calculations can be performed in the meantime
  2. I noticed that every now and then the readings start to glitch causing unwanted noise

To cope with the first issue I used  Arduino’s external interrupt feature that calls a callback function for every rising edge. In addition I wrapped it in a class and defined it as a library for easy usage.

[update: 2013-07-28][update: 2013-08-02]
Continue reading Reading RC Receiver values (version 2)

Pitot tube

Some time ago I wrote something about getting a cheap GPS receiver, a cheap AHRS, and how to read values from a RC receiver. All those tools can be put together to control an autonomous vehicle of some sorts. If the vehicle is a small ground robot nothing more is needed, except the vehicle itself, of course.I do not own anything that is capable of driving around outdoors, but I do own a small airplane. Continue reading Pitot tube