Software radio
Sean Conway provides instructions on software-defined radio (SDR) that turns your Raspberry Pi into a FM radio receiver.
Sean Conway provides instructions in this tutorial on software-defined radio (SDR) that turns your Raspberry Pi (or desktop) into an FM radio receiver.
This tutorial is designed to explore softwaredefined radio (SDR). We will cover some radio frequency (RF) theory in order to have a foundation for the article. The goal is to configure an SDR USB dongle, for this tutorial on a Pi, to receive a broadcasted FM radio signal.
SDR is a radio frequency communications system built using software, rather than physical hardware circuits consisting of oscillators, filters, modulators/ demodulators and signal amplifiers, to transmit or receive a radio frequency broadcast signal.
SDR devices receive analogue radio signals through an antenna, and then using an analogue-to-digital converter (ADC) they digitise the signal that can be further processed using digital signal processing.
What is in an RF broadcast?
An RF broadcast is a transmitted carrier signal travelling through the air. The signal is encoded with information using a modulation method. Two common RF modulation methods are frequency modulation (FM) and amplitude modulation (AM). In FM the carrier signal frequency is up-shifted and down-shifted in carrier frequency relative to the data applied. In AM the carrier signal amplitude varies according to the data applied.
To extract the data from the RF signal you would require a receiver that matches the modulation technique the signal was broadcasted with. The receiver has specific electronic circuits to process the modulated signal. The signal is gathered at the antenna and sent through the receiver circuit to extract the data and produce an output.
The block diagram (see top right) presents a pictorial of the electronic circuits needed to provide the functions required inside the AM and FM radios to produce the data. SDR replaces a majority of the hardware by performing the bulk of the circuit-heavy lifting in software. It also has the advantage of performing this processing over a larger frequency range than typical radio receivers.
With an antenna and an SDR dongle, radio signals can be gathered via the antenna, digitised by the dongle and processed using software on the Pi to produce the data that was carried on the modulated carrier signal. There are SDR dongles that can be both an RF transmitter and/or an RF receiver. These devices are referred to as SDR transceivers. For this tutorial we will use a SDR dongle that is a receiver only – no transmit. The objective is to extract the audio signal in an overthe-air Fm-broadcasted signal.
What is SDR good for?
With an antenna and the SDR dongle the sky is the limit. There are different frequency ranges of RF signals. If the antenna is tuned to the receive frequency and the SDR is designed to operate in the same frequency range, then the signal can be processed.
The software on the computer must then have the capability of demodulating the signal and possibly decoding the signal. Decoding suggests the signal was encrypted and would need to be decrypted to be usable.
Here’s a short list of RF signals and the data that can be extracted using an inexpensive SDR device: AM/FM radio stations
Aviation communications (conversations between aircraft and air traffic control)
Ham radio (person-to-person conversations) Aircraft Automatic Dependent Surveillance broadcasts( aircraft positions)
Satellite transmissions (weather data)
There is even a suggestions of recording vehicle keyless entry broadcasts and then playing them back.
This tutorial is intended for educational purposes. In most countries it is legal to receive broadcast RF signals, but in some countries this activity may be illegal: it is your responsibility to be aware of any legal restrictions in your region.
How does SDR work?
Broadcasted RF signals that are gathered by the antenna are converted to lower frequencies found in the audio band with the compact electronics in the SDR dongle. The frequency is then sampled using highperformance analogue-to-digital converters (ADC) to produce a digital output.
To paraphrase Nyquist’s theorem: an analogue signal can be reconstructed if samples are taken at equal time intervals. The sample rate must be equal to or greater than the highest frequency being sampled. The ADC used in SDRS have sample rates typically in the 200khz range – plenty to ensure an error-free reproduction.
We’ve chosen to ignore nearly all of the concepts and complex maths associated with the operation of an SDR device. Quadrature phase modulation theory used to bend vectors 90 degrees at 0Hz is way beyond this writer’s understanding, let alone explaining it effectively.
What is needed for SDR?
The puzzle pieces required to assemble an SDR receiver can be divided into three categories: the SDR device itself; the antenna for receiving signals; and the software, along with the PC it will run on. Components from all three categories work together to produce an output. Reducing the performance of any one of these components will impact a successful SDR project. You can have a smoking-hot performance from the SDR dongle, but if the antenna doesn’t produce enough input signal, the SDR may only produce the sound of static noise.
There is a balancing act in the form of cost verses performance, especially for the novice with little money who wants to dabble in SDR. Given sufficient money, all three categories could be optimised to achieve the best performance. For the basement technology geek in most of us, unlimited cost is not realistic. Our Quick Tips provide some resources to help you decide what components from the categories fit your budget.
Two dongles were used to develop this tutorial. The price point of each was different. As much as we’d like to purchase a higher-end SDR unit, clearer heads had to prevail and only invest in purchases that were needed to provide a comparison to complete the article.
In addition to the price of the two SDRS being different, so was their performance. The cheaper SDR dongle didn’t appear to work initially. After successfully getting the more expensive SDR device working, we doubled back using the knowledge gained to optimise the software configuration, enabling audio to be produced from the economical unit.
SDR receivers or SDR transceivers are designed to span a specific frequency range. An SDR will have a specification for the frequency range the device is capable of handling. The range can be from low frequencies in the khz to frequencies in the GHZ or thousands of MHZ range.
Devices like SDRS that are capable of transmitting and receiving RF signal require an antenna to handle the modulated signal. The diagram (see page 81) shows an ideal vertical dipole antenna radiation pattern. The RF source sends a signal to the antenna and it is radiated out in a torus or doughnut pattern. The RF signal energy is equal in all directions.
Antennas are designed to provide the best performance at a given frequency or range. The physical construction of the antenna and the components used determine the performance of the antenna. Antennas can be designed to increase signal strength in one direction with a reduction of the signal strength in other directions. These antennas are directional.
The RF energy is focused in one direction with very little escaping out the back. This type of antenna design enables greater range in the direction the antenna is pointed. If the signal is coming from the back side of the antenna, performance is degraded.
At lower-frequency ranges the antenna length is longer, sometimes kilometres long. In higher-frequency ranges the antenna is shorter – think of a mobile phone. An antenna tuned to a specific frequency provides the best signal receive and transmit strength. If you consider how signals are received on the Earth from satellites transmitting while orbiting in space, it might provide some appreciation for antenna design providing maximum signal strength.
Not all SDRS are the same. SDR components range from as little as $10 to $300 and more, depending on the specifications. Most can be purchased as a kit and come with wideband antennas. Wideband antennas are designed to work across a larger frequency range and tend to produce an average signal output across the range. Recall antennas are tuned to receive or transmit
on a desired frequency. If a weak signal is what you are after, wideband antennas are not ideal.
Devices will have specifications on the different features the device supports. Inexpensive SDR dongles lack some of the technology that increases performance and provides stability. An example of this is temperature stabilisation circuitry.
In the image on page 78, the left SDR dongle is housed in a metal case, and the right dongle is plastic. The metal acts as a heat sink for the electronic components. Considering the ADC work the unit is performing there’s a chance the device will generate heat.
Using a $10 SDR to receive the ‘must have’ critical weather broadcast is not a good design idea.
Understand what frequency range you want to operate in and the variables that impact the range, and then make a purchase to reflect those specifications. Like receiving TV signal in the 1960s, no one likes standing up holding the receiving antenna high above their head to receive a clearer picture. The cheaper SDR kit we used proved a challenge to get it to process a signal. If getting a cheap SDR to work is a user’s first experience, we can see why future exploration would be rather discouraged, so bear this in mind.
A quick note on the connectors for antennas and the SDR dongles themselves. They are not all the same. Make note of the connector requirements if you are sourcing antennas separately from the dongle. It is frustrating to discover that the connector on the antenna doesn’t mate with the dongle. There are adaptors available to enable the connection. This adds complexity and also impacts signal levels, so avoid them where possible.
A computer capable of running SDR software is the final piece. The SDR shifts the signal processing from electronic circuits to digital manipulation. For this project we are using a Raspberry Pi to run the software. Without a heat sink on the Pi chips or a fan circulating air around, you may receive warning signals of excessive CPU temperatures. Digital signal processing can require extensive CPU investment, generating heat.
SDR software is supported on a variety of operating systems. Linux was primarily used to develop this tutorial. A short foray into Microsoft Windows 10 was also needed to eliminate the suggestion that the problems in the cheaper SDR dongle were related to the OS software.
In this tutorial we are going to examine two software applications that are supported by the Pi. The first, gqrx (http://gqrx.dk), is software powered by GNU Radio and the Qt graphical toolkit. The software receiver enables you to demodulate received RF signals. The second, Cubicsdr (https://cubicsdr.com), is an SDR application that can be used to navigate the RF spectrum and demodulate any signals. It supports several common analogue demodulation schemes, such as AM and FM, and is continually being developed to support more digital modes into the future.
Enough with the theory
Our assumption is that the reader has sufficient knowledge to prepare a Raspberry Pi with the Raspbian operating system supporting the GUI. Before starting the exercises in this tutorial let’s refresh the Raspbian OS to ensure that all the repositories and software loads are current. Log in to the Pi and open a terminal command line interface (CLI) window, and then enter the following command:
sudo apt-get update -y;sudo apt-get upgrade -y
Keeping our eye on the prize of using SDR, bang out the commands to support RTL-SDR on the Pi and install the two software applications. Finish up with a reboot to ensure the Pi comes back ready to receive. Ensure your SDR dongle is installed before the reboot:
sudo apt-get install rtl-sdr gqrx-sdr cubicsdr sudo reboot
From the command line do a test to confirm the Pi is software-driver ready and detecting the SDR:
sudo rtl_test -t
The following is contained in the text output, depending on the SDR installed:
Found Rafael Micro R820T tuner
or
Found Fiti power FC0012 tuner
The objective is to play audio from an FM broadcasted signal. In ourr rural area, we managed to get a reasonable signal level in a basement lab with the FM radio station on frequency 92.1MHZ. You will need to use an FM radio station frequency in your area.
Using the Raspberry PI GUI Menu > Internet > Gqrx, start the application. Set up a consistent screen display by opening the view menu and selecting input controls, receiver options, audio, FFT settings. This enables tabs on the right side of the display, middle of the screen. There are extensive resources for the gqrx application. Use the annotated pictorials (see left) to establish the settings for the FM broadcasted signal 92.1MHZ.