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
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.