Sunday, October 23, 2016

Software Defined Radio and ADS-B with RTL-SDR

I recently participated in an introduction to Software Defined Radio (SDR). The point of the introduction was to get an RTL-SDR device running and then check out ADS-B. This was a load of fun and I've pulled together here a few notes to document my experience as a newbie.

The notes here focus on the software that worked for me, with particular focus on getting meaningful ADS-B data.

What is SDR?

Software Defined Radio (SDR) has advantages over traditional radio concepts by farming aspects of signal processing to software, rather than requiring expensive hardware. Additionally, SDR provides a practical solution to handling tracts of frequencies at the same time.

What is RTL?

RTL is shorthand for the affordable and apparently versatile Realtek 2832U chipset found in the SDR dongles referenced in this blog. See more information on the rtlsdr.org website.

What is ADS-B?

The introduction I attended was to demonstrate the RTL-SDR as a radio receiver and then move to listening in on ADS-B data from aircraft. This data includes flight information like where the aircraft is in the air, how fast it's moving, flight number, an ICAO 24-bit transponder code and so on.

Is Listening to ADS-B legal?  

Apparently so and commonly done, since services like FlightRadar24 openly track the same data. It is probably safe to say that it is not illegal to listen to anything on the radio spectrum since it is in the public domain

What RTL-SDR Should I Buy?

NooElec NESDR Mini USB RTL-SDR
Two weeks before the SDR introduction was scheduled, I purchased a NooElec NESDR SMArt - Premium RTL-SDR via Amazon but the thing never showed up. At the last minute I purchased instead the NooElec NESDR Mini USB RTL-SDR (pictured right), which arrived the next day (thanks Amazon Prime). The RTL appears to be the same in both, the difference is that the former device had three aerials and an SMA input. The SMA is supposedly more versatile, but adapters are available. The aerial on the latter and cheaper unit isn't fabulous, but for my initial purpose it worked well.

Software - Windows

First off, if you bought a NooElec device, you'll need to follow the instructions for installing the correct drivers under Windows. There's another nice quick-start guide here.

SDRSharp | SDR#

Under Windows I was easily able to use the SDR Sharp (SDR#) software to tune into FM radio stations and amateur frequencies. It seems to be the general-purpose Windows radio software.


The important config points are that you select RTL-SDR from the Source and then select the cog icon at top to bring up the Device settings (right).

There is also HDSDR and CubicSDR that appear to do the same job as SDR#. I did play around with them, but SDR# is the one I primarily use under Windows.

The moment that you need to do anything interesting, however, it seems that you need to switch to Linux. I can confirm that on Windows 10, dump1090 works very nicely with VirtualRadar and with almost no configuration required. This post isn't going to discuss setting all that up, it's well enough documented on the rtlsdr.org website.

Software - Linux

For a Windows-only person, this isn't as daunting as it sounds. You can run Linux as a Virtual Machine on your Windows system. A number of steps need to be undertaken to get that going. This starts with installing VirtualBox or VMware Player, both are free downloads. VirtualBox seems like less hassle but I find VMware Player more flexible and useful. For this situation, VirtualBox is fine.

Also remember to connect the RTL device to the Virtual Machine (VMware screenshot):


Once you have a Linux system running, either as a Virtual Machine or natively installed you might find the following packages useful to install (these are debian / ubuntu packages):
$ sudo apt-get install git cmake libqt5core5 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5svg5 libqt5widgets5 qt5-default gnuradio-audio gnuradio gnuradio-dev gnuradio-dev libgnuradio-audio3.7.10 open-vm-tools rtl-sdr gqrx-sdr

gqrx

gqrx appears to be the Linux standard for Windows' SDR#. Naturally there's nothing new I can add to the existing config docs, but here is how I configured it for RTL-SDR:


rtl_adsb

This application should automatically pick up the RTL-SDR device and tune into the ADS-B frequency, streaming the data to a network port that another application can connect to. I recommend something like this, which keeps the application alive and connects to a port (this example 10000) that you define:
$ while :; do rtl_adsb | netcat -lp 10000 127.0.0.1; done
We will use VirtualRadar to read the data.

dump1090 is an alternative to rtl_adsb, but as it is not part of the default Debian package sources I had trouble getting it compiled (in fact I got it running well after the workshop).

Note also that ADSBSpy, which comes with SDRSharp did not not seem to be RTL-SDR compatible.

VirtualRadar

VirtualRadar will take the ADS-B data and render it against a Google Map. VirtualRadar doesn't care what the data source is, just so long as the source provides data that VirtualRadar can parse.

VirtualRadar runs well under Linux although requires 'mono' to run:
$ sudo apt-get install mono-complete
$ mkdir VirtualRadar
$ cd VirtualRadar/
$ wget http://www.virtualradarserver.co.uk/Files/VirtualRadar.tar.gz
$ tar xvf VirtualRadar.tar.gz
$ mono VirtualRadar.exe
Pay attention to the VirtualRadar.exe.config edit that you may need to make described here.

The main panel looks something like the screenshot below. One clicks on the http link to see the Google Map with the detected planes mapped against it, but remember that your PC/laptop requires a web connection to render the Google Map:


Setting up the right "receiver" information is critical. Below is a configuration screenshot when using rtl_adsb as the data source. Notice that the Port 10000 is that which is used in the rtl_adsb example above.



What to Expect

If you live near an airport, even with an imperfect antenna you should receive 1090MHz signals easily. However, as you get further from an airport your chances of picking it up lessen. The ADS-B data is almost impossible to pick up indoors, it really favours an antenna located outside and line-of-site.

If you want to build a perfect antenna for ADS-B, check this site out:

You Gotta Keep 'em Calibrated

Listening to a signal from a known precise station will tell you how far off your SDR is. My father, an amateur radio operator who was visiting me at the time, used an APRS channel to ascertained a -10,000Hz offset on my RTL-SDR. This will vary from device to device. He recommended amateur radio stations as reliable sources because they have a somewhat self-regulated standard of precision. I guess you could also calibrate off a known FM radio station if you were sure of its exact frequency.

What Next?

Good question. I have more to investigate. Stay tuned ;-)

1 comment:

  1. Unlike most tech blogs, this one actually bothered to explain in laymen's terms the content that it features. The content is organized, colorful and the pictures are wonderful.

    ReplyDelete