We have been using Linux on board since our second season on Soledad – three years ago. There exists quite a large collection of marine/sailing software for Linux. As you might know from previous posts, we mainly use OpenCPN and zyGrib for navigation. In this post, I will explain how we got more by connecting our computer to the boat’s electronics and to an Iridium satellite phone.

Note: this post just gathers information available elsewhere (forums, website, documentation, etc.). I hope you find convenient to have it in one page!

Connecting Linux to the boat’s electronics

A loooong time ago, boat electronic devices were incompatible between brands. Well, incompatible with everything, in fact. Then, some standards were created (NMEA0183, at first for GPS devices, then was expended to accommodate other devices) to allow communication between various pieces of equipment. With NMEA0183, one device (e.g. wind sensor) could talk to another (e.g. auto-pilot). NMEA0183 devices were quite limited (usually, they would only ‘talk’ to one other, not more) and for each device you needed a whole bunch of cable to power it up and make it communicate with the rest, often by adding ‘multiplexers’ (a device that aggregates the data from several devices and send its through a single output) in the mix. Not funny to maintain, not flexible at all.

Then came NMEA2000, which is now widely adopted, most marine brands adhere to it (marine electronics, marine engines, etc.) even though they call it differently sometimes, for marketing purposes. The idea is simple and effective: a single cable (with 6 wires) runs through the boat (it is called the ‘backbone’ or ‘bus’), and by using T-shaped connectors, you can easily plug your devices (sensors, instruments, etc…) along the cable. Most devices get power and data from the bus, making the installation very easy. Power hungry devices (e.g. auto-pilot controller) usually have to be fed by specific power cables.

So… now that every single piece of data regarding the boat is running through one single bus, we just need one more device that can read the NMEA2000 data and export is to some more ubiquitous media: WIFI. Those devices are called gateways ; on Soledad, we use the VesperMarine XB-8000, which is an AIS and a gateway. There are other gateways with different capabilities (just google for “NMEA2000 WIFI gateway”). I like the XB-8000 because not only I can get all the boat’s data to my computer, I can also send data from the computer to the NMEA2000 network.

How does the NMEA2000 data looks like when it is exported over wifi, you ask? There are no standards for that, but most gateway makers have decided to go for NMEA0183 🙂 That’s it: my computer receives the boat’s data in NMEA0183 format, which is nice because it is mostly readable by human beeings (while NMEA2000 can only be deciphered by the devices themselves). Some organisations are trying to push for an open standard like Signal K (JSON-based), which is a nice thing. Unfortunately, most software running of the computer (or phone/tablet) expect NMEA0183 from the gateway.

Once the boat’s data reaches the WIFI network, it’s a whole new world of possibilities! Here are a few things that are possible:

  • Store whatever information you want on your computer (boat track, etc.)
  • Display information (depth, wind, etc.) on phones/tablets/computers. When dropping the anchor, you know how far the bottom is by just looking at your handheld device.
  • See AIS targets on your phones/tablets/computers. You can also track them to see if their course is changing.
  • Make your computer aware of your position on earth. Your computer knows when it’s night and sets the screen darker.
  • You don’t have to activate the GPS on your phones/tablets, which usually uses a lot of the battery: the position comes strait from of the boat’s GPS.
  • Maintain your computer right on time with the GPS clock.
  • Get the current time-zone from your position (if you’re sailing across an ocean)
  • Set and anchor drag alarm on your mobile. With the XB-8000, you don’t even need to have the boat’s electronics running for that since it has a GPS.
  • Prepare a route on your favourite chart plotter and get it sent to the autopilot.

Most importantly, you are then FREE to use the navigation software and marine charts you prefer. On Soledad, we use:

  • On the navigation computer, running when batteries are OK:
    • OpenCPN (this software connects to the gateway)
    • zyGrib / Windy.com
    • GPSd (this software connects to the gateway)
    • NTP to keep the time right
    • Some other tools that I developed:
      • an NMEA0183 software multiplexer, NMEA0183 console and filter, etc.
      • A tool that gets the current timezone from the GPS position
  • On the boat’s Android ‘phablet’:
  • On my Android phone and tablet (both used as back-up):
    • Transas’ iSailor (it connects to the gateway)
    • Navionics (backup charts)
    • VesperMarine’s WatchMate app
    • VLC and Amazon Prime Video for watching films during the night shifts 🙂

It’s a good thing to be able to check the wind or AIS from anywhere at night when sailing.

