Home » Electronics » RTL-SDR – Software Defined Radio (SDR) for $20

RTL-SDR – Software Defined Radio (SDR) for $20

While researching the GNU Radio project, I came upon references to the RTL2832 TV tuners. These dongle are made to receive and decode the European standard digital television, Digital Video Broadcasting — Terrestrial (DVB-T). (By the way, the North American standard is Advanced Television Systems Committee (ATSC), and not  compatible with DVB-T, so this will not work in North America for TV reception.)  In 2012, Antii Palosaari, discovered that there is a device mode for the Realtek DVB-T device chip (RTL2832U) in which raw samples can be captured and transferred to a host computer. This feature enables this device to be used as an inexpensive “front end”  for a Software Defined Radio (SDR) that could be implemented on a PC or other device.

A SDR provide the ability to sample and record the electromagnetic energy (or radio frequency, called “RF” for short) with no preconceived idea as to the structure of the RF signal.  In a sense, you can interact with the RF signal in its must fundamental form.  In addition, a SDR allows you to implement, by means of software, a radio communication system where components that have been typically implemented in hardware.

SDR solutions for the professional-grade applications and amateur radio have been around for some time, but the appearance of cheap solutions for the hacker is new.  There are general purpose SDR platforms for over $1000, like the Ettus Research Universal Software Radio Peripheral (USRP), the $525 SDR-IQ Receiver, to the $450 bladeRF from the Kickstarter Nuand or Great Scott’s DARPA-Funded HackRF for an estimate $300, and now the $20 hacker grade dongle discussed here.  But unlike most of the other referenced solutions,  the dongle  requires a PC, or some sort of attached processor, to provide the signal processing.

In all SDR solutions, a significant amounts of the signal processing is handed over to a numerical processor, rather than being done in special-purpose RF hardware. Such a design produces a radio which can receive and transmit widely different radio protocols (referred to as a waveform) based solely on the software used.  So in a SDR solution, the electromagnetic waveform is rapidly sampled, the sample values are converted to numerical values, and these numbers are manipulated via a discipline called digital signal processing (DSP).  Ultimately, the resulting DSP numerical values produced are converted to an analog signal that goes to a speaker, TV, or other such output device.

The DVB-T dongles can provide a critical component of a cheap SDR, since the chip allows transferring the raw I/Q samples to the host. What I/Q samples are is well beyond what I wish to describe here, but let it be said that practical hardware design concerns make I/Q data the critical for signal processing.  So the fact the dongle does the digital sampling, called a analog-to-digital converter (ADC), and outputs I/Q samples, makes it a valuable asset for a SDR solution.

So how does one get your PC configured to take the dongles I/Q output and create a SDR?  There is GNU Radio (where this post first begun), but a simpler starting point would be the popular, easy, and open source SDR#.  SDR# can perform the required signal processing in an intuitive user interface (if your into Ham Radio, or bit of a RF hacker, and such).  Unfortunately, I couldn’t get SDR# (a MS Windows application) to operate under  Linux and I had to resorted to some simpler utilities.

The Dongle

All this sounds exciting to me (what a geek!) so I purchased from Amazon one of the dongles, specifically the NooElec TV28T v2 USB DVB-T,  FM+DAB & RTL-SDR Receiver, RTL2832U & R820T Tuner, MCX Input.

71RaTxr2WJL._SL1500_

NooElec TV28T

    • NooElec TV28T – This is the manufacture and model name for the device
    • DVB-T – This device is made to receive and decode the European standard digital television, Digital Video Broadcasting — Terrestrial (DVB-T)
    • FM+DAB & RTL-SDR Receiver – The device can also receive FM radio and Digital Audio Broadcasting (DAB) used in several countries, particularly in Europe. RTLSDR is the popular name give to this class of device, which contain the RTL2832U chip, which can be hacked for SDR use.
    • RTL2832U & R820T Tuner – These are the DVB-T demodulator and TV Tuner chips used in the device.
    •  MCX Input – Is a 3.6 millimeter (0.14 in) micro coaxial (MCX) coaxial RF connector 30% smaller that Sub-Miniature version B (SMB) connectors that are typically used in the USA.  MCX is a standard in Europe. It provides broadband capability from DC to 6 GHz.

From the research I have done, I have found that this dongle provides an approximate tuning range of 25MHz-1700MHz for the SDR.  It has been demonstrated to be compatible with most SDR software, including SDR#.  You can pick up FM radio but  don’t expect to pick up long-wave or AM broadcasts since their spectrum lies below 25MHz. You can listen to the 12m 10m 6m 2m 1.25m 70cm 33cm and 23cm ham band, as well as CB, Marine VHF, RC Band, FRS, GMRS, and Airband (Aviation).

