AIS on the CPN Pi-lot project

First of all, what is AIS?

Automatic Identification System, or AIS for short, is a system for automatically displaying location, tracks and information about ships (and other large vessels) It works automatically, transmitting the data over standard VHF frequencies. The information provided is then generally rendered by a chartplotter or other software.

There are some very interesting websites on the web that display AIS information in near realtime. is one of my favorites.

I wanted to add the capability to receive real-time AIS information and display it on the CPN Pi-lot project I’ve been building. Fortunately, once again, the hard work and research has already been performed by other people across the world. They have discovered that USB software defined radio dongles (SDR-RTL) have the capability to extract AIS information using cheap and readily-available hardware and software.

I recently purchased a usb dongle from Amazon that was listed to work with SDR-RTL, and wanted to see if I could get any usable data out of it.

AIS on the Raspberry Pi

I followed the instructions on a few different blogs and forums. The following is the steps I performed to get AIS around all the small gotchas:

sudo apt-get install git-core
sudo apt-get install cmake
sudo apt-get install libusb-1.0-0-dev
git clone git://
cd rtl-sdr
mkdir build
cd build
sudo make install
sudo ldconfig
cd ~
sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/
sudo reboot
rtl_test -t

At this point, the rtl_test program displayed the following error:

Kernel driver is active, or device is claimed by second instance of librtlsdr.
In the first case, please either detach or blacklist the kernel module
(dvb_usb_rtl28xxu), or enable automatic detaching at compile time.
usb_claim_interface error -6
Failed to open rtlsdr device #0.

To resolve it, I needed to edit the /etc/modprobe.d/raspi-blacklist.conf file, by adding the following lines:

blacklist dvb_usb_rtl28xxu
blacklist rtl2832
blacklist rtl2830

After a reboot, the rtl_test program confirmed that I was receiving samples from the USB dongle.

The next step was to install an AIS receiver:

sudo  apt-get  install  libasound-dev  libpulse-dev
tar  zxvf  aisdecoder.tar.gz
cd  aisdecoder
mkdir  build
cd  build
cmake  ../ -DCMAKE_BUILD_TYPE=Release

Then, open up two terminal windows. In the first terminal, type:

mkfifo /tmp/aisdata
rtl_fm -f 161975000 -g 40 -p 95 -s 48k -r 48k /tmp/aisdata

and in the second termnial, type:

./aisdecoder -h -p 10110 -a file -c mono -d -l -f /tmp/aisdata

At this point, it appears I’m getting data flowing through, as I see the following:

Level on ch 0: 50 %
Level on ch 0: 50 %
Level on ch 0: 50 %

Since I am currently at home, and not within range of any ships that should be broadcasting AIS, I believe this is a success. However, I will need to bring all this gear down to the boat, test it there (where I know there are AIS signals) to confirm.