RTL-SDR FM Radio Receiver With GNU Radio Companion

444K14544

Intro: RTL-SDR FM Radio Receiver With GNU Radio Companion

RTL-SDR is currently very popular topic on the Net. There are also many guides on how to use it on Windows and Linux too. But starting to use it myself I haven't found any guide that explains whole process from installing necessary drivers and software to building first simple receiver using GNU Radio which is the most capable software which could be used with RTL28xxU chips and that's what this Instructable is about. It should be, for me I hope too, first step to learn how the thing works from scratch and to make projects capable of capturing signals that wasn't decoded using RTL-SDR yet i.e. 433 MHz band.

STEP 1: What's RTL-SDR?

If you are interested only in how to make GRC project go to step 5.
RTL-SDR is the cheapest method to get into the world of SDR (Software Defined Radio) - method of receiving (RTL-SDR have no capability to transmit) and processing radio transmission using your PC. Using it you can receive everything that is transmitted between about 20~2000 MHz depending on second chip on the device.
In brief it can hear i.e.:
- ordinary FM radio stations
- police radio transmissions
- plane and ship tracking informations
- small radio devices like car keys
- probably GPS satellites (as of now there is no confirmed method to do this)
- International Space Station and other space equipment that transmits below 2 GHz
- every other device that you know transmits on these frequencies

STEP 2: How to Get It?

The simplest method is to get one on eBay. There are many offers that have in their caption names of the chips that are on board. They costs about 10$. Here you need to be aware of few different chips that are currently on market. The difference between them are frequencies they are capable of receiving. Summary of the differences is on that site: 
http://sdr.osmocom.org/trac/wiki/rtl-sdr
The most reasonable choice is R820T chip and that tutorial is based on its capabilities. The other good chip is Elonics E4000 but they are actually more expensive ones.

STEP 3: What You Will Need?

I'm using Arch Linux and receiver with RTL2838 and Rafael Micro R820T chips. It would be good if you had good antenna cause the one that is included to the package has really bad performance. Of course every Linux distro could be good.

STEP 4: Connecting the Hardware and Installing Software