The dongle will not provide the desired SDR function out of the box.  It must first be configured (aka hacked) to stream the I/Q samples to the USB output.  This is where Antii Palosaari’s discovery comes into play.  The wiki’s rtlsdr.org and OsmoSDR are good sources for disparate information concerning RTL2832U based SDR, typically called RTL-SDR.  For my purposes, I wanted to get something initially working on my PC (Linux OS) but ultimately I wanted to have the dongle attached to a Raspberry Pi (RPi) and have the RPi be a server or archive of I/Q samples (sort of a intelligent wide band scanner as done in Raspberry Pi and DVB-T receivers and here Raspberry Pi as Remote Server for RTL2832u SDR and here SDR with Raspberry Pi and DVB-T receivers) that could be processed by my PC.  Therefore, the first step is to get the dongle and a good SDR processor working on my PC.

Building rtl-sdr Library and Capture Tools

The  OsmoSDR wiki has some good instructions on how to build the rtl-sdr software. I basically followed the wiki’s instructions but I had to first install cmake (sudo apt-get install cmake) and libusb (sudo apt-get install libusb-1.0-0-dev) to get a successful make.  I then using the following commands:

cd ~/src
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig
cmake ../ -DINSTALL_UDEV_RULES=ON

The result is source code placed in ~/src/rtl-sdr/build/src and the executables are placed in /usr/local/bin: rtl_adsb, rtl_eeprom, rtl_fm, rtl_sdr, rtl_tcp, rtl_test.  The documentation for these utilities is nearly non-existent.  The only documentation I could fine is for the rtl_fm, a posting called Rtl_fm Guide: The long lost documentation.  If you use the command line option --help, you will get some description for each of the tools (see the very end of this post for some screen captures).  Here is a short description and some example usages:

    • rtl_sdr – This is an I/Q recorder for RTL2832 based DVB-T receivers. To send 10 samples to stdout, and sampled at 1.8Ms/s with frequency tuned to 392MHz: rtl_sdr -s1.8e6 -f392e6 -n10 -.
    • rtl_test – Bench-marking tool for RTL2832 based DVB-T receivers.  The -t option only works for Elonics E4000 tuners (Therefore, on non-E4000 tuners, you can not test for the tuning range).  To check the possible tuning range: rtl_test -t.  To check the maximum sample-rate possible on your machine (change the rate down until no sample loss occurs): rtl_test -s 2.5e6
    • rtl_fm – A simple narrow band FM demodulator for RTL2832 based DVB-T receivers.  Rtl_fm is a general purpose analog demodulator. It can handle FM, AM and SSB. It can scan more than a hundred frequencies a second. Make sure rtl_fm and the player are both set to use the same data rate.  Tune into a local FM radio station : rtl_fm -W -f 99.5M | play -r 32k -t raw -e signed-integer -b 16 -c 1 -V1 -
    • rtl_tcp –  An I/Q sample server for RTL2832 based DVB-T receivers.  I/Q samples are streamed to a specified IP address and port.
    • rtl_adsb – A simple Automatic dependent surveillance-broadcast (ADS-B) decoder.  ADS-B is a surveillance technology for tracking aircraft as part of the Next Generation Air Transportation System (NextGen).
    • rtl_eeprom – An EEPROM programming tool for RTL2832 based DVB-T receivers.

First Run of the Dongle

The first thing to do is to plug in the dongle and run the test rtl_test -t.  It gave me an error statement expressing “installing the udev rules file rtl-sdr.rules”.  The site “rtl-sdr on Ubuntu” provides some instructions on how to fix this.  The command lsusb | grep Realtek gives me the information I need to create the following entry into /etc/udev/rules.d:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", GROUP="adm", MODE="0666", SYMLINK+="rtl_sdr"

After another try, I got a successful test.  Next, I sent ten I/O samples to stdout and then tuned into a local FM radio station using these commands:

rtl_sdr -s1.8e6 -f392e6 -n10 -
rtl_fm -W -f 99.5M | play -r 32k -t raw -e signed-integer -b 16 -c 1 -V1 -

sdrsharp

SDR Sharp

Getting SDR# Running in Linux (didn’t work)

The  rtlsdr.org wiki has some instructions on how to get SDR# working within Linux.  Also, the SDR# home page has a link called One shot install script for Linux. Both these sites require you to build the software from source code. Mono is able to run Microsoft .NET applications in Linux.  I attempted this and got errors that I could not figure out (I’m not a MS Windows developer type and I’m not interested becoming one!).

