Wednesday 23 September 2020

Our NMEA-2000 and Signal-K Electronics System

Hi everyone,

This is a technical post.  We've been doing a lot of work on our electronics system recently.  The work has concentrated on making the most of our NMEA-2000 network.  Adding SignalK to the system has revolutionised access to the data on the network.

We can display identical data on our iPhones, iPads and Macbook using the WilhelmSK app.  And it's exactly the data we want, in the format we want it.  WilhelmSK displays SignalK data gathered and stored on our BeagleBone Black (BBB) computer.  The BBB gets its data from our NMEA-2000 network.  Here's the realtime display we use on our iPads and Macbook...

WilhelmSK on Zen Again

The BBB is a small, cheap, low-power computer running the Debian Linux OS.  It's been running reliably for a couple of months.  We posted about setting up the BBB with SignalK and InfluxDB here.

BeagleBone Black

WilhelmSK allows us to display a lot of data.  Most is from our Airmar DST800 log/depth transducer and our Airmar 220WX weather station.  All NMEA-2000 data is transferred to the BBB using an Actisense NGT-1.  The BBB runs a SignalK server which manages the data and makes it available to clients.

SignalK data goes to our software chartplotters too.  On the Macbook we use OpenCPN which now accepts SignalK data directly.  On our iPads we use iNavX which does NOT accept SignalK.  We setup the SignalK server to translate relevant data into an NMEA-0183 datastream.  The NMEA-0183 is fed to the iPads via the same WiFi hotspot it uses for native SignalK data.  Both OpenCPN and iNavX display AIS traffic information.  On the iPads qtVlm weather routing software also uses the datastream.

To view trends and history our system stores all SignalK data in an InfluxDB database on the BBB.  We can view the data in graphical form using Grafana running on the Macbook.  While the Macbook is running we can also access the graphs from our iPads and even our iPhones.  Here's our favourite Grafana dashboard...

Grafana Dashboard of "last 12 hours"

To calculate data we use node-red which can be added to the SignalK software.  It can input SignalK data and generate new SignalK data.  We wrote a node-red 'flow' to calculate set and drift from boat speed, heading, SoG and CoG.  Node-red uses a GUI and JavaScript.

Node-Red CurrentCalculator Workspace

Node-Red CurrentCalculator Function


It's interesting how radically our electronics system has changed in just 5 years.  In 2015 it was NMEA-0183 and SeaTalk, with one WiFi hotspot.  Here's a diagram of the system at that time...

Zen Again Electronics System circa 2015

Now the system is NMEA-2000, SignalK and WiFi.  We have three WiFi hotspots and another (the Iridium Go!) expected.  In 2015 we had no means of recording data and disparate displays of realtime data.  Now we have common realtime data displays, two recorders and can easily see trends.  Here's the system now...

Zen Again Electronics System 2020

There's a lot of redundancy in the system.  Three GPSs feed data into SignalK - AIS, weather station and chartplotter.  A spare BBB and the Macbook have SignalK and InfluxDB installed.  We described Macbook setup here.  We have two calibrated autopilot systems, and at least 4 rams (having established one is good for one ocean only).  Once we have the Iridium Go! installed we'll have it and the HF/SSB for email access to weather information.

Tangentially, our modernisation also includes carrying Cruising Guide, Almanac, reference, equipment manuals and "cruising bible" books on our iPads.  They're loaded in Kindle and Google Play Books apps.  Other apps include PredictWind, Ovitalmap, Spyglass, ezSights, GoSkyWatch and GoSatWatch.  And of course we have many years of Yachting World and Yachting Monthly magazines on Zinio!

We're starting to feel we're ready to cross oceans again!


Thursday 17 September 2020

Newtown River to Gosport

Hi everyone,

Yesterday morning we returned to Gosport, motor-sailing in light winds.  This was the last leg of our south-west coast cruise which lasted for 55 days.  More stats later, but first a description of our time at Newtown River.

Newtown River sunset

