Turn a Raspberry Pi into a Regetta Processor (and more)

I’ve been cleaning up the boat computer package I’ve been building and want to put it out there so you all can use it and contribute to it. The goal here is to turn a $35 Raspberry Pi or Beaglebone Black into a sensor hub and processor, similar to the B&G H5000 or any other regatta processor.

Raspberry pi is B&G

The package provides several functions through a modular ‘app’ system that I’ll talk about in a bit.

  • It enables calculation of complex data like true wind and currents.
  • It broadcasts all NMEA messages over UDP, so that the sensor data can be displayed in mobile apps like iRegatta and NMEA Remote.
  • It logs all NMEA messages to the Pis disk, and enables downloading of the logs to mobile devices.
  • It stores your sailing instructions so that you can reference them while on the water.

I’ve also started developing some add on apps.

  • It has a web interface for setting a waypoint, and it calculates and displays on instrument screens heading, time, and bearing to the waypoint
  • It enables customizable instrument screens displayed on your mobile device

index documents logs goto output_1sGSns


Any module in the app/ folder at startup will be loaded, if it has the following export:

exports.load = function(server, boatData, settings)  

These three arguments give the app access to the NMEA data stream, the sailors, and an easy place to store simple configs.

  • server – and ExpressJS server object, for adding new web apps
  • boatData – an interface to the boats sensor data.
  • settings – an interface to get and set simple config values.

You can write simple modules that just interact with the sensor data. With Node.js’s event based patterns, its pretty easy to create an app that calculates current from speed, compass, and gps sensor data.

exports.load = function(server, boatData, settings) {
    //@ 1Hz, broadcast current set and drift
    setInterval(function() {
        //first, get the latest boat data
        var data = boatData.now();
        //then use it to calculate the current vector
        var currents = calcCurrents( data.speed, data.hdg, data.sog, data.cog );

        //broadcast the new bit of data. boatData will handle NMEA formatting.
            type: 'vdr',
            set: currents.set,
            drift: currents.drift
    }, 1000);

Or to create an app to show more sensor readings (or custom calculations like ‘target speed’) on your tacktick displays.

exports.load = function(server, boatData, settings) {
    //add tacktick formatter to boatData's nmea parser
    boatData.nmea.parsers.PTAK = {
        format: function(data) {...}

    //every time we get a heading message, make a custom 
    //tacktick message and send it back out.
    boatData.on('data:hdg', function(data) {
            'type': 'ptak',
            'subtype': 'data',
            'index': 1,
            parts: [Math.abs(data.heel)]

    //every 5s rebroadcast the heading label
    setInterval(function() {
            'type': 'ptak',
            'subtype': 'heading',
            'index': 1,
            parts: ['HEEL','@']
    }, 5000);

Or modules that just give sailors access to the boat computer, like the Sailing Documents App.

Or you can make complex modules that have a web app for entering data, and use that data to calculate and broadcast new data to the NMEA network. See GoTo.

Check out the source, install it on your boat and give it a go. Let me know what you think in the comments, or through GitHub’s issue tracking.

Better Speedo

As I’ve learned to sail, I’ve constantly wanted better data out of my instruments so that I could better analyze the performance of different maneuvers.  Moving to a 5Hz GPS last year really illustrated this point.
Here, you can see a tack, where the speedo never even registered within 3/4 of a knot of the lowest speed, and was well over a second behind the GPS in response (this isn’t just a calibration issue, we were in a little bit of current).
Screen Shot 2014-01-19 at 10.29.17 AM
After reading Merlin’s excellent blog here: http://sailboatinstruments.blogspot.com/2011/03/measuring-boat-speed-part-1.html, I decided I could just hook the signal wires from the speedo into the Arduino in my Boat Computer (link).  I realized that if I really wanted a fast response, I’d need to filter the raw pulses.  I figured that I could output 5 or 10Hz, filtered from the raw pulses, and that other parts of the system shouldn’t need to do additional filtering or smoothing.
I researched a bit about signal smoothing and after a little trial and error, decided to go with a simple weighted average using approximately the last 1s worth of pulses.  I went with a scheme that weighed the most recent point twice as heavily as the oldest point.  In the end, calculating speed at 5Hz, this system responds faster than my GPS.  I hoped to do a better test last weekend, but had some power issues on the boat.  I’ll post more results in March when the season picks up.
Screen Shot 2014-01-19 at 10.19.11 AM
I’ve posted the code here: https://github.com/HomegrownMarine/better_speedo.  Let me know what you think, and if you have suggestions about how to do things even better.

My Boat Computer

Over the past couple of years I’ve built a system that is doing a pretty good job for me.  All the parts are kept in a  small Pelican case for easy transport to and from the boat.  I use a parallel cable to run all of the various instrument signal wires into the case.
Here is a diagram of the system.
The zuni-connect creates a wifi access point that many devices can connect to.  All NMEA 0183 is broadcast via UDP, so off the shelf mobile apps like nke Display and NMEAremote can display live instrument data easily.
The Garmin GPS18X-5Hz was a pretty cheap 5Hz GPS a few years ago, before the hobbyist stuff online got so cheap.  I’m mounting it under the deck and it still gets a great signal.  It sends NMEA over serial to the Arduino which forwards the data to the Tack Tick and Raspberry Pi.
The Airmar H2183 is a 10 Hz solid state compass.  It’s a pretty expensive way to go, and I bet you could do as well nowadays with a 9 DOF IMU like the MinIMU-9 from Pololu for $39.
The Airmar ST-300 paddle wheel is pretty standard.
Finally, I’m currently using a TackTick (now Raymarine) anemometer and cockpit displays.  The lag on these is horrible, and part of the reason I’m now reading the pulses from the Airmar speedo manually.
I’ve written one web app, which runs on the Raspberry Pi and will let me set the current waypoint.  The Pi then calculates and broadcasts navigation messages ($GPRMB) to be displayed on the TackTick  displays or on mobile devices connected via WiFi.
It’s pretty straight forward: enter in your destination latitude and longitude and hit “Go To.”  It also keeps a history of your last several destinations.
The Raspberry Pi also logs all data for after race analysis.  I built a few simple web apps a while back to display and explore the data.
1) You can view your track on a map along with the performance data.  Scrub over the graphs and see exact values and a boat shows you where you were in the race at that point in time.
2) The app will find all of your tacks and plot them together so that you can compare what made one better than another.  I’ve got a lot of work to do here, but I think this could be a powerful tool to help one improve.
3) see polars from the race plotted along with historic data.  The idea here is to eventually be able to compare and contrast different rig settings or modes and figure out which is faster.
I plan on open-sourcing all of this in the near future.  I’m in the process of cleaning things up a bit.  I’ve built a bunch of NMEA loggers for my local fleet and I want to get this so that they can upload and analyze their data from home.