RTL-SDR

From HFUnderground

Jump to: navigation, search

An inexpensive Software Defined Radio using the DVB-T dongles based on the Realtek RTL2832U.

Installing pre-built rtl-sdr on Mac OS X

Download and decompress the archive: http://inst.eecs.berkeley.edu/~ee123/fa12/rtlsdr/rtlsdr_osx.zip

Make sure you have the directories /usr/local/bin and /usr/local/lib If not, create them:

sudo mkdir /usr/local/bin
sudo mkdir /usr/local/lib

Copy files from the archive:

sudo cp rtl_sdr rtl_tcp rtl_test /usr/local/bin/
sudo cp lib* /usr/local/lib/

Plug in your RTL dongle and run rtl_test:

rtl_test -t

You should see an output like this:

Found 1 device(s):
 0:  Terratec T Stick PLUS

Using device 0: Terratec T Stick PLUS
Found Elonics E4000 tuner
Supported gain values (18): -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 43.0 45.0 47.0 49.0 
Benchmarking E4000 PLL...
[E4K] PLL not locked for 51000000 Hz!
[E4K] PLL not locked for 2206000000 Hz!
[E4K] PLL not locked for 1103000000 Hz!
[E4K] PLL not locked for 1243000000 Hz!
E4K range: 52 to 2205 MHz
E4K L-band gap: 1103 to 1243 MHz


Building rtl-sdr on Mac OS X

Update, I found that on Yosemite, you can just use MacPorts to built the rtl-sdr package:

sudo port install rtl-sdr

First I got the code from http://cgit.osmocom.org/cgit/rtl-sdr/

I followed the instructions from http://sdr.osmocom.org/trac/wiki/rtl-sdr

cd rtl-sdr/
autoreconf -i
./configure 
make
sudo make install
sudo ldconfig

The first problem was after ./configure, namely:

configure: error: Package requirements (libusb-1.0 >= 1.0) were not met

Turns out I had an ancient version of libusb.

sudo port install libusb
solved that. 

With the programs built, the next step was running rtl_test:

$ rtl_test -t
Found 1 device(s):
 0:  ezcap USB 2.0 DVB-T/DAB/FM dongle
Using device 0: ezcap USB 2.0 DVB-T/DAB/FM dongle
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6  
No E4000 tuner found, aborting.

So far so good.


Next I tried running rtl_fm, which lets you demodulate a FM signal. AM is supposedly also supported. I say supposedly because I could not get rtl_fm to work properly. It would run, and write demodulated sound data to a file, but playing it back always produced gibberish. Also, the files were way too large for the specified sample rate and length of time the program was running. The documentation for rtl_fm is sketchy. For example, the list of options includes:

[-s sample_rate (default: 24k)]

which naturally makes you suspect -s sets the sample rate. It does no such thing, it actually sets the IF bandwidth. Again, supposedly.

After several hours of trying to get rtl_fm to work properly, I threw in the towel, and moved on to rtl_tcp, which acts as a little TCP server, sending I/Q data to a connected client. I had much better luck here. Running the program produced the following:

$ ./rtl_tcp
Found 1 device(s).
Found Rafael Micro R820T tuner 
Using ezcap USB 2.0 DVB-T/DAB/FM dongle
Tuned to 100000000 Hz.
listening...
Use the device argument 'rtl_tcp=127.0.0.1:1234' in OsmoSDR (gr-osmosdr) source
to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...).

I then connected to it via telnet in another console window:

$ telnet 127.0.0 1234</code>

And the rtl_tcp server program responded with:

client accepted!

and proceeded to send I/Q data to my telnet session, which spewed it to the window. Mission accomplished.

Next I wrote a small program to open a connection to the rtl_tcp server, and grab all the received data, count the number of bytes per second, and display it once per second, as a quick and dirty test to see if everything was working OK. I got around 4M bytes per second, which is correctly for a 2 MHz sample rate (the data is 8 bit I/Q, so there are two bytes per sample).

Building rtl-sdr on Ubuntu 12.10 64-bit

This is for getting rtlsdr and dump1090 working together on Ubuntu. Really not all that much different from the Mac OS X procedure above. I used a fresh install of Ubuntu 12.10.

There's a few packages you'll need installed that probably are not already in a fresh Ubuntu install. So, run this (assuming you are the root user, starting off in /root):

apt-get install git cmake autoconf automake libusb-1*

Let that install any dependencies as well (basically, just say "Y").

Next, create a directory under /root with mkdir /root/git and then change into it with cd /root/git.

Now run:

git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig

That will get you the rtlsdr utilities built. Next, you need to do essentially the same for dump1090:

cd /root/git
git clone git://github.com/antirez/dump1090.git
cd dump1090/
make
cd /usr/local/bin
ln -s /root/git/dump1090/dump1090

That's pretty much it! All of the rtl and dump1090 syntax documented in the Mac OS X section will work on Ubuntu.



This site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. Some links may be affiliate links. We may get paid if you buy something or take an action after clicking one of these.