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-utilssudo 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
- Add deb http://ppa.launchpad.net/opencpn/opencpn/ubuntu/ trusty main
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
- Change
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
- Open Settings, Connections Tab. Click Add Connection
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
- add the following lines
- sudo nano /boot/config.txt
- Disable Console Serial
sudo nano /boot/cmdline.txt
- remove the following:
console=serial0,115200
- remove the following:
- From the Menu, select Preferences->Raspberry Pi Configuration
- Interfaces Tab
- Enable Serial
- Interfaces Tab
- 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
- screen /dev/serial0 38400
- Add AIS stream to OpenCPN
- Open Settings, Connections Tab. Click Add Connection
- Type: Serial
- DataPort: /dev/serial0
- Baudrate: 38400
- Priority: 1
- Control Checksum: Checked
- Open Settings, Connections Tab. Click Add Connection
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