Mode-S and ADS-B on a Raspberry Pi

Caveat

What follows is what I wrote the day after setting up my Raspberry Pi to receive and decode Mode-S and ADS-B messages from commercial aircraft. Before publishing this post, I followed my own instructions to get it working a second time. I failed. I failed not because my steps are wrong; I failed not because I made a mistake. I failed because for some unknown reason my Raspberry Pi — which had been working just fine earlier in the day and on which nothing had been changed by me — suddenly would not connect to the Internet at all. Not via ethernet and certainly not via wifi, despite both having worked earlier. I spent hours — hours — trying to re-establish networking on the Pi, all to no avail. I came very, very close to pitching it out the window and into the traffic in the road. In the end, I gave up.

I know the steps below work. It had been my intention to go through the process again so that I could: a) ensure I had my documentation correct (I’m 99 per cent positive it is); and b) so I could snap some screenshots to accompany this blog post. I got as far as cloning the git repository for RTL-SDR before the networking went south on me. Unfortunately, there isn’t much worthy of a screenshot before that step. Sorry…and good luck.


The Tutorial

I was asked a few weeks ago if it was possible to use a Raspberry Pi instead of a PC to receive and share Mode-S and ADS-B message from aircraft. At the time, I knew sharing was possible because sites like FlightRadar24.com had software available for Linux distributions that could be used to upload the data stream to their site, but I hadn’t figured out yet how to decode the data on a Pi.

I had pretty much given up on that until this past weekend when I noticed my Pi was starting to gather dust, and rather than see it become a useless doorstop (though even in a case it isn’t heavy enough to be one of those!) I thought I’d give it another go. Plenty of reading, hours of frustration, a trip to the computer store and a bottle of acetaminophen later, I have it working… though I’m really not sure it was worth the effort and pain.

Maybe you can take what I learned, though, and figure out how to do it better, so here’s what I did…

Use a Powered USB Hub

A large amount of my frustration stemmed from the Raspberry Pi’s underpowered USB ports. Do yourself a favour and buy a cheap powered USB hub. I got a 4-port Belkin USB 2.0 hub with AC adapter for $10. Plug the hub into the Pi and then plug everything else into the hub. I have a keyboard, mouse, wifi adapter and my RT2832U/R820T DVB dongle plugged into my hub. Saved my sanity once I figured out that was the route to go.

The Latest OS

I had messed around with my Pi so much after getting it that I was sure I had bloated it with useless libraries and extensions, so I decided to start fresh. I grabbed a spare SD card and put the latest Raspian “wheezy” release on it. You can download that from here. Note that I did not download the “Soft-float Debian,” though this might have actually saved me a headache later on when it came to install mono. Live and learn, right? More on that later.

How you get the latest Raspian distribution onto your SD card depends on the OS you’re using on your computer. I’m on a Mac so I used RPI-SD Card Builder. If you’re using Windows, you may want to try Win32DiskImager. For a list of other SD card-writing tools for other operating systems, look here.

Once you have your SD card imaged with the latest Raspian OS, connect your Raspberry Pi to a display, power it up and go through the initial configuration. The SSH server should be enabled by default but I recommend running that option again to be sure. If your Pi isn’t connected by cable to ethernet and you’re using wifi instead, run the wifi configuration app (it’s an icon on the desktop) and setup your wifi connection.

Upgrade

Yep, a fresh install, right out of the box, and the first thing you need to do is upgrade the damn thing. Figures. This is a somewhat lengthy process (20 minutes on mine on high-speed broadband Internet) but it’s a necessary evil. So launch the LX Terminal from the desktop and enter the following command:

sudo apt-get upgrade

You’ll be asked to enter your password. If you’re using the default “pi” user and didn’t change the password during the initial configuration, then your password is “raspberry”. That will start the upgrade process. You may have to answer a Yes or No prompt early in the process so don’t just walk away. Once text starts moving up the screen at a regular rate, then you can just let it run for a bit until it finishes.

Install Git

You need git in order to be able to clone some applications from the git repository. What’s git? Beats the hell outta me but I know I had to do it, so you probably should too. First you need to ensure your software list is up-to-date, so enter:

sudo apt-get update

Once the list is downloaded and up-to-date, you can install git by typing:

sudo apt-get install git

Follow the prompts. This is a quick install, as is most of the rest of the software and utilities you need.

Cmake

It’s a mystery to me why this isn’t included on the official Raspbian distribution, because you need cmake to install so many other utilities. Install it by typing:

sudo apt-get install cmake

RTL-SDR

Ah-ha! Now we’re getting somewhere. RTL-SDR probably sounds familiar to you at this point. In fact, if you’ve used your dongle for Mode-S/ADS-B purposes on a PC then you’ve no doubt previously downloaded aspects of RTL-SDR in order to get the dynamic link libraries that RTL1090 uses. We need them on our Raspberry Pi, as well, so let’s git them:

sudo git clone git://git.osmocom.org/rtl-sdr.git

That will create a directory in your home folder called rtl-sdr and will download the software to it. You then need to actually install the utilities, so enter the following commands one after the other:

cd rtl-sdr/
mkdir build
cd build
cmake ../
make
india viagra generic  One can simply order Caverta from the online drugstores with just a click.SIDE EFFECTS :Like all medicines, Caverta (Sildenafil citrate) can cause some more serious damages. A chronic deficiency in vitamin B12 might lead to erectile dysfunction. http://www.icks.org/html/04_publication.php?cate=SPRING%2FSUMMER+2009 buying levitra I was so wrong! What is the main ingredient in  tadalafil 20mg tablets Plus is still Sildenafil citrate, the same component found in the original version of blue pills. levitra no prescription What is Propecia?Generic Propecia, like the brand-name version, contains Finasteride. sudo make install
sudo ldconfig

Now that the utilities are installed, you need to copy a file — called the “rules” — to a directory where the system can access it. First let’s go back to our home folder:

cd ~

Then type the following to copy the rules for the different kinds of RT2832U dongles to a system directory:

sudo cp ~/rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/

Now let’s plug in the dongle and test the connection to it with this command:

rtl_test -t

Hopefully it works!

We’ve installed quite a bit of software and utilities up to this point, so to be sure we don’t have any trouble later let’s reboot the Raspberry Pi:

sudo reboot

Decoder Software

There are two different options for decoding the data received by your dongle. The first is rtl_adsb, which you’ve already installed as part of rtl-sdr in the previous step. If you want to run it and pipe the data stream across your network so you can receive it in PlanePlotter or other virtual radar software, launch LX Terminal again from your desktop and type in:

rtl_adsb | netcat -lp 10003

For a list of parameters you can use with rtl_adsb, type in:

rtl_adsb --help

The second deprer utility is called dump1090 and installing it is easier than rtl-sdr:

sudo git git://github.com/antirez/dump1090.git

Just like when you installed rtl-sdr above, this downloads dump1090 and puts it in a directory in your home folder called dump1090. And as you did with rtl-sdr, you have to install it after downloading it. This step is easier, though:

cd ~/dump1090
make

Piece of make…er, cake. Piece of cake.

dump1090 behaves a bit like the newer versions of RTL1090 in Windows. It outputs a list of aircraft in your terminal window and has a built-in web server that can plot those aircraft on a Google map. For a full list of parameters and other documentation on using dump1090, visit this page.

If you’re happy with your Raspberry Pi simply decoding Mode-S and ADS-B data and sending it across your network, then STOP HERE. If you like pain and suffering, then you might like to install…

Mono and Virtual Radar Server

Yep, VRS can be run on a Linux box (like the Raspberry Pi). You need an additional piece of software, though, that simulates Microsoft’s .NET framework within the Linux OS. It’s called mono. Now, if you installed the Raspian “Wheezy” OS like I told you back at the beginning, then the regular mono download and install won’t work for you. Sorry, but I didn’t know that when I started. You’ll need to download and install an experimental version of mono to run VRS in Raspian. Sounds dicey but it’s easy and it works:

cd ~
wget https://www.dropbox.com/s/sask17flot3zqlg/mono_2_11_4_armv6hf_binary.tgz
cd /
sudo tar zxvf /home/pi/mono_2_11_4_armv6hf_binary.tgz

That’s all there is to it but if you’d like to read more about this experimental version, you can do so here.

If you decided not to listen to me back at the beginning and instead downloaded and used the Soft-float Debian “wheezy” distribution, then you can use the stable mono release:

sudo apt-get install mono-complete

However you installed mono, it’s ready to use right away. So let’s download Virtual Radar Server and install it. You have to download a Mono-Linux-specific version of VRS, which you can get here. You can also follow the installation instructions on that page. I suggest you unpack the download to

~/VRS

so that it’s easily accessible from your home folder. Then to launch VRS you open a LX Terminal window and type:

mono ~/VRS/VirtualRadar.exe

From that point on you can configure it and use it exactly like you would on a Windows PC. Hopefully your experience is better than mine, though, because I find my Raspberry Pi is painfully slow once I start running VRS. I suppose it’s more of a proof of concept to be able to do this, because the Pi doesn’t have a ton of horsepower. If I’m feeling really brave one day I might try to install Debian, or Fedora, or Ubuntu on one of my Dell Latitude D600 laptops and try this all again…

7 replies on “Mode-S and ADS-B on a Raspberry Pi”

  1. Hi

    Thanks for putting this all together.

    I get to the step of install RTL-SDR, and see the rtl-sdr directory on my RPi. When I do the cmake../ step, I get error msgs (I apologize I am not at home, where my RPi resides). I did all of the steps, including upgrade, as described in your essay

    Thanks in advance
    Todd

    1. Hey, Todd. Just this past weekend I gave my RPi another shot using the instructions I found at http://www.satsignal.eu/Radio/dump1090.html and had success. I reformatted my SD Card and reinstalled the Raspian Wheezy OS and started from scratch and it worked. Not being a Linux guy at all (I merely dabble from time to time) I’m completely at a loss regarding what the issue may be that you’ve run into following my instructions. After all, the caveat at the start says I tried my instructions a second time and failed, even though they had worked once. My own personal opinion is that the RPi is flaky as a production tool but is pretty good as an educational device.

    2. Beating a dead horse here:
      I guess you didn’t have make, gcc and libusb-1.0.0-dev installed.
      Deleting the CMakeCache.txt after a failed build also helps.

  2. Thanks for putting this together, it worked first time thanks to your step by step instructions, just what myself a linux noob needs

Comments are closed.