Sunday, 27 September 2015

Read PiAware Flight Data with Python

I have been using Piaware for a couple of weeks and I like the idea of being able to read the signals from aircraft just using simple equipment.

I wanted to use this information to do interesting 'stuff', I'm imagining home built radars and led's which flash, but before I could do anything cool I needed to find a way of getting to this data using Python.

Its possible to read data directly from the dump1090 program using tcp sockets, but the data is a raw stream and it seemed like too much work (I'm all for simplicity)!

The Piaware install also comes with a web front end so you can see the data you are receiving [http://localhost:8080], you can also get to the json data [http://localhost:8080/data.json] which is feeding this web page and this looked like a much easier way of getting the data out.

I create a small Python 3 class called FlightData [link to github] which reads the data from the web page and parses it into an object.

You can install it by cloning the flightdata github repository and copying the file to your project (if there is sufficient interest I'll make it into an 'installable' module):
git clone
cp ./flightdata/ ./myprojectpath
You can test it by running the program file:
Below is a sample program which shows how to use it:
from flightdata import FlightData
from time import sleep

myflights = FlightData()
while True:
    #loop through each aircraft found
    for aircraft in myflights.aircraft:
        #read the aircraft data

   #refresh the flight data


  1. Hi Martin... thanks for's what I was looking for. I have updated the URL to the new PiAware V3 location for the json file (localhost/dump1090-fa/data/aircraft.json). It threw an error on the decode(). Said it couldn't be None. I changed the line to set it to utf8, which is the json default I think. Got past that and hung up on line 66 in where it tries to parse the array. Error is TypeError: String indicies must be integers. I will admit to zero python experience, so that's likely the problem! Any thoughts? thanks. John

    1. I suspect you are using the wrong file location (hence getting None back) I just had a quick look on my piaware machine and "http://localhost:8080/data.json" still takes you to a valid location. Do you know the file location has changed? I'll have a look at piaware v3 at somepoint mine is still 2.1-5

  2. It moved with V3. you can access mine Pi via a proxy on my main site, if you'd like to do so for testing. (the proxy uses "adsb" but Piaware is /dump1090-fa/data/aircraft. the 8080 port will still work on the Piaware, but it simply forwards to port 80 where lighttpd is running.

  3. Hi again. I inserted "print(json.dumps(json_data,sort_keys=
    True,indent=5))" just before the "for aircraft in json_data:" and it dumped the current json file OK. So we seem to be connecting.

    Come to think of it, when I ran this the very first time, I got a 404 error, which is what made me change the URL in the first place.


  4. Hi there,

    I am planing to create the same.. i am new in rasberry pi.. i would like to see, if there is anyway to track the vessels.. what is the range of your tracks and what equipment do i need to do all this.

    I have rasberry pi3, usb gps, usb antenna and also stratux software.. can you advise please