Step 5: Install OpenCPN Chartplotting Software

Yay!

So we have a running Raspberry Pi computer, with an NMEA multiplexer configured.  Let’s install OpenCPN now so this little device can act as a full fledged navigational computer.

In order to use OpenCPN you will be running the XWindows GUI and as such you will need a monitor for the rPi.  An SSH connection from another computer can be used for the bulk of the install, but you will need to be directly using the Keyboard/Mouse/Monitor of the rPi to configure and use OpenCPN itself.

Now this is where it gets a bit more interesting.   OpenCPN is written to be cross-platform which means it can run on all sorts of hardware and operating system combinations.  But maintaining installable packages for every combination is a lot of work, so only a few are actually available for download–primarily Windows, MacOSX, and Linux on intel PCs.  To run OpenCPN on the Raspberry Pi’s ARM CPU we need to download the actual source code and compile it custom.   This sounds complex but it’s actually fairly straightforward.   Slightly more challenging is finding and downloading the source code for the various optional plug-ins that add features to OpenCPN.   One of which is the built-in chart downloader which we will definitely want.

Before we can do any of that, we need to install a few more software packages that are necessary in order to compile software as well as support some of the libraries that OpenCPN requires to do things (like make sounds for example).

Unfortunately, some of these packages need to come from APT repositories that aren’t already configured in Raspbian, so we need to add them to APT first.

Note: This was documented using OpenCPN 4.2.1, other versions may be slightly different.  Be sure to check the linked references if you are unsure.

Reference: https://packages.debian.org/jessie-backports/armhf/wx3.0-headers/download

Let’s add the jessie backports repository to APT.  To do this we edit the /etc/apt/sources.list file.

sudo nano /etc/apt/sources.list

Add the following line to the file

deb http://ftp.debian.org/debian jessie-backports main

Save and Exit (CTRL-X)

Next, let’s update our list of packages in the APT repositories.  This ensures we have the latest list and it also adds in new items from the repository we just added to the sources.list file.

sudo apt-get update

You may be prompted about a missing signature for the new repository.  Just accept it, it’s expected.

Now we need to install the base packages needed for OpenCPN as well as for compiling code

Reference: http://opencpn.org/ocpn/compiling_source_linux

sudo apt-get install build-essential cmake gettext git-core gpsd gpsd-clients libgps-dev wx-common libwxgtk3.0-dev libglu1-mesa-dev libgtk2.0-dev wx3.0-headers libbz2-dev libtinyxml-dev libportaudio2 portaudio19-dev libcurl4-openssl-dev libexpat1-dev libcairo2-dev

This will take a few minutes as the packages are downloaded and installed.

The next step is to download a copy of the source code for OpenCPN.   You may notice one of the packages we installed is called git-core.  Nowadays much of the opensource software being written is maintained in a repository on github.com which we can download from easily using a couple commands.

Let’s make sure we are in the right place and then we will clone (copy) the OpenCPN github repository (the code)
cd ~
git clone git://github.com/OpenCPN/OpenCPN.git
alternate (for latest 4.4.0 version)
    git clone -b v4.4.0 git://github.com/OpenCPN/OpenCPN.git

Next we can actually build this into usable software using cmake..
cd ~/OpenCPN
mkdir build
cd build
cmake ..
make

The cmake and make processes will take some time. cmake took under a minute, make took probably a half hour or more on my rPi Model 2 B.

Once the make process is complete, we can install the software to make it usable.
sudo make install

Once complete, we can actually start up OpenCPN and start using it

The next steps must be done from the Raspberry Pi’s own monitor, keyboard, and mouse.  (unless you know XWindows well and are setting up remote Xwindows sessions, in which case you probably don’t need a tutorial all that much. )

We should already be in the XWindows GUI, if not run the following command.
startx

After XWindows starts up click on the Terminal icon in the upper left to launch the LXTerminal program.

Let’s make a directory for charts to be stored in..

cd ~
mkdir charts

To start OpenCPN, run the command /usr/local/bin/opencpn

Sweet!  OpenCPN is installed and running.  But we need charts to make it work, and manually downloading the charts one by one and copying them to a folder on the rPi is tedious.  So we will use the built in Chart Downloader Plugin for that.

I recommend going into the settings UI and doing the following first…
1.) In the plug-ins tab, enable and configure the Chart Downloader Plugin
2.) in Charts tab, go to the Chart Downloader sub-tab and add a repository, update it, then download charts for your area.
Choose the new /pi/charts directory to store the charts in.
3.) Go to the connections tab and set up a data source.  This will be our kPlex server…  (details coming)

At this point you should have OpenCPN running, with an NMEA feed including GPS position data, and some charts.   Anything else you want to do with OpenCPN is beyond the scope of this tutorial.   Refer to the OpenCPN website and documentation for more.

We’ll cover the installation of other OpenCPN plug-ins here…

 

Next Step: Step 6: Install OpenCPN optional plugins