Gibraltar - OpenCPN on Linux with AIS targets
Gibraltar – OpenCPN on Linux with AIS targets

We use Linux on our main computer for various reasons:

  • I am more comfortable with Linux than any other OS
  • Linux is free, Linux works well on tiny computers that don’t draw much power
  • It is possible to install Linux on small disk drives.
  • Linux can easily be set up to not update unless you ask for it
  • Linux can run for days without trouble
  • All the software you need for navigation is easy to find and install

Running OpenCPN and the likes are totally possible any other OS… but you can not get MacOS on a tiny computer or get a Windows computer to work for years without becoming slow.

Connect GPSd to the NMEA2000 gateway

Why that, you ask? Just because GPSd is an almost standard way of sharing GPS information (Position, speed, satellites in view, etc.) to other software on your Linux computer. To do that, make sure “gpsd” is installed and edit the configuration file for the service (/etc/conf.d/gpsd for me, check your documentation):

# Config file for gpsd server
GPSD_OPTIONS="-n"
DEVICES="tcp://192.168.15.1:39150" 
GPSD_SOCKET="/var/run/gpsd.sock"

Basically, you just give the IP address and port of your gateway’s NMEA0183 data stream. Then you’re ready to start the service (check your Linux manual for that).

Configure NTP to synchronise with GPS clock, using GPSd

Make sure the NTP service (called ntpd) is installed on your computer, then edit the corresponding configuration file (/etc/ntp.conf for me) and add the “GPS Serial data reference” and “GPS PPS reference” sections (as is), as shown below your ‘standard’ NTP pools (I commented out those, since I no longer use them):

# Pools for Gentoo users 
#server 0.gentoo.pool.ntp.org 
#server 1.gentoo.pool.ntp.org 
#server 2.gentoo.pool.ntp.org 
#server 3.gentoo.pool.ntp.org 

# GPS Serial data reference 
server 127.127.28.0 minpoll 4 maxpoll 4 
fudge 127.127.28.0 time1 0.0 refid GPS 

# GPS PPS reference 
server 127.127.28.1 minpoll 4 maxpoll 4 prefer 
fudge 127.127.28.1 refid PPS

Then start or restart your ntpd service. Your computer’s clock will get synchronised with your GPS clock (make sure gpsd service is running!), which is a nice way to get the right time when you are offshore.

Get current timezone while at sea

I always liked to keep the system clock set to UTC on my computers (even on land), but in the user interface I prefer to have the local time. While UTC is useful for weather files, local time is useful to have lunch at the right time 🙂

After looking for it for quite a long time, I could not find any software that would give the current timezone based on GPS coordinates AT SEA. “At sea” is important, because that is the tricky part of the problem to solve: “Nautical time zones are split into one hour intervals for every 15 degree change in a ship’s longitudinal coordinate.” (from wikipedia). Then, I discovered a software called timmeh… which seems abandoned since 2016, and that I could not make to work. Fortunately, the software being published under the MIT license, I was able to quickly build a working version. The original developer had a simple and effective idea (and I built on it): associate each place of the earth to a unique colour (see picture below – each pixel represents a 12 nm by 12 nm square). The GPS coordinates are used to pick up the right pixel in the picture. Then a small text database gives the corresponding timezone to the pixel’s colour.

Timezones at sea
Timezones at sea

That is all there is to it! From GPS coordinates to pixel to colour to timezone.

Here is a quick script that connects to GPSd, get the GPS coordinates, get the corresponding colour, and then gives the current timezone. You can download it from here: timezone_from_gpsd (zip file containing 3 files: the above image, the timezone database, and a bash script). Note: It requires the convert command from ImageMagick package.

Connecting Linux to an “Iridium 9575 Extreme” phone

When we went sailing offshore with the family, we felt the need to be able to call for help in case something goes wrong. I checked what other sailors were doing and most are going for the “Iridium Go!”. To be honest, I don’t like the fact that the Iridium Go! is just a useless box until you connect your smartphone to it… and then use their specific apps to call, get emails or the weather. So, we decided to buy a second-hand Iridium 9575 Extreme phone (most of the second-hand ones are almost like new – ours had been only used for less than 8 minutes). Why did we choose this phone?

  • It is a phone, it is autonomous (no need to connect another device)
  • We turn it on and in less than 30 seconds we are ready to call
  • It has a GPS, an emergency button and is waterproof
  • Any one can send us a text message for free
  • It’s easy to set up the device to send our position to a list of friends

