I moved recently, during which time I came across my original RTL-SDR dongle plus some variants I had found on Amazon from other vendors. I had originally purchased them to compare and play around with some waveform design, but they got shoved in a drawer and forgotten about however many years back when I bought them.
Now that I have found them again with a few more years of SDR development behind me, I wanted to do some tutorial content to show how these devices are great for learning quite a bit about waveform design and signal processing in SDRs.
To start, I just want to make sure my setup works. That entails getting some interface software installed on my host machine, then I'd like to try to listen to some local FM radio stations to verify my RTL-SDR dongle works properly.
Since I'm using Mac OS, the best option for interface software is GNU Radio with the GNU OsmoSDR device library installed (which contains the RTL-SDR drivers and GNU Radio flowgraph blocks). It's also super easy to throw together a flowgraph to receive/demodulate FM radio stations in GNU Radio.
Mac OS Environment PrepIf you haven't already, install Xcode from the Mac App Store (it's free), open it to be able to agree to the T&C pop-ups, and download the base environment stuff for Mac OS. Then open a terminal to install the Apple Command Line Developer Tools:
~ % xcode-select --install
If you already have Xcode and the Apple Command Line Developer Tools installed, make sure Xcode is fully up-to-date and repoint the Apple Command Line Developer Tools it with the following command (they seem to cache the old version of Xcode and it'll confuse any package managers trying to using it):
~ % sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
If you haven't picked up already, a package manager is required to install the RTL-SDR software itself and most other SDR-related software to use the RTL-SDR with such as GNU Radio. The best two I've found so far for Mac OS are MacPorts and Homebrew.
Install GNU Radio & RTL-SDR SoftwareUnfortunately, I discovered that both the GNU Radio and GNU OsmoSDR (gr-osmosdr
) packages were severely out-of-date in both the MacPorts and Homebrew repositories (at the time of writing, the repositories are at v3.8.5.0).
I took a stab and installed them anyways; because if it still works for my application, I don't really care if it's out-of-date. However, I found that on Mac OS version 14 (Ventura) the GNU Radio v3.8.5.0 does not install properly and the entire gr-digital
library shows as missing (which means no digital modulation line FSK, PSK, OFDM, etc).
This is when I went back to GNU Radio's website and noticed their recommended installation method had changed (it had been MacPorts for years which is why I didn't check initially). The new recommended installation method for Mac OS and Windows for GNU Radio is to now use the Radioconda installer.
Radioconda is a collection of open-source SDR packages/libraries bundled together and installed with the Conda package manager. This is super handy because GNU Radio plus all of the devices libraries (such as the RTL SDR drivers - full list here) get installed all at once.
It appears that going forward, this Conda repository is what will be updated with the latest versions of GNU Radio and the corresponding SDR device libraries. So I'm doubtful that the repositories in MacPorts or Homebrew are going to be updated.
There is a dmg package installer for both Intel-based Macs and Apple Silicon Macs. I'm using an Intel-based but once installed, everything works the same way regardless.
Simply run the dmg package installer and follow the prompts to install:
After installation, open a terminal window and launch the GNU Radio Companion (unfortunately there is no icon in Applications folder for GNU Radio with the Radioconda installer):
~ % gnuradio-companion
As a sanity check before trying to connect to the RTL-SDR dongle from GNU Radio Companion, I opened a separate terminal window and typed rtl
followed by the tab key twice to verify the RTL-SDR device libraries were installed/available:
~ % rtl_
rtl_adsb rtl_biast rtl_eeprom rtl_fm rtl_power rtl_sdr rtl_tcp rtl_test
The rtl_test
command is perfect for validating a successful connection with the RTL-SDR dongle:
~ % rtl_test
Then the rtl_power
command is handy to see the received power levels across a specified range of frequencies. So I did this for the typical FM radio frequency range/spacing:
~ % rtl_power -f 88M:108M:125k
Which is a great reminder that antenna selection is extremely important based on the target application...
Antenna Selection for FM Radio Station ReceiverThe most basic thing to know about antenna selection for any RF application like SDR, is that the antenna's dimensions are a direct result of the target frequency of your application.
The ideal length of type of antenna for an application is 1/4 (one-quarter) the wavelength of the target frequency. This is referred to as the "resonant length" of an antenna for a specific frequency.
When a sine wave starts out at the input of the antenna (the feedpoint), it has one polarity. When it hits the end of the antenna 1/4 of a cycle later, it is reflected back in the opposite polarity and makes it back to the feedpoint another 1/4 of a cycle later. Since that reflected wave in the opposite polarity makes it back to the feedpoint 1/2 of a cycle later, it now matches the polarity of the 2nd half of the cycle of the original sine wave is being driven into it.
Therefore the current at the antenna is "reinforced", giving it a low impedance. In other words, it can drive larger current at a lower voltage; and the larger the current, the stronger the EMI field is that radiates from the antenna. This also gets the antenna to that standard 50Ω mark and minimize the amount of complex impedance matching that needs to be done to avoid loss.
I have a simple dipole antenna that's adjustable in length so I can use it across the VHF band of frequencies by simply adjusting each side to 1/4 of the target frequency wavelength.
The formula to calculate wavelength of a given frequency is simply the speed of light divided by that frequency. There are plenty of online wavelength calculators like this one.
Then divide the wavelength by four to get the 1/4 wavelength!
FM Radio Station Receiver in GNU RadioI've attached my flowgraph below for a simple FM radio receiver, and it's very similar to examples that have been put out in the past:
I'm going to save the signal processing details for the next write-up as I feel it deserves a more in-depth explanation. But for now, the main objective is just to verify my RTL-SDR dongle works and I've selected the right antenna.
So I simply took each radio station's frequency, calculated the 1/4 wavelength, set my dipole to the right length, and ran the flowgragh:
I looked up my local radio stations using radio-locator.com since they tell me the broadcast distance, and I experimented with tuning into different stations closer and further away from me to demonstrate what signal integrity issues/symptoms occurred due to simply being out-of-range of a given station's broadcast (versus what issues occurred due to improper signal processing in my flowgraph).
It was interesting to see how quickly it became obvious what sounds in the audio were due to improper signal processing (voices sounded distorted or the wrong speed) versus the signal just being too weak and being taken over by noise (voices sounded normal, but just under a layer of static).
This is also a great exercise to see how changing the length of the antenna impacts the signal quality (in case you weren't convinced of the 1/4 wavelength figure).
And that's the RTL-SDR with GNU Radio on Mac! Stay tuned for future write-ups!
Comments