Getting started with SDR on a Mac

Software-defined radio (SDR) is still at the geek stage, so don’t expect to buy a polished consumer kit from Apple’s online store just yet.

It is, though, remarkably cheap at its most basic, with good USB systems costing as little as £20 ($20). To that you need to add the cost of antennas, but the best software is still free. If you want full transceive features (and have an Amateur Radio licence, as anyone transmitting without a licence is likely to be prosecuted), then you will be looking at a price well above £1000.

sdrkit2I bought a “Yosoo UV HF RTL.SDR Radio USB Tuner Receiver R820T+8232 CW FM 100KHz-1.7GHz Full Band RTL-SDR Receiver”, which is one of a class of devices based on the Rafael Micro R820T tuner and Realtek RTL2823U chips known as RTL (the abbreviation for Realtek). These can come as a simple USB stick or dongle, but mine has a miniature USB port which connects using a standard USB cable to any USB2 port, drawing power from that port.

Not all devices using the R820T and 2823 chips function the same, though, and there is no good way of knowing whether yours will, without putting it to the test. Although this is potentially frustrating, the cost involved is thankfully very low.

Another advantage of using an RTL device, besides its low cost, is its generally good software support, even under OS X. Most apps which work with RTL SDR devices work with most such devices, so you are likely to be able to use any of those apps provided that you can get them to compile and link.

Antenna

The basic rule is that the more metal that you put up in the air, and the higher it goes, the better will be signal reception. Antennas are an enormously complex topic, and the large telescopic mast and antenna arrays in my garden illustrate the lengths (and height) to which you can go if you wish.

However for initial test purposes the little whip aerial supplied in some RTL SDR kits should be sufficient to get you started. If you want more, then I recommend that you seek advice from a specialist ham radio supplier, and purchase a wideband compact antenna which you can mount high outdoors.

One significant consideration with most RTL SDR kits is that the antenna ports on them are usually (very) miniature (SMA F), and you will need an adaptor to connect any other antenna to them; this can be solved by a specialist ham radio store, or careful browsing in your local Maplin, etc.

Hardware

RTL radios are tiny, cheap, and really simple, but perform surprisingly well. They are also incredibly versatile. Although some cover a smaller range of frequencies, most should be reasonably sensitive from VLF of around 100 kHz right up to microwave of around 1.7 GHz. Conventional communications receivers with similar capabilities are far more expensive and bulky.

Originally and still used for digital audio broadcasting (DAB) and FM radio and TV reception, Eric Fry started to look at their use for more generic SDR in 2010. The groundwork was then continued by Antti Palosaari and Osmocom in 2012, since when many systems have been put to use as proper SDR.

The Rafael Micro R820T (or equivalent, including the improved R820T2) is the radio tuner sub-system, for which the RTL2382U then performs analogue to digital conversion, and supplies data to the USB port. Different tuner chips offer slightly different frequency ranges, but each accepts similar commands and thus can be controlled similarly.

Software

At first sight, there are many more PC and Linux apps to support RTL SDR devices. But in reality you do not need a wide choice, just one or two good products, which are available for OS X.

The snag with most of these apps (for any platform) is that they do not come as simple binary installers: you will need to use the likes of MacPorts or Homebrew and compile them on your own Mac using the command-line tools which come with Apple’s Xcode SDK. But as Xcode is free (from the App Store), and the apps are free, this is actually a good deal.

Some non-RTL SDR systems are supported by the excellent SdrDx, but at present it does not seem to support most RTL devices.

The most popular app on OS X for use with RTL devices is probably Gqrx. My own experience with trying to get this installed differs from most. Despite following the instructions to the letter, it failed to compile and install here using the current MacPorts, which reported inscrutable errors.

This is one of the problems with system such as MacPorts: when they work they are magic, but when they fail they are almost impossible to debug. Maybe on another day it would have worked fine. Gqrx is overall a huge package, as MacPorts decides that you need all sorts of dependent products, and here it was happy to consume around 8 GB of disk space by the time it decided it could not build: this is because Gqrx is based on GNU Radio, which itself is expansive to say the least.

CubicSDR

Instead I struck gold with CubicSDR, using the command line version of MacPorts as its installer. However even that did not quite work as advertised.

First, if you do not have Xcode already installed, you must ‘buy’ that from the App Store and install it. From within Xcode you will then need to agree to the licence agreement, and download and install the command line tools. If you think you may have done the latter already, check that you have, as without them the rest will fail miserably.

Then take a trip to MacPorts, from which you should download and install the standard installer for your version of OS X. The CubicSDR Wiki also offers a Homebrew installation, which I tried first, but that stumbled fatally over folder permissions. I then used MacPorts, although my successful command sequence was slightly different from that given here:
sudo port install rtl-sdr fftw-3-single liquid-dsp wxWidgets-3.0-libcxx
git clone https://github.com/cjcliffe/CubicSDR.git
cd CubicSDR/cmake (not cmake_build)
cmake ../ -DwxWidgets_CONFIG_EXECUTABLE=/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.0-libcxx/bin/wx-config
make
cd x64 (which is the folder containing the binary executable)
./CubicSDR
which starts the app. Before pressing Return on the final command, ensure that your RTL SDR is plugged in and powered up.

sdrcubicsdrYou will then see a steady stream of helpful information in the Terminal window, and the single-window displays and controls for CubicSDR itself. Its controls may at first seem a bit idiosyncratic, but you will have fun working them out whilst you listen to noise!

Build your own app

If you don’t fancy writing your own software to control your RTL SDR device, but want to experiment with unusual modes, decoding, signal processing, and generally explore SDR more, then the best place to begin is with Matlab. Provided that you have its Communications System Toolbox, DSP System Toolbox, and Signal Processing Toolbox, MathWorks provides a free hardware support package for RTL-SDR devices. You can then stream their output into your own signal processing software.

sdrmatlabThis may seem expensive, but a hobbyist who is not doing this commercially can buy Matlab for a bargain price, and each toolbox for another £25 or so. Thus the total cost is still much less than even a high-end SDR receiver, and can be customised to do almost anything that you want. As a tool in education, the combination of Matlab and RTL SDR is seriously exciting, littleBits for signal processing.

So if you are not a geek but have read this far, you may still be unimpressed. All I can suggest is that you invest your £20/$20 and give it a whirl: you could soon be listening in to the International Space Station.