OpenCPN on the Raspberry Pi 2 with AIS

This past weekend I gave a presentation to a group of local sailors and boaters touting the benefits of running OpenCPN on a System-on-a-chip board such as the Raspberry Pi.

In preparation for the talk, I rebuilt OpenCPN on the newest generation Raspberry Pi 2, running the most current source code available on git at the time (4.1.412). I didn’t have the time to do any performance tuning of the system, and ran it out of the box all weekend long. OpenGL was not running appropriately, so performance was less than previous installations, but it did run out of the box, following the Raspberry Pi installation steps, with the additional step of compiling OpenCPN from source to get the most recent version.

However, I did add a new feature to the installation, and one that I am extraordinarily happy with — the ability to receive AIS data on OpenCPN running on a Raspberry Pi 2!

First AIS Contact

The first AIS contact!

In order to read AIS messages, I purchased a demo board of a product called dAISy designed by Adrian Studer. I’ve had the board in my hands for a few months, but as always work and life gets in the way of projects such as this. This past weekend I sailed my boat the 35nm or so from Tacoma to Poulsbo and had a few hours to play around with the chartplotter AND dAISy in an environment where the messages could be received. In short, it worked exceptionally well, and you can see the very first AIS contact that was picked up by the system just as we exited the north end of Colvos Passage in the photo above.

dAISy is a very well designed board that is easy to use. Just connect an antennae to the BNC connector, and a USB cable to the mini-USB port. In the current Raspbian image, all the required kernel support is set up, so simply plugging in the board is enough.

To test that it is working, perform the following test:

sudo apt-get install screen
screen /dev/ttyACM0

To exit screen, type CTRL-A, followed by K. At this point you should have a terminal window set up, and if you are within range of AIS targets you should see a list of AIVDM NMEA messages, that look something like this:

!AIVDM,1,1,,A,85Mwp`1Kf3aCnsNvBWLi=wQuNhA5t43N`5nCuI=p<IBfVqnMgPGs,0*47 !AIVDM,2,1,6,A,8>qc9wiKf>d=Cq5r0mdew:?DLq>1LmhHrsqmBCKnJ50,0*30
!AIVDM,2,1,1,A,55?MbV02;H;s<HtKR20EHE:0@T4@Dn2222222216L961O5Gf0NSQEp6ClRp8,0*1C

If you are not within range of AIS targets, you can still confirm that dAISy is responding by accessing it’s menu. Simply press [esc] and the menu will display such as the screencapture from Windows shows below:

AIS

If you turn on debug messages, and you are out of range (or have a very low signal) then you will see a series of messages like the following:
sync A RSSI=-085dBm
error: invalid stuff bit
sync A RSSI=-073dBm
error: CRC error
sync A RSSI=-086dBm
error: invalid stuff bit
sync B RSSI=-071dBm
error: CRC error
sync B RSSI=-087dBm
error: CRC error
sync B RSSI=-086dBm
error: invalid stuff bit

Then the last step is to render the targets in OpenCPN. It’s a fairly simple process of creating a new data connection. Go to Options -> Connections | Data Connections, and Add Connection. Select a Serial message, and set the DataPort to the dAISy USB message port (generally /dev/ttyACM0). Set the Baudrate to 9600, and uncheck Control checksum. Apply and return to OpenCPN.

If you think you have done everything correctly, but you are still not seeing AIS contacts or messages, and especially if ‘screen’ is showing messages, make sure that your user is added to the ‘dialout’ group. To add yourself to the group:
sudo usermod -a -G dialout $USER

Otherwise, enjoy the benefits of knowing where other vessels are, where they are heading, and who they are!

20150426_112418

20150426_112546

Advertisements

