Free Canadian Shipping on orders over $150 with discount code "FREESHIP"!

Tracking and logging flights with ADS-B, Flight Aware and Raspberry Pi

December 12, 2019

Tracking and logging flights with ADS-B, Flight Aware and Raspberry Pi

I am a bit of an aviation geek.  While I have no intentions of learning to fly anytime soon, I have always liked tracking planes and listening to AIr Traffic Control.

Back when I used to travel a lot for my old corporate job, I learned to love FlightAware.  They have become the go-to source on the Internet for independent flight information, as well as interesting aviation-related information.  

A few years back, FlightAware started selling USB ADS-B receivers for Raspberry Pi.  For now we are not selling FlightAware products, but if you are interested, let us know.  We have been using the Pro Stick Plus along with a 1090 MHz antenna, which is currently available from Amazon.  There is an awesome tutorial  on what you need in order to get setup.   Here is an example of the output from our unit.  We have our antenna mounted in our 2nd floor office next to a window.  If you can get your antenna higher, I am sure you would pickup more planes, but I'm pretty happy to get flights from as far as 90 nm (166 km).

Tracking and sending flight information to FlightAware is great, but we wanted to take it a step further by creating a database on our end.  

It turns out that the FlightAware software generates a JSON file with all sorts of great data on every flight.  Here is an example of the JSON output as formatted in our favourite JSON parser.  

With a bit of Python magic, it is super easy to decode JSON data and make a database.  In our case, we have a database that tracks basic plane information such as Flight Number, Altitude, Speed, Squawk, and Emergency Status.  We built a Python script that runs every 3 minutes, scrapes the JSON data, and adds to our table.  

We created two tables:  

1) all_aircraft has one entry per aircraft per hour.  If an aircraft has been seen in that hour and more data is read, it is skipped.  

2) "interesting" contains flights that are squawking emergencies or are reporting emergencies.  So far we have not seen a flight squawking an emergency, and we just noticed the new "emergency" parameter in the JSON data.  It will be interesting to see what we find with this table.

Here is an example of the all_aircraft table, sorted by descending speed.  ACA782 is trucking along at 576 mph on its way from LAX to YUL.

If you are interested in creating your own log of aircraft using PiAware, you can download our Python script here.  I'll warn you right now I am a bit of Python hack, but it works!

Once you have your script ready, add a crontab entry that automatically runs the script.  In the below example, we have the script run every 3 minutes and send any text output to a log file.

To edit your crontab, type "crontab -e"

And add the following line:

*/3 * * * * /home/pi/ >> /home/pi/python.log