Since this project’s main intent is to create a dedicated chartplotter/autopilot, it doesn’t make sense that I need to open a terminal window, start the gpsd service, and then double-click the OpenCPN icon on the desktop to get everything up and running. It should all just start up once the RPi boots up, and since it’s simply a Linux computer, this is possible, and really quite easy
First, the gpsd service needs to be started. As mentioned previously, there are a few terminal commands that are used to start the service. I simply created a pearl script in /etc/init.d/ that performs those steps:
### BEGIN INIT INFO
# Provides: noip
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to start a program at boot
# Description: A simple star/stop script
### END INIT INFO
echo 'Starting GPSD'
sudo service gpsd restart
sudo killall gpsd
sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock
Then, I registered it to run at startup using the update-rc.d command. After a reboot, I was able to simply open a terminal window and execute xgps successfully, proving that the GPS stream was available.
The next step was to launch OpenCPN. I tried many different ways, but many had difficulties reading the user config settings. The simplest way, that worked great, was to create a launcher and place it in an autostart folder inside /home/pi/.config. The launcher file was already on the desktop, so it was a simple copy/paste process.
And with that, on reboot, OpenCPN launches, and after a minute or two GPS acquires the satellites and the chartplotter portion of the project is complete.
This is the detailed documentation of every step necessary to create the Raspberry Pi chartplotter computer. I upsized my SD card to an 8-gig version so I could have more room for charts and other programs, and when I did so, I documented the process. This is the same process that was done before, but this time it is documented much more thoroughly.
Setting Up Raspberry Pi
- Format a new SD card.
On my windows machine, I used the SDCard.org application as the OOB Windows format apparently doesn’t work (I didn’t try it, just going off of forum posts).The only option I changed was to set FORMAT SIZE ADJUSTMENT = ON and give the volume a name.
- Download the NOOBS package from raspberrypi.org and extract onto the SD card
- Connect the RPI hardware
- HDMI connection to a monitor
- Ethernet connection to a router with internet connectivity
- USB Keyboard & Mouse
- Insert the SD card into the Raspberry Pi and boot. Install the OS of your choice (I used Raspbian)
Confirm overwriting of the data
- On first load, set a few settings. I used the following:
- Boot to Desktop: ON
- Overclock: Medium (950MHz ARM, 250MHz Core, 2 overvolt)
- Update internationalization for US
- Raspberry pi is a UK product, set the Locale, timezone, and keyboard layout to the US versions.
- It’s always smart to get the latest updates for the OS, so:
- sudo apt-get update
- sudo apt-get upgrade
- Next I want to set the video resolution to something fast, and yet of high quality. I settled on 1280×720@60Hz (720p CEA : Group 1, Mode 4)
- I also don’t want the screen to get turned off, since it’s probable that the chartplotter will run for long periods unattended. I found a forum post that fixed it, by editing lightdm.conf
- I want to use a wireless keyboard with built in trackpad, so the next step is to set that up
- This was a very rigorous and difficult process that entailed inserting the USB dongle and turning on the power switch on the keyboard!
- Up to this point, I was using wired Ethernet for internet access. I don’t have a hub on the boat, so I got a wireless USB adapter to connect through instead. Setup was a 2-minute task:
- Turn off the Pi
- Plug the adapter into the Pi, and disconnect Ethernet
- Open the WiFi Gui
- Click scan. double-click the network you want to connect to.
- Enter WiFi password
- Click connect
- Install Geany for C/C++/Python development
- sudo apt-get install geany
- Enable I2C communication (for Arduino and sensors)
i2c-bcm2708 and i2c-dev
sudo apt-get install python-smbus i2c-tools
At this point I have a RPI device up and running.
- Rather than replicate the instructions, and to make sure that they stay up to date as new versions are released, I refer to the instructions at http://www.agurney.com/raspberry-pi/pi-chart since that is line-for-line what I did to install OpenCPN
- I did update config.txt for vector charts so that if I change my mind it won’t crash
- I did update opencpn.config for MEMCacheLimit=40 NCacheLimit=10 (Must be done after running OpenCPN for the first time)
- Download the appropriate NOAA charts, and extract them into a directory
- You can use Raster or Vector charts. I use raster charts as I think they look cool, and they seem to perform better on the Raspberry Pi
- Add the directory to the charts directory in OpenCPN, and allow them to be scanned and indexed
- As you zoom in and pan, more charts will be indexed and scanned. This takes a while on the RPI, but it seems to be pretty stable. Spend some time getting the most common areas in your cruising grounds stored, I simply pan, zoom, and wait until the charts are indexed. I took 3 iterations until I got all the charts indexed
- Install the Konni Logbook plugin from http://opencpn.org/ocpn/downloadplugins
Over the past few weeks I haven’t had much opportunity to work on this project, but I have tossed around some ideas.
I have found that the project is now complicated enough that I needed to mock up a design for what I plan to do. Here’s the current design, mocked up on Fritzing :
This way I can make sure that the required (and desired) components would be available without needing to add expansion boards. For example, by doing this exercise, I have discovered that a future capability – to be able to consume AIS signals – would require additional components. Most likely in the form of a powered USB hub, but possibly as additional Arduino-based devices to save on power.