32 Responses to OpenCPN on the Raspberry Pi 2 with AIS

  1. Adrian says:

    Thanks for the plug 🙂

  2. Pingback: The Big Bash 2015 | m/v C:[ESC]

  3. Paul says:

    Hi,
    Have you tried to get this to work with a RTL-SDR dongle?
    If so, i’d be very interested as to how you managed it.

    Paul

  4. Bob Larkin says:

    Thanks much for the info. This has great appeal for saving power. Do you know the power consumption with the R Pi2? Also, what display are you using? Bob

    • mattkabrown says:

      A 5v 2.5A power adapter seems to be quite stable.

      I’ve been using a 32″ LCDTV mounted above the dash, but lately I’ve been playing with a Tontec 7″ 12v HDMI monitor that I’ve been very pleased with.

  5. Bob Larkin says:

    (2.5 x 5) Watts, or less, is a whole bunch better than the Lenovo T60p laptop that I have run OpenCPN on for years. It works well, but with a 12V adapter draws (3 x 13) Watts, plus or minus depending on the mood. The 3A is measured and it varies 2.5 to 3 except startup loading from the hard drive where it is more like 4 A.

    In addition to the power you list, I assume you need to add the power for the monitor. I looked up the Tontec and it referred to a power adapter with “Power Supply(5~12V 2A)” which I find ambiguous. Adding on 12V at 2A would put me back with the laptop power, but that may not be what it means.

    I have a sailboat, and 2 x 20W solar panels needs to run everything. On cloudy days, I work my 27 size gel cell battery down when using the laptop.

    Again, thanks for sharing your project.

    • mattkabrown says:

      There are many things you can do to reduce power consumption. If you are careful with your USB peripherals, you can be way below 2.5A@12v. Without anything plugged in, 700mA is normal, without a display.

      I haven’t measured the Tontec display with any meter, but it is fairly greedy with power for its size. Personally I’m ok with it, as I have a plethora of electricity as being a trawler I’ll be running the chartplotter 95% of the time with an alternator keeping my batteries topped up.

  6. Bob Larkin says:

    In reality, nobody is looking at the display, most of the time. In tight places, it is useful to have it on and running. In open water, a bit of cleverness with a switch and a timer would allow the display to be readily available, but not running most of the time. In the case of something like the Tontec, that would seem to be easy to do as it has separate power. This is sort of what the laptop tries to do with its power management.

    And yes, the USB power loads should be small. I have a GPS and an AIS receiver and a few hundred mA takes care of those. Memory sticks and the like do not draw much, most of the time. So, the parts that need to run all the time might be the 700 mA plus the few hundred more for a total of 5 Watts or so.

    This could be a neat project!

  7. Swokey says:

    Hi,

    I have also a raspbian pi2 with opencpn running on ubuntu 15.04. Just receveid the dAISY. When
    I plug it in I don’t see it in lsusb.

    Did you install anythinh else to get the dAISy working?

    Kind regards,
    René

  8. Curt says:

    Great info – I am working on getting the RPi2 device setup but having a few problems. Attempting to modify the config.txt and I get denied permission to make changes…any ideas?

    • mattkabrown says:

      Did you type sudo first? Or if you are using a GUI editor, did you launch it with administrative privileges, such as with gksu?

      • Curt says:

        I attempted to edit using the leaf text editor from the GUI and the VI editor from the command prompt, both attempts met with failure. Still on the learning curve with this OS. How do I launch the GUI with admin privileges? Can you point me to something on line that can assist?

    • tyty says:

      I hope you got this by now, but use “sudo nano /boot/config.txt”

  9. Curt says:

    Thanks for the info. I have managed to get OpenCPN up and running with charts and all. I cannot get the GPS Puck BSU 353 to run. Any suggestions?

    • mattkabrown says:

      GPS puck for me has really been just plug and play… basically lsusb should see it, and if it doesn’t it’s something more fundamental — most likely permissions

      • Curt says:

        Hi Matt – I got the GPS puck working a while ago. I know have a bench tested PRI2 running OPENCpn, and have the ability to pull down charts as they need updated. I also have configured the Bullet HP WiFi solution and my RPI2 works great with it. I am now ready to install the entire system on board my Tayana 37. But wait…there’s more. I just received my Daisy AIS module and want to configure it. I read your info, great help, thanks. Question, do you run this off your installed VHF-FM antenna via a splitter, or does the Daisy require it’s own antenna? My plan was to install the splitter and run coaxial to the Daisy. Other than what you printed on your website, is there any other info that might be handy to have prior to installing the Daisy into my RPI2/OPENCpn?
        Again – thanks for the great information.
        Regards
        Curt

      • mattkabrown says:

        I started out by trying different rtl-sdr dongles, and had better success reading ACARS messages from commercial aircraft overhead than I did AIS messages from boats on the water.

        But once I switched to dAISy, everything kinda fell into place which is why I suggest it. It’s truly plug and play.

        I currently use a second antennae, but there should be no big problems using a splitter. I would assume some signal loss or degradation, but I doubt it’d be anything substantial.

        I have seen messages from over 20 miles away on my setup.

      • Curt says:

        Thanks Matt. Once I install it on my boat I will let you know how how it works.
        Regards
        Curt

  10. Curt says:

    Hi Matt – Do you connect your RPI2/dAISy to an 12V/120v invertor while u/w to get the required power to operate it?

    • Curt says:

      Matt – concerning power issue. Did you set up your RPI2 and monitor to run via a 12v converter? If so can you share the parts you used? Thanks
      Curt

  11. David says:

    I recommend running all NMEA input through http://www.stripydog.com/kplex/ (runs well on RPi) which will also forward this data to a network port allowing iPad and other nav apps access NMEA data.

    • William Bickley says:

      Hi, David:

      I was thinking about running a Pi 3 headless and multiplexing AIS and GPS data to an iPad. Adrian suggested I take a look at Kplex as an alternative to OpenCPN.

      Did you get such a setup running? (Looking for a mentor, of course… Linux is a whole new ballgame to me.)

      Bill

  12. Petter Neumann says:

    Also Opencpn has the possibility to forward NMEA date to network ports and might be easier to use for average Joe since it has a GUI interface and is installed together with the opencpn program, so if you are running opencpn, it is no need to install additional software.

  13. Andrew says:

    Hi there,

    Thanks a bunch for article- it’s inspired me to build out my own setup. Would you be willing to share what antenna you ended up using? And maybe a follow-up/update post on your system?

    • mattkabrown says:

      At the time I wrote this article I was just using a radio-shack antenna with a BNC connector. But since then I have put a splitter on my permanently mounted VHF antennae which has improved the reception quite dramatically.

      Since this time I’ve been trying to get hardware acceleration to speed up the RPi, and it was only recently that I actually got a complete system running with hardware acceleration, AIS, GPS, and vector charts.

      • Thanks for the quick response, going down the splitter route seems like the simplest solution. Could I lastly ask what splitter you ended up going with?

        Also, I plan on using my dAISy and RPi to my laptop and iPad.

      • mattkabrown says:

        I don’t have the models handy, but it was a basic VHF splitter, a Coax->BNC adapter, and a BNC cable to dAISy

  14. Adrian says:

    Hi Matt

    What GPS are you using with the Pi?

    Thank you.

  15. Curt says:

    I also use the basic VHF splitter like Matt uses.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: