Apr 222014

A friend of mine recently said he’d like to have something to ‘plug in’ to dump1090 running locally (see my previous post for my setup on this) to alert to emergencies in the air that are nearby. As I was getting in to it I realised what a neat idea it actually was. There are many different “interesting” squawk codes, and unless you’re glued to your Virtual Radar all day long, you’re not going to notice. Not to mention if a plane is going to fall out the sky it’d be handy to know to take cover …

So. SquawkWatch was born!

It’s a lightweight PHP script (uses approximately 1% of CPU time allocated to my ‘playground’ virtual server, and it has next to no CPU allocated to it) and sifts through all the messages coming in from dump1090, looking for a set of squawk codes defined within. When it finds one, it sits on it and waits for a complete data picture, and then emails the alert to you.


  • PHP 5.3
  • MySQL
  • dump1090 (reachable by the PHP host)

Download the source code here.

Download the G-INFO database here (late March 2014).

Example (non-debug mode) output here (stdout).

Any questions pop them in the comments and I’ll help where I can.


  11 Responses to “Monitoring ADS-B with dump1090 and Generating an Alert on a Squawk (7700, etc) in PHP”

  1. Updated to Squawkwatch 5 (heartbeat)

  2. Updated to Squawkwatch 6 (pidfile locking, companion script to empty processed array)

  3. Can you add the possibility to generate an alert if a plane is below a certain altitude? Thanks

    • This is certainly do-able, from an abstract point of view. I can’t see it causing much of an additional overhead on the script. Watch this space! 🙂

  4. Where did you manage to get a copy of the G-INFO database? It was very expensive via the CAA when I last looked for a copy (should be free IMO but…)

    • Dan,

      I found it online – I can’t remember where now. I think it was really obvious, like a google for ‘CAA G-INFO download’ or something. It seemed official enough and there was no license with it so assumed it was fair game to use for a fun open source project!

  5. hi Lee,

    with the link to flightradar24 giving almost the same info instantly and the complexity (and lack of instructions) for setting up mysql db with this ginfo db (that also needs to be updated to keep current)
    I adapted your script and removed all the parts were db access is required, I tested it with squawk 1000 (somehow a common code) and it seems to work. Setting up sendmail (using ssmtp really) was in fact the largest task. Why would the frequent restart be required, is it memory usage? If little events happen (I only alert on codes 7500,7600, 7700) can I skip this? Many thanks for this script, it’s rudimentary but seems to do the job!



    • Thanks for your comments! dump1090 was said by the original author to need restarts; I can’t comment on why I just complied.

      Squawkwatch will run for months without being touched 🙂

  6. I get an error 403 when trying to download the source code. Any other way to get the source?

    • Wow, sorry for the slow reply. For some reason your comment never appeared in the moderation queue. Thanks for pointing out my configuration error! This has been corrected and you should now be able to see the source code again.


  7. G’Day Lee, I’ve succesfully got this running with my own MySQL database and it emails me good stuff when a Squawk is detected. If I wanted to change this from Squawk to Callsign, how would I do that? I’ve had a crack at changing some of the line references but it didn’t work. Any help would be much appreciated.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



This site uses Akismet to reduce spam. Learn how your comment data is processed.