Track and Photograph Ships with Software Defined Radio

Note: You can view captures by date in the Shippix ship capture viewer.

With a Software Defined Radio you can pick up all kinds of interesting signals with cheap commercial hardware. A RTL dongle is easily obtained online and can be connected to a Raspberry Pi to create a platform for experiments. I used an RTL2832 dongle for this project, although there are several options available as listed on the RTL-SDR website.

Ships at sea broadcast AIS (Automatic Identification System) messages every few minutes when underway. They also broadcast messages when at port at a slower frequency. The AIS system aids navigation - other vessels can use this information to plot their courses, avoiding collisions.

This project uses the RTL dongle to listen to these signals and track ships as they move into and out of the Sydney harbour.

In particular I wanted to count the traffic under the harbour bridge and to Circular Quay (the geofenced area below). In addition, having access to a location with line of sight to the area in question, I wanted to photograph the ships exactly as they passed under the harbour bridge and in front of the opera house.

The geofenced area where ships are detected

Using the GPS coordinates from the AIS messages broadcast by ships every couple of minutes when they are underway, it is easy to compute if the ship is inside the geofence or not, and record the time a vessel enters the geofence. And entering the geofenced area can be used as a trigger to start a capture.

There were several challenges getting this up and running: I used a Raspberry Pi Zero W as the basis of the platform, and this was simply not powerful enough to run the project reliably. In addition the tiny Pi Zero takes a very long time to compile the libraries needed - doing anything in the SDR world requires a lot of compiling c++ libraries.

The little Pi's CPU runs absolutely flat out trying to process the radio - after all it is Software defined - taking up 100% of all cores and occasionally crashing the driver of the RTL dongle.

The Raspberry Pi camera, though cheap, isn't the best for taking pretty pictures - particularly when you're only interested in a small portion of the image being captured. The sensor outputs grainy, blurry images.

After putting a restart script in place to recover from crashes,I ran the project for a few weeks and got some good captures of ships transiting the Sydney Opera House.

The Sunshine Princess crosses the Sydney Harbour, 26 November 2017

The data reported by the ships themselves was not always accurate, with some jumps in position that needed to be filtered out. The Sydney harbour also has massive traffic - and most of the vessels are too small to photograph with the Raspberry Pi camera, so ships big enough to photograph need to be filtered out.

In theory the AIS messages themselves carry information such as the ship's dimensions, draught, name, and even destination port. In practice, this information is self-reported with no real standards, and the information (other than the MMSI identifier and the GPS co-ordinates) is often wildly inaccurate. I attempt to filter out ships smaller than 80 metres in length to reduce the number of false captures although this often fails because not all ships report accurate sizes.

NS Asia (Crude oil tanker) on 11 December 2017

Overall the results from relatively cheap hardware were quite impressive. The RTL hardware combined with a raspberry pi can enable a massive number of possibilities, allowing readings from everything ranging from weather balloons and aircraft to smart electricity meters.

The source can be found in this Github repository

And this is the repository for the capture viewer.