Given this, I chose a different path. I found another posting that claim to get SDR# running in Linux. In this case, only executable will be loaded, not source code that needs to be compiled. You can download SDR# executable from this posting.  You’ll also need to install mono and PortAudio.  Here is how I did it:

sudo apt-get install mono-complete monodevelop
sudo apt-get install libportaudio2
cd ~/src
mkdir sdrsharp
cd sdrsharp

Within ~/src/sdrsharp, install the downloaded SDR# zip file and unzip it.

cd sdr-nightly
ln -s /usr/local/lib/librtlsdr.so librtlsdr.dll
ln -s /usr/lib/i386-linux-gnu/libportaudio.so.2 libportaudio.so

Note, for the above link, you may need to use locate libportaudio.so.2 to find the PortAudio library.

To test things out, I ran the application using mono sdrsharp.exe and got a core dump.  I attempted this again using the stable version of SDR# instead of the nightly build and got the same results.  After the typical thrashing about, I found a bug report for this problem.  Also see “SDR Software – Good, bad and very ugly“.  Also, there seems to be some sort of dispute between SDR# and a new group calling itself Open SDR#.  I’m not sure, but what appears to be at the heart of this is the level of support of SDR# within Linux.  All this is disappointing since SDR# is a very popular tool and I wish I could find away to make use of it within Linux.

The next logical SDR tool to try would be the Linux-based Gqrx SDR receiver, but in this case, it is dependent on GNU Radio.  I’m attempting to delay my conquest of GNU Radio until I do some experimenting with the dongle.  So lets turn our attention to a much simpler tool.

Getting RTLSDR Scanner Running

RTLSDR Scanner is a simple frequency scanning GUI using the OsmoSDR rtl-sdr library.  I more or less followed the installation instructions but they are confusing/out-of-date and you’ll needed to do some adjustments.  The OsmoSDR rtlsdr library has already been installed earlier in the text, so its not listed here.  To get the required files for RTLSDR Scanner:

sudo apt-get install python python-wxgtk2.8 python-matplotlib python-numpy
cd ~/src
git clone git://github.com/roger-/pyrtlsdr.git
cd pyrtlsdr
sudo setup.py
cd ~/src
git clone git://github.com/EarToEarOak/RTLSDR-Scanner.git

With this, I found I could run ~/src/pyrtlsdr/demo_waterfall.py.  Make sure to read the comments in the file to understand how to change the center frequency, gain, etc.  The image below is demo_waterfall.py tuned to the amateur radio 6 meters band.  The image is called a spectrogram (sometimes call spectral waterfall) is a dynamic, visual representation of the spectrum of frequencies in the RF signal.  Blue is low signal strength, where yellow, and red are higher strengths.

demo_waterfall.py

demo_waterfall.py

To get ~/src/RTLSDR-Scanner/src/rtlsdr_scan.py to work, I had to do some coping of files as shown below:

cp ~/src/pyrtlsdr/rtlsdr/rtlsdr.py  ~/src/RTLSDR-Scanner/src/rtlsdr.py
cp ~/src/pyrtlsdr/rtlsdr/librtlsdr.py  ~/src/RTLSDR-Scanner/src/librtlsdr.py

The image below is from rtlsdr_scan.py, again tuned to the amateur radio 6 meters band.  Here again you see the signal strength of the individual amateur radios as vertical spikes.

rtlsdr_scan.py

rtlsdr_scan.py

So we now have auditory and visual proof the dongle is doing its job. Now its on to GNU Radio!

Command-Line Options for RTLSDR Capture Tools

For reference purposes, below are screen shots of the RTLSDR capture tool’s command line options.

rtl_test -s

rtl_test -s

rtl_test

rtl_test

rtl_tcp

rtl_tcp

rtl_sdr

rtl_sdr

rtl_adsb

rtl_adsb

rtl_fm

rtl_fm


6 Comments

  1. […] RTL-SDR – Software Defined Radio (SDR) for $20 May 26, 2013 […]

  2. Hao Doan says:

    Hi,Can put range frequency 2100-2200Mhz?And can I get full bandwidth if frequency gennerator is 2100-2170Mhz?

  3. karthik says:

    thanks you very much jeff!!

  4. […] Anleitungen funktionieren oft nicht mehr wenn man sie ein halbes Jahr später nachmachen will. Hier beschreibt einer auch diese […]

  5. ct224.aspx says:

    And his new team-mates are doing their best to persuade him to join on a permanent deal.

  6. rs82.asp says:

    And it is likely he would be out of Gareth Southgate’s plans if he moved to the Far East.

Leave a comment