VN's Blog

Photograph Ships with Software Defined Radio

OVATION OF THE SEAS, March 12 2020
An RTL-SDR radio dongle can pick up all kinds of interesting radio signals using cheap hardware that connects to a laptop or Raspberry Pi over USB. The dongle and associated software allow accesssing these signals programatically using Python or your language of choice.

The RTL-SDR website lists several signal types including

Ships and smaller boats usually have an AIS transponder. The Automatic Identification Sydtem (AIS) broadcasts a vessel's location, name, size, and speed every few minutes. The main use of this is collission avoidance, but is also useful for traffic management and like with this project, tracking ships.

These transponders can be turned off, but ships within Sydney harbour usually leave them on for collission avoidance purposes - even military vessesls usually run these when in the harbour.

Back in 2017 I moved to an apartment with a view of Sydney Harbour, and I decided to build out a project to finally use a Raspberry Pi Zero I had lying around. The idea was to photograph ships, using a time-lapse, as they moved under the harbour bridge.

I used an RTL2832 dongle for this project, and there are several alternatives available as listed on the RTL-SDR website.

Along with the dongle and Raspberry Pi, I used a Raspberry Pi camera and a cheap phone maginifier lens to enhance the image quality, my setup being some distance from the bridge. I ran this out of my apartment between 2018 and 2022, at which point I moved and turned this off.

HMAS Canberra, one of Australia's two helicopter carriers moves under the bridge under some dramatic weather, March 29, 2022

This project uses the RTL dongle to listen to these signals and track ships as they move into and out of Sydney harbour. The area under the harbour bridge and to Circular Quay (the geofenced area below) is the designated geofence - with a bit of trial and error, I was able to figure out the precise moment to trigger a timelapse capture using the Raspberry Pi python SDK.

The geofenced area where ships are detected

Not all ships correctly advertise their size over AIS - often the only reliable pieces of information are the ship MMSI (Maritime Mobile Service Identity), a unique code assigned to each ship in the world and its GPS coordinates. Since the RPI camera isn't hugely capable, there is little use in trying to run a capture of vessels of a size under about 40 metres - they just show up as specks in the video. I filter out ships smaller than 80 metres in length (as self-reported by their AIS messages) to reduce the number of false captures although this often fails because not all ships report accurate sizes.

MV Sycamore, navy aviation training vessel, August 7, 2022

The capture software is written in Python and uses AWS for backend processing work. The code is all present in this repository, Sydney Ships

The project uses the excellent RTL-AIS project to process incoming AIS messages and libais to access them in Python.

The Sunshine Princess crosses the Sydney Harbour, 26 November 2017

The data reported by the ships themselves is not always accurate, with some jumps in position that needed to be filtered out. As you might imagine, Sydney harbour is a busy area with lots of traffic

Back to homepage