Reading weather data with software-defined radio


Article from Issue 160/2014

Armed with a US$ 20 hunk of hardware and a free software-defined radio tool, Konstantin starts the hunt for radio-transmitted data from a weather station.

Weather stations with transmitters (Figure 1) are used in many households today, including my own. The small transmitter, in this case, is on the window sill, measuring weather data such as temperature, air pressure, and humidity and transmitting the results digitally to a base station, which then displays them. However, a base station is not even necessary for receiving the data. With a little passion for tinkering, and the help of software-defined radio, I can receive, read, and even produce this wireless data with my own computer.

Figure 1: Communication between a commercial weather station (left) and the associated sensor (right) can be evaluated with SDR.

Software-defined radio (SDR) picks up electromagnetic waves almost directly at the antenna and uses software to process them. In the simplest case, an SDR-receiver consists of an antenna and an analog-to-digital converter plus software. Depending on the device, it can thus scan a very large frequency range. Applications for implementing SDR include GNU Radio, GNU Radio Companion, or Gqrx (see the "GNU Radio from a PPA" box).

Gnu Radio from a PPA

Before plugging in the hardware, Ubuntu users need to create a udev file. To this end, run lsusb to determine the vendor and product ID of your DVB-T stick and issue the following command as root:

echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="Vendor_ID", ATTRS{idProduct}=="Product_ID", GROUP="adm", MODE="0666", SYMLINK+="rtl_sdr"' > /etc/udev/rules.d/20.rtlsdr.rules

This command writes a new rule for udev that references the DVB-T stick. You also need to restart udev as root before connecting the stick:

service udev restart

Ubuntu users install the Debian packages of GNU Radio and Gqrx from a PPA:

sudo add-apt-repository ppa:gqrx/snapshotssudo apt-get update
sudo apt-get install gqrx gnuradio

You can then call gqrx to start the SDR GUI.

The software does the majority of the work, so your soldering iron can stay safely in the cabinet. You only need to find the right hardware, which costs only a few dollars, as well as an editor to process the digitized radio data on your computer.

The Hardware

The first step is to find the right reception hardware. Although specially developed hardware is quite expensive, DVB-T sticks at around US$ 20 offer a very convenient entry point into SDR, as long as they use a Realtek chipset (RTL2832U). The whole thing operates under the RTL SDR umbrella and relies on Librtlsdr library.

A look at my weather station shows that it receives data on 868MHz. Online sources list various chipsets and the frequency ranges they cover [1] [2]. On the recommendation of a colleague, I bought a Terratec Cinergy T Stick RC with Elonics chipset that covers the largest frequency range of the listed DVB-T receivers – and that includes the weather sensor's frequency. The hardware cost me US$ 25; a rod antenna is included.


The basis for the installation was a netbook with Mint 15; the GNU Radio Framework [3] helped to analyze the received radio signals. This kind of kit even includes a graphical editor and supports raw data signal processing (optionally also in realtime) to create a target format with the help of various filters. The software automatically generates Python code that processes the data.

To use the DVB-T stick as a receiver, I first need the RTL SDR package. Typing:

git clone git://

installs RTL SDR on my computer. Gentoo and Arch Linux include prebuilt packages; on Ubuntu, you can install the software from a PPA (see the "GNU Radio from a PPA" box).

Building the software from the source works with cmake, but there's a catch: RTL-SDR uses the libusb library to communicate with the stick. However, when certain drivers are loaded, the software fails to correctly talk to the stick. My Mint system loaded the modules from Listing 1. Listing 2 shows a guide from the website [1] for building the software from the source code.

Listing 1

lsmod | head 7


Listing 2

Compiling rtl-sdr


Testing, Testing, 123 …

To prevent the modules from loading, the udev rules need to be modified. To do this, I had to expand the cmake call adding the -DINSTALL_UDEV_RULES = ON parameter and then still issue the following command:

sudo make install-udev-rules

after doing so. You can now read the hardware functions as follows

rtl_test -t

to find out about, for example, which frequency range the DVB-T stick covers. Another practical test would be to receive a local radio station:

rtl_fm -f 98.5M -W -s 200000 -r 48000 - | aplay -r 48k -f S16_LE

The demodulator rtl_fm takes 200,000 samples per second on a frequency of 98.5MHz (the frequency of a radio transmitter). The aplay command plays the data stream on stdout at a rate of 48kHz. Because the raw audio file does not contain header information, aplay reads the data at this rate and encodes it with 16-bit in little-endian format.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Pi FM Radio

    Low-cost RTL-SDR dongles can read frequencies between 24 and 1,766MHz. We built a simple FM radio with a Raspberry Pi, a USB dongle based on the RTL2832U chipset, an LCD HAT, and some Python code.

  • Charly's Column: Air Traffic Control

    When he sees vapor trails in the skies above the Lower Rhine area, sys admin Charly Kühnast doesn't just dream of faraway places. With a Linux system and a DVB-T stick, he grabs the signals from jets flying overhead and tracks their courses on a map.

  • FOSSPicks

    Graham looks at Graphite, retrogram~rtlsdr, Piano Forte, OneTrick SIMIAN, The Command Line Murders, and more!

  • Linksys Says Yes to Open Source Firmware

    Home routers will give room for custom firmware but still comply with FCC rules

  • Internet Radio Guide

    Take a tour of some favorite Internet radio sites from the experts at Linux New Media.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More