RTL_433 to MQTT

Is a nice peace of software that turns a cheap Realtek SDR into a receiver that will pick up many signals on the 433,92 Mhz frequency.

Like I wrote in a previous post I’ve got some equipment that transmits information on this frequency. I share this information on the local network using MQTT.

In this post I would like to introduce a script that does the work and at the same time show how I got this software running inside a docker container.

System setup

The system that will do the scraping of the information from the 433,92 Mhz band I’m using is an Ubuntu system. It requires some additional packages and needs to pull source code from GIT, compile it and install it:

This will install a program rtl_433 in /usr/local/bin.

The mqtt publishing script

This scripts launches rtl_433 and contiuously reads information from it, filters it, selects interesting pieces of information and publishes these.

Quite likely you’ll have to adjust it to your needs, use at for inspiration. I named my script /usr/local/bin/rlt2mqtt.sh

Docker

I’m testing quite a lot of software and want to keep things isolated per task/function. Virtualisation would require many different VM’s which is heavy on resources.

Using Docker containers I can create images for a specific task that run in their own environment without the overhead of VM’s.

Creating an image is done by creating a docker file that will prepare the image, a script that will be uploaded into the image and running a container based on this image.

Go ahead and create a directory and place the following two files in there:

Dockerfile with the following content:

And the script file named rtl2mqtt.sh

When both files are present run the command

This will take some time. You should end up with an image id that you need in the next step. Give the image a meaningful name

Time to run a container based on this image. This image requires access to a USB device on the host which is handled with the privileged option and the volume mapping on the next line.

 

 

Disclaimer: All information posted is written with the upmost care and valid at the time of writing. Changes in versions can supersede the provided information. Please use your own judgement.

1 thought on “How to publish weather info from RTL_433 to MQTT for Domoticz in a docker container

Comments are closed.