We spent 5 nights anchored at Newtown River.  We arrived at neap tides and had plenty of depth.  For our last two nights we moved about 30m to ensure we stayed afloat as the low tides got lower.  The river is very peaceful at night.  During the day many vessels come and go, making the anchorage quite busy.

Looking SE over the mud flats

Looking S towards the Solent

William the seal

Misty dawn

Feed me or I'll eat your dinghy

High tide exploring

The landing

Our passage back to Gosport was an 11nm motor-sail in light winds.  The track and graphs are below.  The graphs show the strength of the tidal currents in the Solent.

Zen Again track

Zen Again graphs

Reaching sheet on the new Yankee

During our 55 day cruise of the south-west we logged 457nm, ran the engine for 67 hours (about 1/3 of that charging batteries) and visited 21 locations.  We stayed in 2 marinas, on 1 pontoon, on 4 swinging moorings and anchored at 14 locations.  We particularly enjoyed anchoring at the top of rivers, surrounded by farm and woodland.

The only failures we had were the engine overheating at the Needles and the fridge breaking down.  The fridge has been running pretty much continuously for 5 years so no complaints there.  We spent the last two weeks fridge-less but it's a good cool box and we had plenty of UHT milk and canned food aboard.  The successes were the AutoProp propeller, the WindPilot vane gear, the new Yankee headsail and adding SignalK to our electronics system.

Here's our overall track for the 55 days...

Zen Again South-West Coastal Cruise Track

On arrival back in Gosport we gave the boat a good wash, filled our water tanks, exchanged a propane cylinder and filled our diesel jerry cans.  Zen Again's ready for more!

Trust all's well where you are!

Saturday 12 September 2020

Poole to Newtown River

Hi everyone,

Following our passage from Weymouth to Studland Bay we spent two nights there.  Last Saturday we motored the short distance to Poole Harbour.  We spent most of the week there, did a short-stay in Poole Town Quay Marina to reprovision then yesterday sailed back to the Solent and into the Newtown River.

Poole Harbour is reputed to be the second largest natural harbour in the world, second only to Sydney Harbour.  However much of Poole Harbour is shallow.  We did a tour of the harbour before anchoring in in South Deep, south of Brownsea Island.

Here are our tracks in and near Poole Harbour...

Zen Again Tracks in Poole Harbour

Our initial tour of the harbour took us around the north side of Brownsea Island.  There are visitors moorings here but we didn't like the wash from the traffic.  So we motored around to the much quieter south side of Brownsea Island.  It's shallow but the channel is well marked.  We anchored in South Deep.  We liked it so much we stayed for five nights.

Entering Poole Harbour

Brownsea Island

Sunset in South Deep

Twilight in South Deep (looking East)

While Nicki worked from home Monday to Wednesday I worked on our boat electronics software.  See the preceding posts on SignalK.  We also did some chores including our laundry.  We love our Wonder Clean pressure washing machine.

Laundry day

South Deep Dawn

On Thursday we motored around to Poole Town Quay Marina for a short stay.  Before entering the marina we motored past the waterfront up to the first bridge and back.  A little like Annapolis's 'ego alley' except one side has the waterfront with many pubs and the other has the port and the Sunseeker yard.

Inspecting Poole Waterfront

Sunseeker Yard

In the marina it only took an hour to reprovision from the adjacent Tesco Metro, leaving us time for a sober pub lunch at The Jolly Sailor and a walk around the old town.  A lot of very old buildings and narrow side streets.  Then we motored back out to Studland Bay so as to allow departure for the Solent free of South Deep's tidal constraints.

The Jolly Sailor

Studland Bay Sunset

Yesterday we sailed from Studland Bay to the Newtown River in the Solent.  Winds have been very light recently and the afternoon offered the first decent breeze for several days.  We departed at 1100 in a light WSW breeze.  The breeze gradually built to 15 knots or so and we had a marvellous sail.

Here are the track and graphs...

Zen Again Track

Zen Again Graphs

