A Year Later: OpenCPN on a Raspberry Pi 3

It’s been over a year since I’ve tried to use OpenCPN on a Raspberry Pi, and I thought I’d see what the community has done since then.

Wow.

Simply Wow.

A Raspberry Pi 3, with the latest versions of Raspbian/PIXEL and OpenCPN matches up as good as commercial entry-level chartplotters on the market today. This platform has really come a long way in the past year, and I’m truly impressed.

Recipe:

Hardware

  • Raspberry Pi 3, Power and HDMI cables, SD card, & case
  • HDMI Monitor
  • USB Keyboard with integral trackpad
  • USB Wifi Adapter
  • GlobalSat BU-353-S4 USB GPS Receiver
  • dAISy Hat AIS Receiver

Set Up Rasbian

  • I burned the most recent version of Raspbian/PIXEL (March 2017) onto a 32GB SD card, inserted it into a RPi3, and booted. In seconds I had a desktop.
  • Connect to WiFi with a USB dongle
  • I removed the products I don’t need:
    sudo apt-get purge wolfram-engine mathematica-fonts sonic-pi nodered libreoffice
    sudo apt-get autoremove
  • Update Kernel to latest for OpenGL
    sudo branch=next rpi-update
  • Reboot
  • sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install mesa-utils
  • sudo raspi-config
    • Set Timezone
    • Set Locale and Keyboart to US English
    • Change graphics memory split to 128MB
    • Enable OpenGL Driver
      • With Full KMS, I had problems with the display not working after a reboot, so I needed to use Fake KMS, Option G2. To recover, edit config.txt and comment out the dtoverlay=vc4-kms-v3d (or edit to be vc4-fkms-v3d)
  • Turn off screen blanking
    • sudo nano /etc/lightdm/lightdm.conf
      • [SeatDefault]
      • xserver-command=X -s 0 dpms
  • Reboot
  • Run glxgears
    • I was running glxgears at 60fps and 2% CPU
    • At full screen I saw 30fps and 11% CPU
  • Run glxinfo
    • Direct Rendering: yes
    • Renderer string is the Gallium renderer, and not Software Rasterizer
    • OpenGL Version string is 2.1 Mesa 13.0.0

Install OpenCPN

  • Install required supporting tools
    • sudo apt-get install gpsd gpsd-clients screen
      • This required a reboot to work properly
  • Install the OpenCPN software from the Ubuntu PPA
    • In previous recipes I have built from source. To save time, and because building from source truly isn’t necessary, this time I just used the pre-built packages
    • sudo nano /etc/apt/sources.list
    • sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C865EB40
      sudo apt-get update
      sudo apt-get install opencpn
  • Download charts from NOAA
    • I simply create a directory under the user account to hold all OpenCPN files, and a Charts subdirectory
    • After extracting, to pre-render all the charts, from a terminal window run:
      • opencpn -unit_test_1 0
  • Set up GPS
    • I actually had a bit of difficulty for the first time in a while getting GPS set up. If I ran cgps or xgps I got no data, but running gpsmon showed a good solid fix
    • This is the sequence of commands I followed to get it working (and works on subsequent reboots):
      • sudo dpkg-reconfigure gpsd
      • sudo nano /lib/systemd/system/gpsd.socket
        • Change ListenStream=127.0.0.1:2947
          to
          ListenStream=0.0.0.0:2947
      • sudo nano /etc/default/gpsd
        • START_DAEMON="true"
          USBAUTO="true"
          DEVICES="/dev/ttyUSB0"
          GPSD_OPTIONS="-n"
          GPSD_SOCKET="/var/run/gpsd.sock"
      • sudo killall gpsd
        sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
    • Connect GPS to Opencpn
      • Open Settings, Connections Tab. Click Add Connection
        • Type: Network
        • Protocol: GPSD
        • Address: localhost
        • DataPort: 2947
        • Priority: 1
        • Control Checksum: Checked

