RTL-SDR FM Receiver: Difference between revisions
Jesternofool (talk | contribs) (Changed the gain from "AGC" to manual, along with an explanation of how to set the gain manually.) |
Jesternofool (talk | contribs) (Modified the type of RTL-SDR usable with this flowgraph. Added discussion of gain on RTL-SDR.) |
||
Line 8: | Line 8: | ||
The following hardware is needed for this tutorial: | The following hardware is needed for this tutorial: | ||
* RTL-SDR | * RTL-based SDR (aka "RTL-SDR"); this flowgraph has been tested on the Nooelec NESDR SMArt, the Nooelec Nano Three, and the RTL-SDR.com v3. As of July 2025, the RTL-SDR.com v4 does NOT work. | ||
* VHF Antenna | * VHF Antenna | ||
Line 18: | Line 18: | ||
[[File:RTL_SDR_FM_add_rtlsdr_block.png]] | [[File:RTL_SDR_FM_add_rtlsdr_block.png]] | ||
The receiver needs to be configured with a proper sampling rate, center frequency and gain value. The RTL-SDR supports multiple sampling rates but in this tutorial the maximum sampling rate of 2.048 MHz is chosen. Update the ''samp_rate'' variable with the value 2048000: | The receiver needs to be configured with a proper sampling rate, center frequency and gain value. The RTL-SDR supports multiple sampling rates but in this tutorial the maximum sampling rate of 2.048 MHz is chosen. Update the ''samp_rate'' variable with the value 2048000: | ||
Line 27: | Line 26: | ||
[[File:RTL_SDR_FM_rtlsdr_updated_samp_rate.png]] | [[File:RTL_SDR_FM_rtlsdr_updated_samp_rate.png]] | ||
The RTL-SDR source block still has an undefined ''freq''. The ''freq'' variable needs to be given a frequency associated with a radio station. This tutorial uses the frequency allocations within the United State of America, therefore you will need to modify them according to the allocation for your country. Within the USA, the smallest frequency of a radio station is 87.9 MHz and the largest frequency is 107.9 MHz [https://en.wikipedia.org/wiki/FM_broadcasting_in_the_United_States], and each channel is separated by 200 kHz. | The RTL-SDR source block still has an undefined ''freq''. The ''freq'' variable needs to be given a frequency associated with a radio station. This tutorial uses the frequency allocations within the United State of America, therefore you will need to modify them according to the allocation for your country. Within the USA, the smallest frequency of a radio station is 87.9 MHz and the largest frequency is 107.9 MHz [https://en.wikipedia.org/wiki/FM_broadcasting_in_the_United_States], and each channel is separated by 200 kHz. | ||
Line 37: | Line 35: | ||
[[File:QT-GUI-Range-general-properties-freq-annotated.png]] | [[File:QT-GUI-Range-general-properties-freq-annotated.png]] | ||
Open the properties of the second '''QT GUI Range''' block | Open the properties of the second '''QT GUI Range''' block, which will be used to adjust the gain of the RTL-SDR. RTL-SDRs have a set of 29 gain values varying from 0 to ~50. In the properties, enter the name ''rfGain'' for the ID, set the label to ''RF Gain (dB)'', the default value of 10, the start value of 0, the stop value of 50, and the step value of 1. Lastly, put the value ''1,0,1,10'' in the ''GUI Hint'' window: | ||
[[File:QT-GUI-Range-general-properties-rfGain-annotated.png]] | [[File:QT-GUI-Range-general-properties-rfGain-annotated.png]] |
Revision as of 14:27, 18 July 2025
Beginner Tutorials
Introducing GNU Radio Flowgraph Fundamentals
Creating and Modifying Python Blocks DSP Blocks
SDR Hardware |
This tutorial describes how to receive broadcast commercial radio stations transmitting Frequency Modulated (FM) signals using the RTL-SDR receiver.
The previous tutorial, Reading and Writing Binary Files, demonstrates how to read and write radio waveform captures as binary files. The next tutorial, B200-B205mini FM Receiver, describes how to build a broadcast FM receiver using the Ettus Research B200/B205mini receiver.
The following hardware is needed for this tutorial:
- RTL-based SDR (aka "RTL-SDR"); this flowgraph has been tested on the Nooelec NESDR SMArt, the Nooelec Nano Three, and the RTL-SDR.com v3. As of July 2025, the RTL-SDR.com v4 does NOT work.
- VHF Antenna
Please connect the antenna to the RTL-SDR, and plug the RTL-SDR into the USB port on your computer.
Configure the RTL-SDR
Add the Soapy RTLSDR Source block to the flowgraph. Soapy [1] is a SDR support library which interfaces with different SDR hardware.
The receiver needs to be configured with a proper sampling rate, center frequency and gain value. The RTL-SDR supports multiple sampling rates but in this tutorial the maximum sampling rate of 2.048 MHz is chosen. Update the samp_rate variable with the value 2048000:
Notice that the sampling rate within the RTL-SDR block has been updated:
The RTL-SDR source block still has an undefined freq. The freq variable needs to be given a frequency associated with a radio station. This tutorial uses the frequency allocations within the United State of America, therefore you will need to modify them according to the allocation for your country. Within the USA, the smallest frequency of a radio station is 87.9 MHz and the largest frequency is 107.9 MHz [2], and each channel is separated by 200 kHz.
Add two (2) QT GUI Range blocks into the flowgraph. The properties need to be changed in order to incorporate the frequency allocations for broadcast FM as well as the adjustable gain of the RTL-SDR.
Open the properties of the first QT GUI Range block and give it the name freq, the label Center Frequency, the default value of 88.5 MHz (or, if you have a favorite FM broadcast station, the frequency of that station), the start frequency of 87.7 MHz, the stop frequency of 107.9 MHz and a step of 200 kHz. Lastly, put the value of 0,0,1,10 in the "GUI Hint" window:
Open the properties of the second QT GUI Range block, which will be used to adjust the gain of the RTL-SDR. RTL-SDRs have a set of 29 gain values varying from 0 to ~50. In the properties, enter the name rfGain for the ID, set the label to RF Gain (dB), the default value of 10, the start value of 0, the stop value of 50, and the step value of 1. Lastly, put the value 1,0,1,10 in the GUI Hint window:
The freq variable within the Soapy RTLSDR Source block is now defined. The flowgraph should look like the following:
Open the Soapy RTLSDR Source block properties. Navigate to the RF Options and enter rfGain within the RF Gain window:
Add Time & Frequency Plots
Drag in a QT GUI Time Sink and QT GUI Frequency Sink:
Open the QT GUI Frequency Sink and enter freq as the Center Frequency (Hz):
Connect the QT GUI Time Sink and QT GUI Frequency Sink blocks:
Run the flowgraph. A time plot and frequency plot will be displayed. This simple flowgraph represents a basic tuner application, such that dragging the slider bar or entering a frequency manually will retune the RTL-SDR and start producing sampled data.
Due to the nature of the RTL-SDR and how it presents data to Gnu Radio, a QT GUI Time Sink at the output of the RTL-SDR source block gives an indication of signal strength and potential overload. The image above, with the RF Gain set to 10, shows the data in the time sink as relatively low amplitude. Depending on the antenna connected to your specific RTL-SDR, your time domain may be higher or lower amplitude. Further, your spectral display (the QT GUI Frequency Sink) will also appear differently.
Adjusting the RF Gain value higher adds gain to the RF front end of the RTL-SDR. This will boost the signal strength and increase the signal-to-noise ratio (SNR). For example, increasing the gain to 31 dB will increase the amplitude within the time sink, as shown below:
Increasing the gain to where the amplitudes within the time sink are close to, but not surpassing, the top and bottom of the display (with limits set to +/-1, which is the default) is optimal for proper reception.
FM Demodulator
An Audio Sink block is needed to play the sound of a demodulated FM radio station. Drag in an Audio Sink block and open the properties. Notice there are a couple choices for sampling rates to choose from. Select 48 kHz:
The flowgraph should now look like the following:
The question is how to get from the output of the RTL-SDR which is complex IQ sampled at 2.048 MHz to the input of the Audio Sink block which requires real samples at a sampling rate of 48 kHz? The rest of this tutorial will work backwards from the Audio Sink and establishing blocks and connections towards the output of the RTL-SDR.
The next block that is needed is the an FM demodulator. Drag in the WBFM Receive block, which takes complex IQ as an input, demodulates the FM thereby producing real output samples and also performs a decimation.
Recall from earlier in the tutorial that FM broadcast channels allocated 200 kHz, therefore we want to process as much of that bandwidth as possible with the FM demodulator. The WBFM Receive block can perform a decimation from a larger input sampling rate to the required Audio Sink input of 48 kHz. The decimation factor must be an integer, and 4*48 kHz = 192 kHz which is close to the total bandwidth of the frequency allocation.
Add a WBFM Receive block, open the properties and enter in the quadrature rate of 192 kHz and an audio decimation of 4. Note that the quadrature rate must be evenly divisible by the audio decimation factor, and that the audio decimation must be an integer.
The flowgraph should now look like the following:
A sample rate change is needed to convert from the RTL-SDR output of 2.048 MHz to the WBFM input of 192 kHz. The required sampling rate change can be simplified as 192000/2048000 = 192/2048 = 3/32, a rational ratio. Therefore the Rational Resampler block can be used to implement the sample rate change.
Drag in the Rational Resampler block and open the properties. Enter 3 for the interpolation and 32 for the decimation:
The flowgraph is now complete and should look like the following.
Run the flowgraph. The same GUI window that was displayed previously will appear but now audio should be playing through your computer. You can drag the bar at the top of the screen to tune to different channels.
Diagnosing Overrun Problems
When you run your flowgraph if you get a string of “aUaUaU” and the audio comes in and out periodically then you have probably entered a sample rate wrong somewhere along the way. Double check all of the sample rate values and interpolation and decimation rate changes.
The next tutorial, B200-B205mini FM Receiver, describes how to build a broadcast FM receiver using the Ettus Research B200/B205mini receiver.