Twas a downwind, 6 gybe passage.  Initially we had to work hard with boat speed less than 2 knots for a period.  Then the predicted wind came in and we got moving.  We had a nice view of the Needles as we approached Dolphin Bank and the Shingles.  From there we gybed NE toward North Channel.  It was fun sailing close along Hurst Beach with 2 knots of tide with us.

Departing Studland Bay

The Needles

In North Passage

Hurst Castle

Crossing the rip off Hurst Castle was fun.  We reached the approach to Newtown River rapidly with 1.5 knots of tide with us, and it was a neap tide.

In the Rip off Hirst Castle

Approaching Newtown River Mouth

The entrance to Newtown River is narrow but deep.  Inside it is quite shallow with varying depth.  It is quite well marked but care is necessary.  We found our Admiralty and Navionics charts good but our Garmin charts poor.  There are visitor's moorings and one or two were free.  We found a good spot to anchor.

Entering Newtown River

Newtown River Track

Newtown River Sunset

We had hoped to sail east to Brighton and Eastbourne this week but the light winds made that unattractive.  Maybe we'll do so in a week or two.  In the mean time we're enjoying Newtown Creek and may visit other parts of the Solent.

Trust all's well where you are!


Tuesday 8 September 2020

NMEA-2000 Data on BeagleBone Black using SignalK

 Hi everyone,

This is a technical post.  It is the second of two posts describing how we installed and setup software to capture, record and display data from our NMEA-2000 network.  The first post described how we did so on a Macbook laptop running Mac OS X.  This post describes how we moved the NMEA-2000 capture and recording onto a cheap, low-power BeagleBone Black (BBB) computer.

Updated to describe installation on both Debian 9 and Debian 10

Appended notes following several months use

24 hours at anchor in Poole Harbour
BeagleBone Black
(beaglebone.org photo)

The capture, recording and display of our NMEA-2000 data on a Macbook was a big step forward.  However it required the Macbook to be running.  This uses a lot of power.  We have two low-power BeagleBone computers aboard, one of which we use for SSBMinder to run a 24 hour schedule on our HF/SSB.  We decided to try SignalK and InfluxDB on the BBB. 

Here's how we did it, noting that we have an ActiSense NGT-1 NMEA-2000 to USB interface directly connected to the BBB.  If you follow in our footsteps you should replace 'ZenAgain' with your boat name, and our IP addresses to your own.  Needless to say, the BBB and Macbook are on an ethernet network and they have internet access during this installation process.

NOTE1: Commands were executed in a ssh session, in our case from our Macbook.  We connected as the default user 'debian' but used 'su' and 'sudo' for some commands.  This is shown below.

NOTE2: I'm NOT a Linux expert and made many mistakes along the way.  I believe what follows is correct but there may be errors.  Proceed with care and backup your BBB before starting!

NOTE3: An advantage of the BBB over the Raspberry Pi is it runs from 5.0V, not the weird 5.1V demanded of current Pis.  We use this power supply to provide 5V from ship's 12V power.

Making Room

The BBB has only 4GB internal storage.  Much of this is consumed by the Debian Linux distribution.  We ran Debian 9 'bone-debian-9.9-iot-armhf-2019-08-03' before updating to Debian 10 'bone-eMMC-flasher-debian-10.3-iot-armhf-2020-04-06-4gb'.  We knew we'd need more space for the InfluxDB database so we added a micro SD card.  We've used 4GB and 32GB SD cards.
  1. Insert the SD card in the BBB
  2. Connect to BBB as 'debian'
  3. Run 'su'
  4. Run 'lsblk' to identify SDcard (usually /dev/mmcblk0p1)
  5. Run 'fdisk /dev/mmcblk0'
  6.   'd' to delete current partition
  7.   'p' to print the partition table
  8.   'n' to create new partition, then <enter> to take defaults
  9.   't' then '83' to set partition type to Linux (ext4)
  10.   'w' to write
  11. Run 'mkfs.ext4 /dev/mmcblk0p1' to create file system on the new partition
  12. Run 'lsblk' to check partitions (see first image below)
  13. Use nano to add a line to /etc/fstab: '/dev/mmcblk0p1 /media/sdcard auto auto,async,rw,nofail 0 0'
  14. Run 'reboot now'
  15. Reconnect to BBB as 'debian'
  16. Run 'lsblk' to check partitions (see second image below)
  17. Run 'df' to view space available
  18. Run 'sudo chmod 777 /media/sdcard'
  19. Run 'sudo mkdir /media/sdcard/influxdb'
'lsblk' output before mounting

'lsblk' output after mounting

Disable Services

The BBB runs a number of services which clash with putting SignalK's web server on IP port 80 and/or compete for resources.  Here's what I disabled...
  1. Connect to BBB as 'debian'
  2. Run 'sudo systemctl disable cloud9.service'
  3. Run 'sudo systemctl disable gateone.service'
  4. Run 'sudo systemctl disable bonescript.service'
  5. Run 'sudo systemctl disable bonescript-autoscript.service'
  6. Run 'sudo systemctl disable bonescript.socket'

Remove cloud9

  1. Connect to BBB as 'debian'  
  2. Run 'sudo rm -R /opt/cloud9 /var/lib/cloud9'

Install Dependencies

This was the toughest part.  NodeJS is required by SignalK and it took me a while to realise the BBB had the wrong version installed.  Likewise 'dns_sd.h' was reported missing.  Hopefully the following is correct.  If not Google is your friend, as it was mine!

Debian 9
  1. Connect to BBB as 'debian'
  2. Run 'sudo apt-get install libavahi-compat-libdnssd-dev'
  3. Run 'curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -'
  4. Install specific version of NodeJS by running 'apt-get install nodejs=10.22.0-1nodesource1 -V'
Debian 10

  1. Connect to BBB as 'debian'
  2. Run 'sudo apt-get install software-properties-common'
  3. Run 'curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -'
  4. Run 'sudo apt-get install libavahi-compat-libdnssd-dev'

SignalK Installation and Setup

  1. Connect to BBB as 'debian'
  2. Run 'sudo npm install -g --unsafe-perm signalk-server'
  3. Run 'sudo signalk-server-setup'
  4.    Enter your boat's name and MMSI, and set IP Port to 80

Initial Run and ActiSense Connection Setup

  1. Connect to BBB as 'debian'
  2. Run 'signalk-server' to start the SignalK server
  3. In a remote browser (ie Macbook), open 'http://192.168.1.21' to access the server
  4. On the 'Server => Connections' page click on 'Add'
  5.   Set ID to 'actisense'
  6.   Set NMEA 2000 Source to 'Actisense NGT-1 (canboatjs)', noting the 'js'
  7.   Set Serial Port to '/dev/serial/by-id/usb-Actisense_NGT-1_...', modifying the '...' to suit your BBB
  8.   Accept defaults for the other fields and click 'Apply'
  9. On the 'Dashboard' page check the Stats show ActiSense data being received.
  10. On the 'Data Browser' page select 'Self' and check for data, noting the use of SI units.
The SignalK server starts automatically on boot.

Here are some screenshots, noting that some aren't from the BBB...

SignalK New Connection

SignalK Dashboard

SignalK Server Settings

SignalK Server Connections

OpenCPN SignalK Connection

Use OpenCPN running on our Macbook to test availability of the SignalK data.  OpenCPN support for SignalK began with version 5.2.  Here's our OpenCPN connection setup...

OpenCPN SignalK Connection

ActiSense Connection not working?

I had trouble using the ActiSense NGT-1 with canboatjs prior to SignalK Server version 1.34.0.  The error was indicated on the Dashboard page.  This simplest fix was...
  1. Connect to BBB as 'debian'
  2. On the 'Server => Connections' page click on the 'actisense' connection
  3.   Change NMEA 2000 Source to 'Actisense NGT-1 (canboat)'
  4.   Set Serial Port to 'dev/ttyUSB0'
  5. Run 'sudo reboot now' to reboot
  6. In a remote browser (ie Macbook), open 'http://192.168.1.21' to access the server
  7. On the 'Dashboard' page check the Stats show ActiSense data being received.

