Reading weather data with software-defined radio
Waverider
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.
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.
Software
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://git.osmocom.org/rtl-sdr.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
(incl. VAT)
Buy Linux Magazine
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.
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.