Capturing raw AIS data using rtl_fm and decoding using aisdecoder v2
I captured 4 x raw AIS data files by running the following commands on my Mac laptop while crossing the Solent on a WightLink car ferry which departed Yarmouth late afternoon of Sunday, 19th April:
rtl_fm -f 161975000 -p 45 -s 48k > 2015-04-19-test-161975000-p45-s48k.raw
rtl_fm -f 161975000 -p 50 -s 48k > 2015-04-19-test-161975000-p50-s48k.raw
rtl_fm -f 162025000 -p 45 -s 48k > 2015-04-19-test-162025000-p45-s48k.raw
rtl_fm -f 162025000 -p 50 -s 48k > 2015-04-19-test-162025000-p50-s48k.raw
This resulted in the following raw data files:
- 2015-04-19-test-161975000-p45-s48k.raw
- 2015-04-19-test-161975000-p50-s48k.raw
- 2015-04-19-test-162025000-p45-s48k.raw
- 2015-04-19-test-162025000-p50-s48k.raw
- I chose the frequency (
-f
option) values based on the official AIS frequencies i.e. 161.975 MHz & 162.025 MHz. - I didn't have GQRX working on my new laptop, so I couldn't check the signal strengths and just recorded blind.
- I chose the value of the PPM error (
-p
option) based on running thertl_test
command and seeing what the value settled to after a couple of minutes.
I decoded the AIS NMEA sentences from the raw files captured above using aisdecoder
on the Ubuntu Virtual Box VM running on my Mac laptop. I ran the following commands:
aisdecoder -h 127.0.0.1 -p 1234 -a file -c mono -d -f 2015-04-19-test-161975000-p45-s48k.raw 2> 2015-04-19-test-161975000-p45-s48k.nmea
aisdecoder -h 127.0.0.1 -p 1234 -a file -c mono -d -f 2015-04-19-test-161975000-p50-s48k.raw 2> 2015-04-19-test-161975000-p50-s48k.nmea
aisdecoder -h 127.0.0.1 -p 1234 -a file -c mono -d -f 2015-04-19-test-162025000-p45-s48k.raw 2> 2015-04-19-test-162025000-p45-s48k.nmea
aisdecoder -h 127.0.0.1 -p 1234 -a file -c mono -d -f 2015-04-19-test-162025000-p50-s48k.raw 2> 2015-04-19-test-162025000-p50-s48k.nmea
This resulted in decoded NMEA sentences in the following text files:
- 2015-04-19-test-161975000-p45-s48k.nmea
- 2015-04-19-test-161975000-p50-s48k.nmea
- 2015-04-19-test-162025000-p45-s48k.nmea
- 2015-04-19-test-162025000-p50-s48k.nmea
A total of 80 AIS sentences were decoded despite the west end of the Solent not having much shipping visible at the time.
I tried to use AGG Software's Online AIS Decoder to decode the NMEA sentences, but I kept getting an error. So I then found this Online AIS Message Decoder website which seemed to work ok. However, I also came across the gpsdecode Ubuntu package and I used this to convert my .nmea
files into translated .json
:
- 2015-04-19-test-161975000-p45-s48k.json
- 2015-04-19-test-161975000-p50-s48k.json
- 2015-04-19-test-162025000-p45-s48k.json
- 2015-04-19-test-162025000-p50-s48k.json
I used the following Ruby script to convert the JSON for type-1 NMEA sentences into a single CSV file:
require 'json'
require 'csv'
type_one_sentences = Dir['*.json'].map do |filename|
lines = File.readlines(filename)
sentences = lines.map { |line| JSON.parse(line) }
sentences.select { |s| s['type'] == 1 }
end.flatten
csv = CSV.generate do |csv|
csv << type_one_sentences.first.keys
type_one_sentences.each { |s| csv << s.values }
end
puts csv
I then imported this CSV file into Google Spreadsheets. I then manually split it into a file for each of the two car ferries mentioned (Wight Sky & Wight Sun):
- https://docs.google.com/spreadsheets/d/16ZbSOxl5H5Gq1dI11Woz4HnwGjpR4ulVyvHhzT5CMfw/edit?usp=sharing
- https://docs.google.com/spreadsheets/d/1d35pYJOUJPBcvz3LowKniNJc27F_jvNsVozC1qDvcsM/edit?usp=sharing
Finally I imported each of these two spreadsheets into a layer on a Google Map: