Sunday, October 5, 2014

Real Time Tracking of Aircraft with the Raspberry PI

Almost all the aircraft flying overhead broadcast tracking information on 1.09GHz via ADS-B.  ADS-B is an open protocol.  So what?  Well, it means you can decode it.  If you are just interested in what information this RasPI set up can provide to you take a look at the pics below.  Keep reading if you are interested in duplicating the rig.
-----
The two graphs below show how many aircraft were tracked and how many positions were reported to FlightAware.com (more on this later):
-----
The daily history log that produced the graph above:
-----
The Polar/Spider chart below shows the direction and distance from your rig of the planes that were tracked.  This chart can help with antenna location:
-----
The rig will also give a real time status of the planes being tracked.  If longitude/latitude information is available from the plane the ground track will be plotted (http://192.168.1.6:8080):
----
Still interested?  Setting it up is pretty easy now thanks to satsignal and FlightAware.com; check out these sites if you want more detail or have a problem.   Anyone with some ambition should be able to duplicate the build.  When I first took the project on things were not quite as straightforward; it was even kinda difficult....    The build is now more mature allowing this original blog entry to be edited down to just a few command lines and some tips.  It seems like a lot of commands, but copy/paste makes will make the install fast.  Most of the info on this page comes from the two sites mentioned above so look there is you want details.
-----
EDIT November 1, 2014: Getting your RasPI running is now nearly 'brain dead' simple.  See this link at FlightAware.Com
-----
- You'll need a Raspberry PI running Raspbian (NOOBS is fine) with always on internet connection.

- You'll also need a Software Define Radio (SDR).  This SDR from Amazon is less than $10. It works fine, but a better antenna could help.  The included antenna will give ~100 mile range with good placement and look something like this:

- Use a good solid USB power source for the RasPI as the SDR will need the juice to run reliably.
- Goto FlightAware.com and get an account.  It's free.
- Install some software to ready the SDR for 1.09GHz tune, decode the ADS-B signals, and display the planes the rig tracks in a text format.  This install is well documented at satsignal.eu , but below it is boiled down just to the install commands and a few tips.  If you have issues (you probably will not) head to satsignal.eu and check into their details.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install git-core
$ sudo apt-get install git
$ sudo apt-get install cmake
$ sudo apt-get install libusb-1.0-0-dev
$ sudo apt-get install build-essential
$ git clone git://git.osmocom.org/rtl-sdr.git
$ cd rtl-sdr
$ mkdir build
$ cd build
$ cmake ../ -DINSTALL_UDEV_RULES=ON
$ make
$ sudo make install
$ sudo ldconfig

Now plug in the USB SDR dongle.

$ sudo ldconfig
$ cd ~
$ sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/
$ sudo reboot
$ rtl_test -t

If you get this error:
   Found 1 device(s):
   0: Generic RTL2832U
   Using device 0: Generic RTL2832U
   Kernel driver is active, or device is claimed by second instance of librtlsdr.
   In the first case, please either detach or blacklist the kernel module
   (dvb_usb_rtl28xxu), or enable automatic detaching at compile time.
   usb_claim_interface error -6
   Failed to open rtlsdr device #0

Then you will need to do this (commands below):

$ cd /etc/modprobe.d
$ sudo nano no-rtl.conf

     In the blank file you just created called 'no-rtl1.conf' put the following three lines and save the file:

blacklist dvb_usb_rtl28xxu
blacklist rtl2832
blacklist rtl2830

Rerun the test and all should be fine:

$ rtl_test -t

Now the SDR is set up.  Ready for dump1090 install:

$ cd /home/pi/
$ git clone git://github.com/MalcolmRobb/dump1090.git
$ cd dump1090
$ make

$ ./dump1090 --interactive --net

The command above means run dump1090.  
  •      --interactive means show the results on the RasPI screen. 
  •      --net means we plan on sending the tracking data to FlightAware.com
  •      if you want to see other dump1090 options use the --help switch
After running dump1090 look for a spinning text type cursor in the upper right corner.  The spinning cursor means all is running fine.

At this point the RasPI is tracking planes.  Double check that by looking at your on personal tracking map on the RasPI.  From a browser local to your RasPIs network goto:

    http://<local_IP_address_of_the_dump1090_RasPI>:8080
for example
   http://192.168.1.6:8080
-----
To log your finding with FlightAware.com just head to their piaware install site.   FlightAware.com has done a great job making the piaware install simple so just follow their instructions.  

After piaware gets installed and running you will get a welcome email from FlightAware.com saying your RasPI is logging and all is good.  If you suspect an issue take a look at the file /tmp/piaware.out for clues or ask questions on the FlightAware.com discussion forum.
-----
Seems like a lot of work, but just copy/paste the commands and you should be fine.  If you get into trouble satsignal and FlightAware.com are the sites to visit for help.

Happy logging!!!