The second hand phone we got came with all its accessories, including an external antenna (tiny, and so far it proved to be quite useless) and a USB cable for connecting to a computer. OK… then why not check if Linux can make some good use of it 🙂

Configuring Linux to use the Iridium 9575 as a modem

In the end, the set up proved to be quite simple. The most difficult was to find the right information on the internet. There are some Linux computers using sat phones to upload data from remote places (I read about some scientific workstations in Antarctica), so I knew it was possible to make it work.

If, like me, you like to compile your own kernel to keep it small, you will probably need to select the following options in your kernel configuration:

* For PPP:
CONFIG_PPP
CONFIG_PPP_ASYNC
CONFIG_PPP_SYNC_TTY
CONFIG_PPP_DEFLATE
CONFIG_PPP_BSDCOMP
CONFIG_PPP_MPPE

* For Iridium Extreme:
CONFIG_USB_ACM

PPP is the ‘Point to Point Protocol’ used to connect the computer to the remote server on Iridium’s side. ‘ACM’ is the driver to use so that the kernel know how to handle the modem inside the Iridium phone. If you did a standard Linux installation, chances are that these options are already active, check your kernel configuration. If you prefer to have the driver compiled as a module, it will be called ‘cdc_acm’.

Once you are using your new kernel, just plugging the phone should be enough to check that everything is OK. Once plugged, the module loads itself and a new device appears in your ‘/dev/’ directory:

$ ls /dev/ttyACM*
/dev/ttyACM0

Now that the computer is able to communicate with the Iridium phone, it’s time to install some software that will actually use to the modem, make it call the right number, and setup a network interface so that all software running on the computer can have access to the internet. Just like the good old noisy modems we used back in the previous century – just don’t expect your Iridium phone to be as fast as your old modem was 🙂

The easiest was to use a program called “wvdial“. Just install it the way you install any other software, make sure you also have “ppp” software installed.  “wvdial” comes also with a tool called “wvdialconf“. Run”wvdialconf” as root, and it will prepare a configuration file for your Iridium modem (this file tells “wvdial” how to initialise the modem, what command to send, etc.)

# wvdialconf

The next step is to edit the generated file as root (/etc/wvdial.conf) to indicate what number should be called. Here is my “wvdial.conf” file:

[Dialer Defaults]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
Modem Type = USB Modem
ISDN = 0
Username = none
Init1 = ATZ
Password = none
Modem = /dev/ttyACM0
Baud = 460800
No username nor password are needed. The phone number to call is 008816000025 (I don’t even remember where I got it…), and that is all you have to configure. When all is ready, just run as root:
# wvdial

… and that’s all. It should automatically:

  • Initialise the modem, wait for the carrier and dial the number
  • Prepare a network interface for PPP
  • Receive all the IP routing info from the remote server via DHCP

Usually, it takes around 40 seconds of connection to get everything ready. Once the IP routing info is received (including DNS information), you have to use the network straight away or the modem will just disconnect after a short period of time. Usually, I prepare the zyGrib download area before making the call/connection: I select the region (as small as possible), the type of data (only wind and wind gusts), the period (next 2 or 3 days only), the resolution (0.50°), the interval (every 6 hours) – no swell/waves unless we are concerned about that. This requests really small GRIB files from zyGrib’s server and the transfer usually takes less than 4 to 8 minutes. If you go for longer transfers, it can happen that you lose the signal in the middle of the transfer… which is bad because the downloaded piece of file is then useless. We use a long USB extension cable so that the phone can be outside on deck and have a clear view of the sky/satellites.

We have used this set-up between Madeira and Cadiz, and again between Cartagena and Sardinia. After a couple of days at sea, we like to update the weather file and compare it with the previous to check the current trend.

Conclusion

Do you know about another Linux software for navigation that is pretty cool? Please let me know.

Do you need help to setup your network on board? Drop us an email!

4 thoughts on “Sailing with Linux (NMEA, GPSd, Iridium)

    1. Hi! Life would be boring if everything COMPLETELY worked perfectly 🙂
      We have a mix of SIMRAD and B&G (which is basically the same brand) electronics and are still struggling to get the distance log (!!) working (the only thing that keep us away from perfection).
      BTW, we just passed in Lefkas canal a few days ago. We’re in Paxos, heading to Corfu.
      Are you around? Fair winds!

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s