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.



12 thoughts on “AIS on the CPN Pi-lot project”

  1. Hallo there, all well?

    I have finally bumped into your pages after having tried alsmost anything else to get gnuradio gr-ais running on a cubietruck for Open CPN. I had rtl-sdr already up and going on Lubuntu and now aisdecoder is succesfully build and running.

    Could you please inform me if the above should really deliver NMEA on the host port 10110?
    I do not live next to the river/sea but on my windows setup i can normally receive at least some AIS messages. AISdecoder is only showing Level on ch 0: 50 % and no messageg at all at Open CPN.

    Thanks in advance voor your reaction, if this should work I keep on it otherwise I still will have to dive into cross-compiing.


    Martin J. Brockhus near Rotterdam NL

  2. Hallo, Thanks for coming back to me that fast.

    On Lubuntu it seems I cannot get the OpenCPN ppa going so the plugin is extracted and positioned together whit the two standard ones and it is accessible.

    The plugin however yields “Execution failed: “aisdecoder -h -p 10110 -a file -c mono -d -f /dev/stdin”.

    I guess I still need to start rtl-fm first but to what file should the output thereof be directed in order for the plugin looking to /dev/stdin? that would not be /tmp/aisdata as far as I dare to guess.

    Appreciating you asssistance

    Kind Regards,
    Martin J. Brockhus

      1. Hmmm?
        Can you tell me if you still start rtl-fm and aisdecoder in seperate terminals before launching opencpn? Whit what command lines?
        I have OpenCPN 4.0 with hardware acceleration on Cubietruck up and running now.
        Thanks in advance
        Martin J.

  3. Hello,

    I managed to reproduce this on my Raspberry .. well I don’t have any AIS senders nearby.

    However – the aisdecoder pipes (with -d) the nmea data to stderr. I wonder if there is a way to pipe those to a tcp or udp port, so OpenCPN can reveive those without a plugin?

    best regards

  4. “sudo apt-get install libasound-dev libpulse-de”
    Shouldn’t that be “sudo apt-get install libasound-dev libpulse-dev” ?

  5. I bought the amazing spiderman for PS3, and found it to be pretty lacking for a console title. The bosses were fun but too easy, free roaming was great, but the missions were very tedious. I think I`d rather pick this up for 5 bucks over the PS3 one for 60.

Comments are closed.