If the above fails try installing canboat separately.  Here's how that's done...
  1. Connect to BBB as 'debian'
  2. Run 'sudo apt install xsltproc' since canboat needs xsltproc
  3. Run 'git clone https://github.com/canboat/canboat' to download canboat source
  4. Run 'cd canboat'
  5. Run 'make' to built the executables from the downloaded source
  6. Run 'sudo cp rel/linux-armv7l/* /usr/local/bin' to move the executables for use
  7. Run 'which actisense-serial' to check the executable we need is ready for use
  8. Run 'nano ~/.signalk/settings.json' and replace its contents with the text illustrated below, replacing '/dev/ttyUSB0' with the correct string for your NGT-1
  9. Run 'sudo reboot now' to reboot
  10. In a remote browser (ie Macbook), open 'http://192.168.1.21' to access the server
  11. On the 'Dashboard' page check the Stats show ActiSense data being received.
SignalK ~/.signalk/settings.json for canboat

InfluxDB Installation

  1. Connect to BBB as 'debian'
  2. Run 'sudo apt install influxdb'
  3. Run 'which influxd'
Debian 10
  1. Connect to BBB as 'debian'
  2. Run 'sudo nano /lib/systemd/system/influxdb.service'
  3. Append ‘ media-sdcard.mount’ to After statement so influxdb service waits for SDcard to mount

InfluxDB Configuration

  1. Connect to BBB as 'debian'
  2. Run 'sudo chown influxdb:influxdb /media/sdcard/influxdb'
  3. Run 'sudo nano /etc/influxdb/influxdb.conf' and edit the three database pointers to suit the above locations.

InfluxDB Start

  1. Connect to BBB as 'debian'
  2. Run 'sudo systemctl unmask influxdb.service'
  3. Run 'sudo systemctl enable influxdb.service'
  4. Run 'sudo systemctl start influxdb'
The InfluxDB daemon will now start automatically on boot.

InfluxDB uses IP port 8086 to service client requests.  It doesn't provide a web page but browsing there is a handy way to see if InfluxDB is running.  Doing so produces a page with '404 page not found' text.

Another way to see if InfluxDB is running is to run 'ss -tlpn' which lists all ports on which the BBB is listening for traffic.

InfluxDB Database Creation

  1. Connect to BBB as 'debian'
  2. Run 'curl -X POST http://localhost:8086/query?q=CREATE+DATABASE+ZenAgain' to create influxdb database
  3. Run 'journalctl -u influxdb.service' to view the log

signalk-to-influxdb Installation

  1. In a remote browser (ie Mac), open 'http://192.168.1.21'
  2. Go to 'AppStore => Available' page, find the 'signalk-to-influxdb' entry and click on the download link on the right
  3. Go to 'AppStore => Installed' page and check 'signalk-to-influxdb' installed
  4. Connect to BBB as 'debian'
  5. Run 'sudo reboot' to reboot
  6. Back in the remote browser wait (several minutes) for the Server page to refresh then go to 'Server => Plugin Config' page, and click on 'Influx DB'
  7. On the page, tick the 'Enable' checkbox, enter 'ZenAgain' as the Database, then click on 'Submit' at the bottom
Here are some screenshots...

SignalK Server Plugin Config

SignalK Server Plugin Config InfluxDB

The BBB is now setup with SignalK and InfluxDB running.  Lastly we need to tell our Mac (or other machine running Grafana) to read data from the BBB's InfluxDB.

