Close

AIS and OpenCPN

A project log for (me) Learning to speak SDR

I recently purchased an RTL-SDR from NOOELEC and started fiddling around with it. This is my documentation of what works and what doesn't.

Timo BirnscheinTimo Birnschein 05/11/2021 at 01:190 Comments

I live on a boat. The Automated Identification System (AIS) is great to have on a boat. If you don't have a transceiver to send AIS packages, you should at least be able to receive and display AIS targets on your chart plotter.

An RTL-SDR is the cheapest way I am aware of to accomplish this. All we need is the RTL-SDR itself and a VHF antenna that is able to pick up the signals around 162 Mhz.

To start with, I fiddled around with the antenna that came with my kit. It's not the right antenna for this frequency and I wasn't able to receive anything more than 0.5 miles away. That's useless (this antenna might get another chance though as I'll explain bit bit below. Spoiler alert: I think having the signal gain set automatically doesn't work well). But I was more hopeful with my boat's 8' VHF antenna. Turns out, I was right, but it needed at least some tuning. The results are great!

Here are the steps to make the above possible:

Download OpenCPN from their website. This is an open source chart plotter software that's excellent. Many boaters around the globe are using this software package as it also includes open and up to date charts! My own setup can be found here.

Download the RTL-AIS binary package from this website.

Install OpenCPN and unzip rtl-ais to a folder you want to use for it. Open the folder and navigate to the "ais.bat" file. Right click on it and EDIT the file.

Note that, in the last line of the file, the actual application is started. For my AIS reception to work, I needed to add a parameter "-g30" to the list of arguments to set the gain for the receiver. By default, it is set to AUTO which did not result in good results (see complaint about the kit antenna at the beginnig of this post). In fact, it wasn't any better than the antenna that came with the RTL-SDR kit. Makes me wonder if I can get better results with that antenna now as well...

I determined the gain by opening SDRsharp, clicking on the gear icon in the top left to get into the settings and increase the gain until I saw massive amounts of harmonics show up in the spectrum. I assume, the default setting of rtl-ais increased the gain too far which messed up the reception.

With the gain set to 29.7 dB:

With the gain set to >30dB:

At >30dB, the signal gets somewhat distorted and worst from there. If you know why, please let me know in the comments! This is really puzzling to me. It went so far that I was able to hear other audio channels on the AIS frequencies. That doesn't work for digital data transmissions.

Close SDRsharp, add the gain to the “ais.bat” file and run "ais.bat".

You will see a command line box show up that selects the sdr dongle, sets some parameters and then starts receiving AIS NMEA strings.  

Next, I went into OpenCPN, clicked the gear icon in the top left to get into the settings and clicked on Connections:

There, I added a new UDP connection to listen on localhost (127.0.0.1) on port 10110. This is the port RTL-AIS is transmitting to as the application mentions when it is started. That's it!

You can check your work by clicking on Apply and then the Show NMEA Debug Window checkbox further up and see that the AIS messages are coming in.

Please note, the debug window MUST be closed by unchecking the checkbox again. You CANNOT click the X at the top right.

If you receive AIS messages here, they will slowly fill your OpenCPN chart plotter window!

Please also note that AIS is slow, especially for targets that are not moving! So it might take a couple minutes to receive them all. In addition, packages are being received and checked if the data was received correctly. Often, that is not the case! You will get lots of damaged packages that are consequently discarded. Look at this screenshot somewhere in the middle. It tells you how many packages where received, how many were malformed and how many had CRC errors. Ignore that. It's just good to know whether you have way too many reception errors. The number of good packages should be higher than the number of bad ones. If that's not the case, play with your gain settings. I think, based on my 5 minutes of testing, anything between 20 to 40 could make sense.

(wrong screenshot needs to be replaced)

To see the complete target list, right click (almost) anywhere on the chart and click on "AIS target list..."

Discussions