Experimenting with RF using RTL-SDR
Using CubicSDR, rtl_433, MQTT and telegraf to stream live data to InfluxDB
I was always interested in the RF world, the fact that we are surrounded by an infinite amount of invisible waves that carry information is intriguing. A lot has changed over the years, the technology advanced and today you can easily dive into the electromagnetic realm without fiddling with mountains of equipment and burning your pocket.
In this post we’ll explore using RTL-SDR to read live temperature and humidity stats from cheap 433.92Mhz modules, feeding them to InfluxDB using rtl_433, MQTT and Telegraf on a Raspberry Pi (but any Linux based device can work)
The definition of SDR is “Software Defined Radio”, it’s a radio-communication system where instead of using components that were traditionally implemented in hardware - software is used, allowing greater flexibility and reducing costs.
RTL-SDR is a high quality USB dongle (but relatively cheap at ~$25) that can be used to scan and receive radio signals from 500Khz (24Mhz for the device I used) up to 1.75Ghz. It was designed and built by the awesome dudes over at RTL-SDR.com based on DVB-T TV tuner dongles. I ordered this kit which included two modular dipole antennas.
Almost any RF based wireless thermometer / humidity sensor is probably readable by
rtl_433. Since we’re talking about cheap hardware you can’t really get any assurances, checking the RF frequency is probably enough - if it says 433.92Mhz, you are 99% good. I’ve used this as my indoor sensor and this as my outdoor, for monitoring my garden soil humidity level and outdoor temperature
I’ve used a RPi4 that I had lying around loaded with Raspbian Buster.
This is an awesome free open-source software for SDR. It wasn’t easy finding one for MacOS, most of the commonly-used projects are made for Linux and Windows. It’s not really required for decoding 433.92Mhz signals, but I wanted to get my hands dirty and look on live RF, it’s pretty neat (and of course to test the device is actually working!)
An amazing project that can be used to decode a variety of RF-based devices on various frequencies (433.92 MHz, 868 MHz, 315 MHz, 345 MHz, and 915 MHz ISM bands). This is the software that does the heavy lifting.
Very simple MQTT server and client implementation, we’ll be using that as the output of rtl_433 and input of Telegraf to stream the metrics to a remote InfluxDB instance.
Agent for collecting and writing metrics. It will subscribe to our MQTT queue, parse and transmit the metrics to InfluxDB.
Getting a signal
Connecting the antennas
Let’s start by quickly testing our shiny RTL-SDR receiver, I’ve used the two short 5cm dipole telescopic antennas for this test, you should definitely read this great guide that the awesome dudes over at rtl-sdr.com wrote on using the provided antennas. The antenna used is critical for getting high-quality signal in some cases. For our radio FM test any antenna will probably suffice, but if you want to receive weather satellite signal running on 137Mhz, you’ll have to be more specific.
Hopefully you’ve ended up with something like this:
Listening to radio
Now you can connect the dongle to your usb port, launch CubicSDR, choose “Generic RTL2832U OEM” and hit “Start”, you can ignore the extra settings you see on the right for now. You should see a pretty moving signal heatmap, you can change the center frequency by hovering over it and tapping space (the key), I chose a local FM radio station that is broadcasting on 88Mhz (FM).
Now your bandwidth setting should be set to 200Khz, you should get a nice signal and when you hover your mouse over it the band will “encapsulate” the signal, click and you should start hearing radio!
Checking Frequency 433.92Mhz
Let’s get ready to use
rtl_433 by looking at the frequency and making sure there are devices there. Usually they will transmit information in 30 second bursts, you can change the center frequency to 433.92Mhz and check that you see data. Near the end of the video above you can see the signal bursts when I switch to 433.92Mhz
Decoding on the RPi
Installing and running rtl_433 on our RPi
You can now connect the RTL-SDR dongle to the Raspberry Pi and see if you can get some temperature and humidity data! (If you haven’t tested your sensors, now is the time to do it). Run
rtl_433 and you should get some data like in the video below
Installing Mosquitto and Telegraf
So we’re getting live sensor data, that’s pretty awesome, let’s stream everything to InfluxDB. You can open a free Influx Cloud account and we’ll configure Telegraf to stream information to it, after you open the account generate an API key for your bucket.
We’ll use Eclipse Mosquitto as the MQTT server, it’s a very lightweight implementation of MQTT server, providing simple pub/sub service which we’ll use.
The logs are accessible over at
Before running Telegraf service let’s configure it, you can backup the existing config and paste the contents of my
/etc/telegraf/telegraf.conf like this:
You’ll need to get your InfluxDB endpoint url, token, organization name and bucket from Influx cloud. The MQTT consumer settings specifies connecting to our MQTT server and listening to rtl_433/# topic, which basically says any topic with the prefix rtl_433/ will be sent to InfluxDB.
The expected data should be json (as specified by the
Now for the last part, just run rtl_433 with mqtt output!, to make sure everything works you can first run a mosquitto subscription client and listen to incoming events by running
mosquitto_sub -t "rtl_433/#", afterwards launch it (I like using screen for that, see the next video):
If all went well data should be flowing to InfluxDB! hurrah!
Viewing your data
Using InfluxDB is outside the scope of this post but you should be able to get funky graphs like this one:
Using RTL-SDR for decoding RF data is only the tip of the iceberg of what you can do with it, I highly suggest going to rtl-sdr.com and checking some of their amazing tutorials - You can receive live weather satellite data, decode trunked radio systems and see the universe!