Skip to content

Instantly share code, notes, and snippets.

@dceejay
Last active February 9, 2017 12:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dceejay/3288996fefdc3aef04846496277b6444 to your computer and use it in GitHub Desktop.
Save dceejay/3288996fefdc3aef04846496277b6444 to your computer and use it in GitHub Desktop.
Plotting planes using dump1090 and worldmap.

This example uses an external program and 2 non-core nodes.

dump1090 - the awesome ADS-B program from @antirez - https://github.com/antirez/dump1090

worldmap node - http://flows.nodered.org/node/node-red-contrib-web-worldmap

daemon node - http://flows.nodered.org/node/node-red-node-daemon

The Daemon node runs dump1090 --net in the background. If you don't want to install this node then you can just run it in a separate window.

dump1090 --net

One of dump1090's hidden features is the ability to provide a json object of the planes it can see via http://localhost:8080/data.json. So we can poll this url to get a pre-decoded array of planes, then split this into individual planes, add the necessary parameters for the map, and finally forward to the map page's websocket.

[{"id":"c9c26db2.572ff","type":"worldmap","z":"5e316136.c9343","name":"","x":597,"y":260,"wires":[]},{"id":"ee8117db.660788","type":"http request","z":"5e316136.c9343","name":"","method":"GET","ret":"obj","url":"http://localhost:8080/data.json","tls":"","x":288,"y":199,"wires":[["1158850f.f2be6b"]]},{"id":"76c2b099.8578e","type":"inject","z":"5e316136.c9343","name":"","topic":"","payload":"","payloadType":"str","repeat":"3","crontab":"","once":true,"x":128,"y":199,"wires":[["ee8117db.660788"]]},{"id":"1158850f.f2be6b","type":"function","z":"5e316136.c9343","name":"Split array into individual planes","func":"var m = [];\nfor (var i in msg.payload) {\n m.push({payload:msg.payload[i]});\n}\nreturn [m];","outputs":1,"noerr":0,"x":528,"y":199,"wires":[["1b108949.a69537"]]},{"id":"1b108949.a69537","type":"change","z":"5e316136.c9343","name":"","rules":[{"t":"set","p":"payload.name","pt":"msg","to":"payload.hex","tot":"msg"},{"t":"set","p":"payload.bearing","pt":"msg","to":"payload.track","tot":"msg"},{"t":"set","p":"payload.icon","pt":"msg","to":"plane","tot":"str"},{"t":"set","p":"payload.layer","pt":"msg","to":"ADSB","tot":"str"},{"t":"delete","p":"payload.track","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":358,"y":259,"wires":[["c9c26db2.572ff"]]},{"id":"ecb8190.4425de8","type":"daemon","z":"5e316136.c9343","command":"dump1090","args":"--net","cr":false,"redo":true,"op":"string","name":"","x":168,"y":339,"wires":[[],[],[]]}]
@vielmetti
Copy link

Thanks! I have a slight mutation of this flow

https://gist.github.com/vielmetti/6329ea5a49dadd2f106980a20727d16e

which adapts it to work with http://github.com/mutability/dump1090 which is a fork of the original dump1090 that adds some features and that moves the data it supplies around from data.json to data/aircraft.json and also slightly changes the format of the JSON object returned.

Thanks again for the sample flow, this got me running quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment