It’s a well worn cliché that little in the boating world comes cheap. Monitoring systems can cost hundreds (or thousands) of dollars for the hardware alone. Ongoing fees for connectivity and alerting can extend those high dollar expenses out into the future.
But it does not always have to be this way; below is a complete guide to a perfectly serviceable (and reasonably reliable) monitoring system based around open source software that will cost under $100 to put together. It does assume you have WiFi coverage at your boat’s marina or mooring, but that is an increasingly safe assumption to make. You can then use the free service tier at FloatHub to get vessel tracking and alerts. We’ll even discuss Alexa connectivity so you can ask your Amazon Echo about how your boat is doing and get an up to the minute report.
Overview
Our system will be built around a small Raspberry Pi computer, to which we’ll add a GPS module for location information. We’ll also suggest a case suitable for mounting inside a vessel. Then we’ll run through all the steps to get the required software in place and configured. Finally, we suggest a few avenues for further extensions.
Hardware and Software Required
Because they are quite robust and have low power requirements, Raspberry Pi computers are quite popular aboard boats. At the time of writing, the newest version available was the 4, but the venerable version 3 (B Plus) is more than powerful enough for our purposes. It’s available here (for roughly $38).
You’ll also need a suitable case for securely mounting the system. One option is available here (at a cost of about $13).
For the GPS module, you have a couple of different options. In most boating applications, a below-decks device such as this would still have a pretty clear electromagnetic-view of GPS satellites, so a straight USB dongle should have little difficulty getting a good fix. One example we’ve used for testing purposes is a Diymall VK-172 at $14 (but there a ton of different models all built around similar Ublox chipsets):
If you want a little more flexibility about where the GPS unit goes, or if you have a metal vessel, you might want a GPS with a more robust housing and a longer USB lead. Again, anything built around a Ublox chipset should do the trick, but we’ve had good luck with these $24 units:
In case you are not overly familiar with Raspberry Pi computers, you’ll also need an SD card ($7) for the file system and some sort of micro-usb power source ($10). All of this brings us to grand total of $80-$90 all in (depending on which type of GPS you choose).
That’s it for hardware, everything else is setup and software.
Setting Up the Raspberry Pi
Before you can boot your Pi and start installing software, you’ll need to burn the standard image to your SD card. Very detailed directions can be found at the Raspberry Pi site, but the gist of it is to download an image for your SD card and then use software on a computer to copy the image to the SD card. Once you have the image in place on your SD card, you insert it into the Pi, temporarily connect an HDMI monitor, USB keyboard, and USB mouse, and power up the unit (don’t plug in your GPS yet).
You should get to a desktop screen that looks something like this:
The first thing you’ll want to do is click on the WiFi icon (red #1 above) in the upper right and connect to your WiFi network. Next, you want to open a terminal window where we’ll be typing in commands to complete the software setup. You do that by clicking on the terminal icon (red #2 above), so you have a desktop that looks like this:
Detecting Your USB GPS Dongle
Go ahead and insert your GPS, and type the following command into the terminal window you just opened:
dmesg | tail -10
This tells your Pi to list the last 10 lines of a “diary” it keeps about devices and peripherals it is talking to. What exactly is listed will be different for you, but it will show something like this:
[106346.573558] usb 1-1.1.3: Product: Dell USB Keyboard
[106346.573567] usb 1-1.1.3: Manufacturer: Dell
[106346.625692] input: Dell Dell USB Keyboard as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.3/1-1.1.3:1.0/0003:413C:2105.0004/input/input3
[106346.691534] hid-generic 0003:413C:2105.0004: input,hidraw1: USB HID v1.10 Keyboard [Dell Dell USB Keyboard] on usb-3f980000.usb-1.1.3/input0
[106676.651941] usb 1-1.3: new full-speed USB device number 11 using dwc_otg
[106676.784156] usb 1-1.3: New USB device found, idVendor=1546, idProduct=01a8, bcdDevice= 3.01
[106676.784175] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[106676.784185] usb 1-1.3: Product: u-blox GNSS receiver
[106676.784194] usb 1-1.3: Manufacturer: u-blox AG - www.u-blox.com
[106676.788099] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device
The important bit is where it lists details about a “u-blox GNSS receiver” near the bottom of the list (which is why you want to plug your GPS in last, just before running the dmesg command). Your need the USB device name that your Pi chooses for your GPS device. In this case, it is ttyACM0
. It will alway be tty-something, and should be pretty obvious on the last line or two of the output.
Installing and Configuring kplex
Next we need to install a very useful utility called kplex. Almost anyone using a small computer aboard a boat will end up installing kplex at some point, because it is a very useful utility for handling navigation data (such as that produced by your GPS dongle).
There’s a great quickstart guide on the kplex website, but essentially you want to start by downloading a kplex package for Raspberry Pi from the downloads page. You can do this right from the browser on your Raspberry Pi by clicking on the icon in the very top left cornet (the raspberry) and selecting
Internet → Chromium Web Browser
and then navigate to:
http://www.stripydog.com/kplex/download.html
Click on the link for the Raspbian image and the file will be downloaded. You might have to click on a security question about accepting files of this type. Go ahead and do so. You can now go back to your Terminal window and type:
sudo dpkg -i ~/Downloads/kplex_1.4-1_armhf.deb
This should install the kplex package on your Pi. You then need to edit the configuration file for kplex, by typing the following command in your terminal window:
sudo leafpad /etc/kplex.conf
This will open an editing window (leafpad) that will allow you to change kplex’s configuration settings. Scroll down to the bottom of the file and make sure the last few lines look like this (changing the device name to whatever you found it to be in the previous section):
[serial]
filename=/dev/ttyACM0
baud=38400
[tcp]
mode=server
port=10110
Save the file and then quit out of the editor. You can now go back to the terminal window and try running kplex by entering kplex -d 9
. If all goes well, you should get a brief response like this:
kplex DEBUG: kplex starting, config file /etc/kplex.conf
kplex DEBUG: _serial-id1: opened serial device /dev/ttyACM0 for input/output
kplex DEBUG: _tcp-id2: initialised
This means kplex is listening to navigation data being produced by your GPS (/dev/ttyACM0
) and re-transmitting that data (over a network protocol called TCP) to anything that asks for it on port 10110.
Installing and Configuring sfh
Out last software step involves installing another open source utility called sfh (for Soft FloatHub). This is the program that will consume that stream of GPS data and periodically transmit updates about your vessel’s location, speed, etc. to the FloatHub website. From there you can monitor it remotely, set alerts, and so forth. To complete this step, you’ll need Device ID and Security Key from FloatHub to uniquely identify your vessel. They don’t cost anything, and you don’t need to provide any personal information (other than an email address). If you don’t already have a FloatHub account, sign up here, then grab your Device ID and Security Key by clicking on the button that says “Show FloatHub Device Settings” on your account page.
Next, open a second terminal window (kplex should still be running in the first terminal window) and enter the following command:
git clone https://github.com/floathub/sfh.git
This will download the sfh software. You can now run it by typing:
./sfh/sfh -v -i device_id -k security_key
making sure to substitute your FloatHub Device Id for device_id and your Security Key for security_key. These are long strings, so take a little time to double check you have typed them correctly. Once you hit enter, navigational data should start scrolling by. If you get a message about failing to connect, make sure your kplex process is still running in the other terminal window.
You might get a response that says:
You are missing the pynmea2 library (NMEA processing for python).
You should be able to install it with:
pip install pynmea2
See http://github.com/Knio/pynmea2 for more information.
If you do, go ahead and enter the pip install pynmea2
command. Once it’s completed, reenter the the sfh line above (again with your device_id and security_key info).
You should now be able to go the FloatHub website, log in, and see your vessel’s location displayed:
There’s a lot more you can do on the site, including setting alerts, reviewing trips, etc. More details are available in FloatHub’s support section.
Automating Everything
Once all of the preceding is in place, you’ll want a way to make sure both kplex and sfh are always running and will automatically come back up after a power loss, reboot, etc. Although there are a few different approaches one could take to this, we will stick with the most straightforward.
For kplex, you can tell your Pi to have it always running by issuing the following command (you can either CTRL-C one of the existing processes in a terminal window or open a new terminal window):
sudo update-rc.d kplex defaults
For sfh, we will install a crontab (a way of automating tasks at certain times) on your Pi that starts it at boot-up with the following command (all on one line):
echo "@reboot /home/pi/sfh/sfh -i device_id -k security_key &" | crontab -
Again, be sure to set device_id and security_key to the ones for your specific account at FloatHub.
From the Raspberry Pi Menu, choose Shutdown and then click the Reboot button. When your Pi reboots, it should automatically start relaying data to the FloatHub website. NOTE (!): It can take up to ten minutes for the new data to appear, since the the sfh process only sends summary data about a stationary vessel every 10 minutes (and, on boot up, the very first data transmission will probably be attempted and fail before your Pi was its WiFi connection set up). Be a little patient when debugging.
Asking Alexa
Since you now have your data streaming out to the FloatHub website, you can ask about the state of your vessel with Alexa. From the Alexa App on your phone, just search for the FloatHub skill and authorize Alexa to use your FloatHub data by entering your email and password (i.e. the email and password you used to create your account on the FloatHub website, not your Device ID and Security Key). Then say, “Alexa, open FloatHub.” More detailed instructions for setting this up are available here.
Further Extensions
You now have a fully functional computer running 24/7 on your vessel and reporting back to the world. And the kplex process that is already running can be used to transmit data wirelessly to lots of onboard navigation apps running on a phone, tablet, or laptop (see, for example, OpenCPN). You could also try popping a dAISy HAT onto your Pi, adding AIS vessel information to the mix (both for local onboard use and to live relay out to the world via sfh). If you’re a Pi/Linux whiz, you could look at writing some custom udev rules so that the kplex+sfh system is more robust to device interruptions, replugs, etc. (in addition to reboots). If you have any questions or want to get in touch, please don’t hesitate to contact us.
Photo by Tatiana Zhukova on Unsplash