How to use an RTL2832U with a Raspberry Pi
An RTL2832U is an inexpensive software-defined radio (SDR) dongle available for $30 or less. A Raspberry Pi is a relatively inexpensive single board computer running Linux. Together you can build a radio receiver capable of receiving everything from longwave to UHF communications. It can also be used to monitor P25 trunked radio systems.
This guide assumes a base level of knowledge, including:
Knowing how to flash a custom ROM.
How to use the Linux CLI.
How to install software and edit files on Linux.
What you need
RTL2832U dongle (only 1 is required)
A Raspberry Pi kit
A note on the Pi. Just the card itself is useless. It goes without saying you need a power supply and a way to interact with it, either a physical keyboard, mouse, and monitor or a headless setup.
I strongly suggest downloading and installing the pisdr image as it includes much of the required software.
gnuradio (included with pisdr)
rtl-sdr (included with pisdr)
Install necessary software and drivers
All of this software is preloaded with the pisdr image. Only install if you’re using a different image.
sudo apt install -y alsa-utils cmake git gnuradio libusb-1.0-0-dev rtl-sdr
All of these drivers are preloaded with the pisdr image. Only install if you’re using a different image.
cd rtl-sdr/ mkdir build cd build cmake ../ -DINSTALL_UDEV_RULES=ON make sudo make install sudo cp ../rtl-sdr.rules /etc/udev/rules.d/ sudo ldconfig
Now restart your Raspberry Pi to assure the drivers load.
Try it out!!
Open the Terminal window.
rtl_fm -f 162.4e6 -M nbfm -s200000 -r 48000 - | aplay -r 48000 -f S16_LE
You should hear the familiar sounds of NOAA Weather Radio or Weatheradio Canada playing. You will need to change to frequency to match your local weather radio station. If you’re outside of the US or Canada, try a local FM broadcast station.
rtl_fm -f 93.7e6 -M wbfm -s200000 -r 48000 - | aplay -r 48000 -f S16_LE
The above command will tune 93.7 MHz, in my case, KLBJ-FM.
In order to enable reception below 28 MHz, bias trees must be enabled. The installation below is included with the pisdr image.
mkdir -p ~/git && cd ~/git git clone https://github.com/rtlsdrblog/rtl-sdr-blog cd rtl-sdr-blog mkdir build cd build cmake .. -DDETACH_KERNEL_DRIVER=ON make sudo make install
Enable bias trees
rtl_biast -b 1
Disable bias trees
rtl_biast -b 0
NRSC5 (HD Digital Radio)
sudo apt install -y git build-essential cmake autoconf libtool libao-dev libfftw3-dev librtlsdr-dev cd ~/git git clone https://github.com/theori-io/nrsc5.git && cd nrsc5 mkdir build && cd build cmake [options] .. make sudo make install sudo ldconfig
-DUSE_NEON=ON Use NEON instructions. [ARM, default=OFF] -DUSE_SSE=ON Use SSSE3 instructions. [x86, default=OFF] -DUSE_FAAD2=ON AAC decoding with FAAD2. [default=ON] -DLIBRARY_DEBUG_LEVEL=1 Debug logging level for libnrsc5. [default=5]
Using an RTL2832U for monitoring trunked systems
This software is not part of the pisdr image and must be installed. ~~But it’s a straightforward installation~~. Since GNURadio 3.9 it’s not no straightforward. You’ll need to compile cmake yourself in order for this to work.
Remove existing cmake
sudo apt remove -y cmake
Download cmake source code, compile, and install
cd wget https://github.com/Kitware/CMake/releases/download/v3.21.0-rc3/cmake-3.21.0-rc3.tar.gz tar -xzvf cmake-3.21.0-rc3.tar.gz cd cmake-3.21.0-rc3 ./configure make sudo make install
The software can be installed anywhere a user has write access. I prefer to keep all git installed software under
mkdir -p ~/git && cd ~/git git clone https://github.com/boatbod/op25.git && cd op25 ./install.sh
mkdir -p ~/git && cd ~/git git clone git://git.osmocom.org/gr-osmosdr && cd gr-osmosdr/ mkdir build cd build/ cmake ../ make sudo make install sudo ldconfig
How to configure software
Before we get too in depth, let’s verify things are working. Since I live in Austin, I will use the Greater Austin/Travis Regional Radio System (GATRRS) as my example.
The best way to confirm your installation is to monitor the control channel frequency of a local system. And the easiest way to find that information is from the good folks over at RadioReference.com.
All commands should be run from the apps directory. So let’s cd into that directory and go from there. If you installed your software in a different location I have to assume you know how to find it.
This is the command that will launch the software and start tracking.
./rx.py --args 'rtl' -N 'LNA:47' -S 2500000 -x 2 -f 851.2875e6 -o 17e3 -q 0
Here’s an explanation of that line.
The python script you’re running
You’re using an RTL device
Gain setting, 47 should be fine
Sample rate, 2500000 should be fine
Audio gain, 2 should be fine
Control channel frequency in scientific notation
Offset, 17e3 should be fine
Frequency correction and this will likely need to be changed
If you selected the correct q value, you should see a screen similar to this after a few seconds.
If you get something like this, your q value isn’t correct. Try a different one, an integer between -5 and +5 inclusive.
Time to listen
You probably noticed you’re not hearing anything. This is because we haven’t told the software to do this. Now we will tell the computer to give us some audio.
cd ~/git/op25/op25/gr-op25_repeater/apps ./rx.py --args 'rtl' -N 'LNA:47' -x 2 -o 17e3 -q 0 -f 851.2875e6 -V -2 -U -n 2> stderr-stream0.2
Wait, all I see are talkgroup numbers? Have I gone back in time to the original Uniden Trunktracker scanner? We need data and the best source of this data is, again, RadioReference.com. You need to be a premium member to be able to download files. It’s well worth it, and keeps the crew who run the site fed. If you’re not a member, you’ll have to enter this info by hand or copy and paste.
Both of these files will download into your Raspberry Pi’s Downloads folder.
You cannot simply copy them over to your apps directory. I have created a Perl script that creates the required files and places them in the appropriate directories.
The site file contains information about the site(s) for your system along with control channel frequencies. The tg file has the talkgroup information.
The software will scan through the control channels until it finds one. If there’s a site you prefer to monitor, then list that line first. If you prefer to monitor each site individually then create unique site files. They can all reference the same tg file.
In all honesty this is the hardest part and I hope my Perl script eases some of the pain.
Now it’s really time to listen
cd ~/git/op25/op25/gr-op25_repeater/apps ./rx.py --args 'rtl' -N 'LNA:47' -x 2 -o 17e3 -q 0 -T ~/.local/pisdr/sites/trs_site_2.tsv -V -2 -U -n 2> stderr-stream0.2
Be aware that the filename after the
-T will vary depending on your local system.
-l 'http:0.0.0.0:8080' to your rx.py command string, you can enjoy a web-based dashboard.
./rx.py -2 --args 'rtl=0' --gains 'lna:49' --nocrypt -l 'http:0.0.0.0:8080' -o 17e3 -q 0 -U -V -v 1 -X -T ~/.local/pisdr/sites/trs_site_2.tsv 2> /dev/null &
Now open your web browser and visit
Enable Icecast for Streaming
If you so desire you can make your new Raspberry Pi scanner available online.
Install Required Software
sudo apt install -y icecast2 liquidsoap
The icecast2 installer will as you setup hostnames and passwords. Just use
localhost for the hostname and pick hard to guess passwords. For purposes of this tutorial we’ll assume the following passwords:
Icecast administration password: administration Icecast relay password: relay Icecast source password: source
I hope this helped. If something isn’t clear, feel free to email me about it. Also please, please read John’s (not me) article that I reference below. It’s written for installing on Ubuntu and gives a broader explanation than I give.