Setup dAISy Hat

  • Update config.txt to enable UART
    • sudo nano /boot/config.txt
      • add the following lines
        • # Enable UART
        • enable_uart=1
        • dtoverlay=p3-disable-bt
  • Disable Console Serial
    • sudo nano /boot/cmdline.txt
      • remove the following:
        • console=serial0,115200
  • From the Menu, select Preferences->Raspberry Pi Configuration
    • Interfaces Tab
      • Enable Serial
  • Reboot
  • Test Hat Serial communication
    • screen /dev/serial0 38400
      • [ESC] brings up a menu
      • ‘T’ sends a test message every 5 seconds
      • [CTRL-A], ‘K’, ‘Y’ to exit
  • Add AIS stream to OpenCPN
    • Open Settings, Connections Tab. Click Add Connection
      • Type: Serial
      • DataPort: /dev/serial0
      • Baudrate: 38400
      • Priority: 1
      • Control Checksum: Checked

Results

OpenCPN running ENC charts, with location set by GPS, and AIS contacts listed.

This also shows 24 AIS Targets in a list, as well as xgps running in the background. 6% CPU.

AIS Target Query. Deep zoom into the Hylebos waterway to find three vessels currently underway, including the cargo ship Indigo Lake. These vessels were approximately three miles away from my current location

References

Advertisements

22 Responses to A Year Later: OpenCPN on a Raspberry Pi 3

  1. William Fleenor says:

    If you used a Raspberry Pi 3 why did you need a WiFi adapter?

  2. kit thomas says:

    Did you get a chance to look at the AIS QK-A022 module we sent you last autumn at all? We’re several upgrades on now but would still appreciate your comments.

  3. Brian Smith says:

    Very cool, Matt! Thx for all the details. Have you thought of using a touchscreen?

    • mattkabrown says:

      I played around with touchscreens a while ago, but at the time it wasn’t the best experience with OpenCPN. I’ll try again, as I bet the android work on the product will have made a difference.

  4. Winston Heisler says:

    Hello, Total neophyte with Raspberry Pi.

    Want to make an integrated Plotter using a Pi-2 and the Daisy Hat 2 channel receiver. Have not found any specific firmware/software for the Raspberry Hat install. Any references would be appreciated.

    Thanks,
    Winston Heisler
    winstonheisler@hushmail.com

    • mattkabrown says:

      The Daisy Hat is simply a serial comm device at 38400 baud. There’s really no firmware or software needed, you just need software to consume it. It’s fairly close to plug and play — you just need to find out where the data is being written.

      Every step of the installation is what I posted on here, but getting it to work on a RPi3 can be a bit of a pain because of what they did with bluetooth.

      Or maybe I’m not understanding the question?

      • Winston Heisler says:

        O.K. Now I understand… Will take a closer look at what you have.. Guess I’m biting off a little more than I can chew… Just don’t want to reinvent the wheel…
        Thanks,
        Winston

  5. Have you tried the OpenPlotter image yet? Very powerful.

    • mattkabrown says:

      I have, and it’s a great solution as well. I choose not to use it, because I use the RPi for things other than simply chartplotter work — blogging, email, media player, etc.

      Also, with the stock OS I know that I can follow any online guides and not have to worry about kernel parameters or other unexpected configuration differences.

  6. Curt Brownlow says:

    I currently run the RPI2 and OpenCPN Ver 4.0.0. I want to upgrade to the latest ver of OpenCPN. Is there anything special I should know/do or can I use the instructions you have that are talking about the RPI3? Thanks!

  7. Curt Brownlow says:

    Oh yea – can the RPI2 be set up to use an external HD? I would like to store all my charts there.

    • mattkabrown says:

      Absolutely. Any USB connected drive works well. I use Western Digital passport drives to store movies and music on and stream them to devices on the network.

      • Curt Brownlow says:

        Thanks. Can I just plug it into an open USB port or will I need to input a command so the RPI will recognize the drive? If there is a command, would you mind passing it along? Thanks very much.

      • mattkabrown says:

        It should just be plug and play.

        Some external drives take a lot of power from the USB ports, and power management has been the one Achilles heel with the RPi in my experience. A powered external USB hub would solve it.

      • Curt says:

        I attempted to turn off screen blanking per your instructions but my monitor continues to go to sleep. i see the command under the [SeatDefault]. Any thoughts? Prior upgrading to the new OS ver (which I really like) my monitor stayed on full time.
        Thanks.

  8. Tommi says:

    Outdated for Stretch?

  9. Pingback: Raspberry Pi 3 with 7″ touch screen and OpenCPN – Sage the Boat

  10. Ha MaiViet says:

    Could you overlay AIS daisy receiver and Garming VTS on OpenCPN ?

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: