Tutorial: Build Your Own Cheap Wireless AIS Receiver

Sailing vessels that are 65 feet or longer are required to announce their position, course, speed, destination, and vessel dimensions. This announcement is made over VHF and known as the "Automatic Identification System” (AIS). Not only large vessels but more and more smaller pleasure craft are also carrying AIS transponders. It is a nice security feature.

If you are a sailor or mariner, happen to have your own boat or just enjoy hacking things, having an AIS receiver can be very handy (and fun!). AIS devices come with different functionality and price points. In its basic terms, there are receivers and transponders (or transceivers). For both categories, some of these devices also support wireless communications. This is normal as more and more devices become wireless and it is not different on a boat. Unfortunately adding wireless to an AIS receiver bumps up its price fairly significantly (well, anything on a boat is a bump up in price anyway, you know what BOAT stands for: Bring Out Another Thousand!). Purely technically speaking, wifi is almost a commodity these days and it is really not justified to pay several hundreds dollar extra for a wifi version of a device which already costs quite a bit. This guide is going to explain how to use a $35 Raspberry Pi to add wireless functionality to AIS receivers that don't support wireless.

Safety Warning: It probably is not a good idea to rely on to this method solely if you are going for cruising. Use the information here at your own risk.

I learned this the hard way, when I decided to buy a 'Wireless AIS' receiver (Digital Yachts iAIS). I paid north of $500 on Amazon.com. When I received it, it didn't take long for me to notice that the wireless option was fairly problematic. Not all devices could connect properly. And when they connected, IP addressing sheme would cause issues if you had an onboard wireless hub etc. It did work allright for receiving and decoding AIS messages and it was fun to play with but the added wireless capability was not worth the relatively steep price.

For what I needed, $100 would be more than enough to have a wireless AIS solution. dAISy HAT, a module that plugins onto the GPIO pins of Raspberry Pi as a shield sells for only $65. dAISy would have been perfect and on top of everything it is open source! This is the newer version of dAISy, there is also an older version that is single channel and connects via USB.

Digital Yacht iAIS

When I was trying to solve the wireless problems with my iAIS, I came across instructions on how to upgrade its firmware to a more recent version. In the process of upgrading, I managed (or more it managed itself...) to completely stop the wireless operation of the box. I have been in technology business for about two decades and played extensively with all sort of devices, programs and embeddded systems. So I would like to believe it was not me but who knows... Bottom line was, that wireless option which costed several hundred dollars went down the drain. I was left with a semi-functioning AIS unit, which still decoded AIS messages and made them available over a USB connection but the wifi never came back. I could use it if I connected my laptop using the USB connection but that was it. Then I started thinking, if I could get this over USB, I could very well craft my own 'wireless AIS solution'!

Raspberry Pi3

Obviously, when you want to add some functionality to an existing device that normally costs $200, you don't want to put a $1,000 laptop next to it. But then there is this really great tiny computer known as Raspberry Pi3, which costs only $35 ($20 more with accessories) and it has 4 USB ports, an ethernet port and built-in wifi! I had plans for making an onboard computer based on Raspberry Pi (a.k.a. BoatPi) anyways, so this was a perfect starter. Anyway, let's get to action!

Following section assumes you are doing this on a Raspberry Pi3 running Raspbian, but it will work on any similar Unix/Linux based system.

First of all, plug your existing AIS receiver to the Raspberry Pi. In my instance this is a USB connection from Digital Yachts iAIS. Once you plug it in, an device will be created under /dev for that serial connection. In my case, this is /dev/ttyUSB0

[email protected]:~# ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Sep 15 01:17 /dev/ttyUSB0
[email protected]:~#

If you want, you can simply dump the contents of this interface:

[email protected]:~# cat /dev/ttyUSB0
!AIVDM,1,1,,B,[email protected]?tTfEUtE7s9rRP000,0*74
[email protected]:~#

These are the VDM messages that are actually transmitted from ships. Of course they need a bit of deoding ;-)

Now we have these locally, it is really only a matter of couple of commands to make this available over the network, including wifi! Linux comes with a set of nice tools that can really do a lot. So in this instance, all we need to do is to take this data and make it available over the network. There are several ways to do it, but the easiest is to use a tool known as netcat, also known as the TCP/IP swiss army! So, let's use netcat to start listening on a local port, and send the data that we get from the serial connection:

[email protected]:~# nc -l 2000 < /dev/ttyUSB0

You will notice that, nothing seemingly happens. Well actually a lot of things happen in the background. This command actually started listening on TCP port 2000 and once a connection to that port happens, it will send everything it gets from the serial connection, essentially relaying AIS messages to network connections!

Let's test this from a different device on the network. In order to do this, we need to know the IP address of Raspberry Pi on the local network. In this tutorial, we are assuming it is connected over its wireless interface, but it could very well be ethernet too. When we talk about TCP/IP, interfaces really don't matter that much. In this instance, Raspberry Pi has the IP address of that is obtained over WiFi. We will talk about configuring WiFi on Raspberry Pi in a bit. So let's access TCP port 2000 from a device:

Ilkers-MBP:~ itemir$ telnet 2000
Connected to
Escape character is '^]'.

!AIVDM,1,1,,A,[email protected]<:pGJ@:P000,0*77
!AIVDM,1,1,,B,[email protected]?j;pEWD3u6ELB0DOb,0*75
!AIVDM,1,1,,A,403Oti1v2GTc;[email protected]?02H6k,0*26
^CConnection closed by foreign host.
Ilkers-MBP:~ itemir$

It worked, we successfully relayed AIS messages to another host on the network. They still look like gibberish to a human but they will make much more sense for a machine ;-) You should notice something here though. When you stop the flow of this data with Ctrl+C (meaning you terminate the network connection), go back to the nc command you invoked on Raspberry Pi, you will see it stopped as well. This is expected. We will come back to it but for now, repeat the exact same nc command and make sure it goes into waiting mode.

Now let's test this with an actual program that can decode AIS messages. Here, we have many options, free and non-free. I will list three options:

  • OpenCPN A very sophisticated open source and free navigation software. It can consume AIS messages over the network. OpenCPN is available for Windows, OS X and Linux.
  • iNavX A mobile app for iPhone and iPads. iNavX can consume AIS messages over the network. It is sold for a fee.
  • AISplay An open source mini project I developed for visualizing AIS objects on Google Maps. It is designed to receive AIS messages over the network.
You can try any of these or an existing solution you have. Below, I am putting two screenshots from iNavX running on an iPhone, that is configured to connect to the wireless connection we created above.

There is only one outstanding issue. Our network connection stops listening on port 2000 whenever the connection terminates. We want it to be available all the time. For this, we need to write a little script:

[email protected]:~# mkdir /opt/ais
[email protected]:~# nano /opt/ais/aisd

This will open an editor, copy paste the following code in the editor and save by pressing Ctrl+X:

while true; do
  nc -l 2000 < /dev/ttyUSB0 > /dev/null

This will ensure a new session is started as soon as one terminates. You need to make sure this file is executable. Then simply run it in the background.

[email protected]:~# chmod +x /opt/ais/aisd
[email protected]:~# /opt/ais/aisd &

That's it, you now made your AIS receiver wireless! You may want to add it to your startup scripts so it gets started automatically at every boot. In order to do so, edit /etc/rc.local and add the following line right at the bottom of that file, just above exit command (this is important).

/opt/ais/aisd &