The first thing is to connect your dongle and check if it has appropriate chips using
$ dmesg | tail
or
$ journalctl
Here I had some troubles with default driver of the dongle that was hanging OS when I unplugged it so I had to disable that driver by creating new .conf file in /etc/modprobe.d that contains one line:
blacklist dvb_usb_rtl28xxu
add that file to initrd by inserting its path to FILES variable in /etc/mkinitcpio.conf:
FILES="/etc/modprobe.d/blacklist.conf"
and generate new image by mkinitcpio -p linux
Now after system restart the problem was solved.
(on other systems the procedure will probably be completely different)
After fixing driver problem you can install packages needed to use RTL-SDR.
Here we will install 'rtl-sdr', 'sdrsharp-svn', 'gnuradio' and 'gr-osmosdr-git'.
rtl-sdr is the main driver and can be installed on Arch from community repo:
# pacman -S rtl-sdr
or its git version available on AUR as rtl-sdr-git
SDR# is the program that offers basic capability to decode FM and AM radio and have easy to learn GUI so using it is the best for beginners. It is available on AUR as sdrsharp-svn.
The most capable software for RTL-SDR is GNU Radio and its graphical tool: GNU Radio Companion. It is also available on AUR (name: gnuradio). It is also required to install package gr-osmosdr-git from AUR that is needed to use RTL-SDR dongle as source in GRC.
(and again on different operating system whole process is different, maybe simpler maybe harder, not tested myself but on Ubuntu rtl-sdr should be available from apt-get and on Fedora it should also be on default repositories, gnuradio has good installation instruction here: http://gnuradio.org/redmine/projects/gnuradio/wiki/InstallingGR)
SDR# could now be used also to find station which signal is strong enough to be received without any disruptions. If you found one after making the program you can check if it's working on that station as good as on SDR#.

STEP 5: FM Radio - Theoretical Introduction

The simplest FM radio consists of few elements:
- signal source - in our case it would be RTL-SDR dongle
- low pass filter
- WBFM demodulator
- audio output - your PC's sound card
There can be few other elements depending on input and output sample rate, if it will be possible to match them using only above elements there won't be any other.

STEP 6: RTL-SDR Source

osmocom Source can also be used here. We can find both of them in Sources category on the right sidebar of GRC. Our signal input. We need to set its sample rate to 2M. It can be done by editing samp_rate variable and setting its value to 2e6. Here we will also set the frequency of the station we want to receive.

STEP 7: Low Pass Filter

The next step is to filter out frequencies other than the one we centered in th previous step. In that task we will use a low pass filter block. It can be found on filters category. We here set cutoff frequency to 100e3. This is because that's standard band's width. I don't know what correct value for transition width should be, but trying to change that I found that the higher value the better so it's finally set to 1M. We also sets decimation to value "int(samp_rate/quadrature)" so it will be slowly matching to our sound card's sample rate.

STEP 8: WBFM Receive

Now we could do the nearly final and the most important step: placing the FM demodulator. Its block can be found on modulators menu. In my case its quadrature rate equals 500k. I don't know if it could be changed to something else so if you are not sure just leave it as is. In that setting it should work. 

STEP 9: Matching to Audio Output and Volume Regulation

That two tasks can be done by using rational resampler and multiply const blocks. The first can be found in resamplers menu and the second is in math operators category. At first we need to convert rate from 500k to 48k so we need to decimate by 500 and then multiply by 48. In the second block we set const to 'volume'. Now we can create variable or place element named "WX GUI Slider". Placing the second one will let us regulating volume on GUI that will be shown after our program starts. This can be of course done with any other variable. 

STEP 10: Audio Sink

And finally we link Audio Sink block (found in Audio) with Multiply const. Now its only required to edit its rate and choose 48k from a drop down list and that's it! If you don't have that option just choose the biggest value and edit value in rational resampler and it should work.

STEP 11: Final Remarks

If you don't know how some step has been done you can find finished project on my site. There is also another project that I created trying to figure out how it works so it has few additional features like FFT graphs. The links are in this post: http://v3l0c1r4pt0r.tk/newsy/czytaj/37 which is a bit modified version of this Instructable.
Finally one more note: during the tests of this schematic I realized that decimation to 500k should not been made on the filter block but before it so I modified it and now demodulated audio is much better than before.

16 Comments

I don't have WX GUI only QT GUI. I am running this on a windows 10 MSI laptop. What can I do?
I am thinking about setting this up, and my goal is to detect GPS signals. I noticed you said it may work or something like that. Is there anything you can tell me that can help me make up my mind about buying these and put in the time? How can I make sure it'll do what I want please?

Anyone know what the audio device path would be for the audio sink running on a raspberry pi?

Device name: hw:0,0 works for me as the device name for the 3.5mm jack output.
aplay -L will list all of the ALSA devices on the pi.
Thanks for the tutorial, it's a fun intro to GNU Radio :)
For the people that face issues regarding IO sizes not matching up: You should set the rational resampler to do float→float and the Multiplier to also use the IO Type float.

Good afternoon everyone.

I write here to see if any of you know that installation errors I may have had to use the r820t2 in gnu radio companion.

I'm trying to make an FM receiver and other analog TV receiver but when running the program does not receive any type of signal and the view errors, I have: devices not supported. I believe that this is some driver to be installed but I don't know where or how.

The steps that I have followed for installation (Ubuntu 16.04 LTS) have been:

  1. Install gnuradio.
  2. Install Xenial Xerius specifications (it is supposed to do I need for my version of Ubuntu).
  3. Install specifications of gr-osmosdr to enable some features of the chip.

The Stick comes with a CD but i do not know how to install it since, according to the specifications only works for WXP, 2000, Vista, 7 and 8; and it is something that it seems strange to me since I have seen videos where they use this same model of stick to carry out projects in Gnuradio on Ubuntu.

Please, if any of you know that i need to install It would serve as much help as I am a novice programmer and i need to resolve this problem for my project.

I've been exploring gnuradio for two days now, and this instructable has been a big boost up the learning curve for me. Sort of the gnuradio "hello world" application on steroids!

I look forward to studying the fm radio in more detail over the next several days. Many thanks!

(Using Ubuntu 16.04 Linux with a generic ebay RTL dongle.)

Little confused on sampling rates, because even with a Transition Width of 1M in the LP filter, my fft sink doesn't show the pilot signal at 19khz.

Should the low-pass-filter always be set to the maximum sampling rate of the entire flowgraph? While the demodulator's Quadrature rate should always be the rate at which the samples are going to it from the (virtual) source or, if connected to directly to the fm modulator block's output quadrature rate? Similarly, the FFT sink sample rate should be at the same rate as where its connected.. noting that the maximum frequency that the fft plot will show is its sample/2?

Also, any tips on how to do AM?
I'm trying to listen to 640khz with a rtl-sdr and HamItUp/SpyVerter. The upconverter puts the RF at 125Mhz, so I tune the radio to 125.64e6 (125e6 + 640e3), then pass it to a low pass filter before demodulating and outputting to the sound card. Unfortunately, it doesn't work, any idea what could be wrong?
http://imgur.com/a/BxBVQ

Worked really nicely! The one thing to note is if you are tuning to an FM frequency, it's in MHz. Meaning 100.3 is really 100.3e6. Also I implemented this with QT GUI options (which is preferred with newer GNU Radio).

Great work... but I think in the Low Pass filter, transition width must be very less. you can choose in between 5k to 10k. Otherwise filtering will not work.

Check filter response...

Just a quick heads up: Texts like these are awesome, but they tend to outdate at some point. The official wiki of GNU Radio, www.gnuradio.org, is the place where information on GNU Radio is gathered.

Generally, to get started, I recommend the continously updated, tested and supported Guided tutorials:

https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorials

They are not as centric on doing a specific thing with a specific piece of hardware, so this won't get you started as fast doing something, but it will explain the core concepts, so you can do anything pretty quickly!

https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorial_Hardware_Considerations/62#A-Working-Software-Radio-Broadcast-FM-Receiver is an example FM radio setup from the GnuRadio site.

I keep getting error messages about source io size 8 doesnt match sink io size 4 for blocks_multiply_const and for the analog_wbfm_rcv0 with those messages reversed.. dont see a way to alter io size.. what am I doing wrong?

but thanx for an excellent tutorial... some clarification about how to connect block in the flowgraph would have been nice (I know afterwards its obvious but i didnt hunt a bit for a few moments.. for that)...

gwen

The error message is not meaningful, but it is happening since you have different data types. If you look at the pictures in the instructable above you will notice the "in" & "out" tab colors are half blue and the other half is orange, these colors define the data type such as int, float, complex ...etc and you must match the type on the intput with the output.

So in your case you need to change the default setting for the rational resampler and multiply const blocks to "float" since the FM receiver output is float, and the audio sink input is also float.

Thanks for getting me started with GNU Radio. Great Instructable.