Rtl-sdr on Ubuntu
It was recently discovered that several cheap DVB-T usb dongles could be configured to be used as cheap ham radio receivers.
Follow along with the discussions here: http://www.reddit.com/r/rtlsdr or find some of the useful software here: http://sdr.osmocom.org/trac/wiki/rtl-sdr
I picked up one of the compatible receivers from ali-express:
http://www.aliexpress.com/snapshot/106450763.html
and will document here the steps I took to set it up with gnuradio on ubuntu 12.04.
There are a few things that I won't cover in this instructable, because they deserve an instructable of their own. These include:
1) using the Ubuntu command line (terminal)
2) cloning a git repository
3) building software from source on Ubuntu (especially with cmake)
If anyone has links to stellar, class A++ quality tutorials on any of these things, please add them to the comment and I will link them here.
Follow along with the discussions here: http://www.reddit.com/r/rtlsdr or find some of the useful software here: http://sdr.osmocom.org/trac/wiki/rtl-sdr
I picked up one of the compatible receivers from ali-express:
http://www.aliexpress.com/snapshot/106450763.html
and will document here the steps I took to set it up with gnuradio on ubuntu 12.04.
There are a few things that I won't cover in this instructable, because they deserve an instructable of their own. These include:
1) using the Ubuntu command line (terminal)
2) cloning a git repository
3) building software from source on Ubuntu (especially with cmake)
If anyone has links to stellar, class A++ quality tutorials on any of these things, please add them to the comment and I will link them here.
Install Gnu-radio
It looks like there are two options for installing an up-to-date gnuradio on ubuntu:
1) use an install script
2) install from source
Don't ask me why, but I tried the second option (probably the harder). After a first attempt that failed, I went for the first (and recommended option) to much success! So... lesson learned. Note to self, follow advice of program developers when installing software.
My advice, use the install script.
1) use an install script
2) install from source
Don't ask me why, but I tried the second option (probably the harder). After a first attempt that failed, I went for the first (and recommended option) to much success! So... lesson learned. Note to self, follow advice of program developers when installing software.
My advice, use the install script.
Install Rtl-sdr Tools
Next, you want to install any missing rtl-sdr specific tools from here:
http://sdr.osmocom.org/trac/wiki/rtl-sdr
Again, rather than duplicating instructions, follow the steps outlined here to install the rtlsdr library & capture tool: git://git.osmocom.org/rtl-sdr.git
Although this page also mentions a gnu radio module (git://git.osmocom.org/gr-osmosdr) I was unable to get it to work. Instead, I installed:
https://github.com/balint256/gr-baz
as recommended from here: http://2h2o.tumblr.com/
the basic steps are:
git clone https://github.com/balint256/gr-baz
cd gr-baz
sh bootstrap
./configure
make
sudo make install
sudo ldconfig
Now you should have all the necessary software to communicate with the DVB-T dongle using gnuradio.
http://sdr.osmocom.org/trac/wiki/rtl-sdr
Again, rather than duplicating instructions, follow the steps outlined here to install the rtlsdr library & capture tool: git://git.osmocom.org/rtl-sdr.git
Although this page also mentions a gnu radio module (git://git.osmocom.org/gr-osmosdr) I was unable to get it to work. Instead, I installed:
https://github.com/balint256/gr-baz
as recommended from here: http://2h2o.tumblr.com/
the basic steps are:
git clone https://github.com/balint256/gr-baz
cd gr-baz
sh bootstrap
./configure
make
sudo make install
sudo ldconfig
Now you should have all the necessary software to communicate with the DVB-T dongle using gnuradio.
Setup Udev Rules
Next, you need to add some udev rules to make the dongle available for the non-root users. First you want to find the vendor id and product id for your dongle.
The way I did this was to run:
lsusb
The last line was the Realtek dongle:
Bus 001 Device 008: ID 0bda:2838 Realtek Semiconductor Corp.
The important parts are "0bda" (the vendor id) and "2838" (the product id).
Create a new file as root named /etc/udev/rules.d/20.rtlsdr.rules that contains the following line:
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", GROUP="adm", MODE="0666", SYMLINK+="rtl_sdr"
With the vendor and product ids for your particular dongle. This should make the dongle accessible to any user in the adm group. and add a /dev/rtl_sdr symlink when the dongle is attached.
It's probably a good idea to unplug the dongle, restart udev (sudo restart udev) and re-plug in the dongle at this point.
The way I did this was to run:
lsusb
The last line was the Realtek dongle:
Bus 001 Device 008: ID 0bda:2838 Realtek Semiconductor Corp.
The important parts are "0bda" (the vendor id) and "2838" (the product id).
Create a new file as root named /etc/udev/rules.d/20.rtlsdr.rules that contains the following line:
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", GROUP="adm", MODE="0666", SYMLINK+="rtl_sdr"
With the vendor and product ids for your particular dongle. This should make the dongle accessible to any user in the adm group. and add a /dev/rtl_sdr symlink when the dongle is attached.
It's probably a good idea to unplug the dongle, restart udev (sudo restart udev) and re-plug in the dongle at this point.
Test It Out
Now, plug in the dongle and run the following command to test out rtl-sdr:
rtl_sdr capture.bin -s 1.8e6 -f 392e6
Ctrl-C the program after a second or so. If you saw no errors, you should see a file named capture.bin in your current directory. If the program complains about not being able to open the device, try sudo-ing the command. If that helps, the udev rules are probably incorrect.
If all is still going well, try out the attached rtl.grc gnu-radio graph by downloading it and opening it with:
gnuradio-companion ~/Downloads/rtl.grc
It is a modification of the graph from http://2h2o.tumblr.com/ to use a pulse audio (Ubuntu default) rather than an ALSA audio sink.
If you've reached this point with no errors, you are now as far as I am :)
Enjoy! and please add any resources you have on using gnuradio to the comments.
rtl_sdr capture.bin -s 1.8e6 -f 392e6
Ctrl-C the program after a second or so. If you saw no errors, you should see a file named capture.bin in your current directory. If the program complains about not being able to open the device, try sudo-ing the command. If that helps, the udev rules are probably incorrect.
If all is still going well, try out the attached rtl.grc gnu-radio graph by downloading it and opening it with:
gnuradio-companion ~/Downloads/rtl.grc
It is a modification of the graph from http://2h2o.tumblr.com/ to use a pulse audio (Ubuntu default) rather than an ALSA audio sink.
If you've reached this point with no errors, you are now as far as I am :)
Enjoy! and please add any resources you have on using gnuradio to the comments.