Grafana Setup Modification on Macbook

  1. Open Grafana in browser at 'http://localhost:3001'
  2. In 'Configuration => Data Sources' click 'Add Data Source' then 'Influx DB'
  3.   Set Name to 'InfluxDB-BBB' and switch Default on
  4.   Set HTTP URL to 'http://192.168.1.21:8086' (don't leave it greyed-out)
  5.   Set Influx DB Details Database to 'ZenAgain'
  6.   Set Influx DB Details user/password to 'debian/password'
  7.   Click 'Save & Test' and confirm all 'green'
  8. Open your Dashboards and check data is flowing from the BBB's database
Here are some screenshots...

Grafana Add Data Source (top of page)

Grafana Add Data Source (bottom of page)

Grafana with 2 Data Sources

It's worth noting that the Grafana Dashboards setup on the Macbook used the default Data Source for all their data.  Adding the BBB Data Source and making it the default brought the Dashboards to life immediately.  Very nice.

Overall Usage

We've been running SignalK and InfluxDB on our BBB for several months now, including for weeks at a time.  No unexplained (ie non user error) crashes and so far it has used only 8% of the 32GB SDcard.

Backup

Here's how I backup the InfluxDB databases and the BBB generally...
  1. Connect to BBB as 'debian'
  2. Run 'sudo systemctl disable signalk.socket'
  3. Run 'sudo systemctl disable signalk.service'
  4. Run 'sudo systemctl stop signalk.socket'
  5. Run 'sudo systemctl stop signalk.service'
  6. Run 'sudo systemctl stop influxdb'
  7. Run 'sudo tar -cvf /media/sdcard/backup/<date>_bbb_influxdb.tar /media/sdcard/influxdb'
  8. In a Terminal window on the Macbook run 'scp debian@bbb:/media/sdcard/backup/<date>_bbb_influxdb.tar .'
  9. Back on the BBB, run 'sudo umount /media/sdcard'
  10. Remove the InfluxDB SD card from the BBB
  11. Insert a backup SD card into the BBB
  12. Run 'sudo /opt/scripts/tools/eMMC/beaglebone-black-make-microSD-flasher-from-eMMC.sh'
  13. When the BBB powers down on completion of the backup, remove the backup SD card
  14. Insert the InfluxDB SD card into the BBB
  15. Power up the BBB
  16. Connect to the BBB as 'debian'
  17. Run 'df' to check /media/sdcard connected
  18. Run 'sudo systemctl enable signalk.service'
  19. Run 'sudo systemctl enable signalk.socket'
  20. Run 'sudo systemctl start signalk.service'
  21. In a browser on the Macbook check the Signal K Server and Grafana are functioning normally

Upgrading SignalK

I had problems upgrading SignalK from within the browser.  Instead I did this...
  1. Stop SignalK as described above (steps 1..3)
  2. Run 'sudo npm install -g --unsafe-perm signalk-server'
  3. While updating SignalK perhaps do the same for Debian generally... 
  4.   'sudo apt-get update'
  5.   'sudo apt-get upgrade'
  6. Run 'sudo reboot now'

Recent Steps

We now have SignalK and InfluxDB installed and tested on three Beagles.  Two BBBs (active and spare) plus a BeagleBone Black Wireless as a demo unit.  We transmit SignalK data to our Macbooks, iPads and iPhones using the WilhelmSK app.  We also feed wired SignalK-generated NMEA0183 to our autopilots.

Improving Usability and Reliability

Modify restart of SignalK service to simplify stopping/restarting for backups...
  1. Edit /etc/systemd/system/signalk.service, changing to 'Restart=on-failure'
Auto-reboot daily (below at 23:50) to stop /dev/mmcblk1p1 gradually filling to capacity...
  1. Use 'sudo crontab -e' to append '50  23 *   *   *     /sbin/reboot'
Backup InfluxDB database monthly and create new, to avoid BBB slowing to a crawl and losing data...

  1. sudo systemctl stop signalk.service
  2. sudo systemctl stop signalk.socket
  3. sudo systemctl stop influxdb
  4. cd /media/sdcard
  5. sudo tar -cvf ./backup/<year+month>_influxdb.tar ./influxdb
  6. sudo rm -rf influxdb/*
  7. sudo systemctl start influxdb
  8. curl -X POST http://localhost:8086/query?q=CREATE+DATABASE+ZenAgain
  9. sudo reboot