Table of Contents

Installing and Configuring MacArthur HAT on Raspberry Pi with NMEA 2000 and Signal K

The MacArthur HAT (Hardware Attached on Top) is a specialized expansion board designed for the Raspberry Pi, primarily used in marine and outdoor applications. It integrates various sensors, including GPS, 9-axis IMU (accelerometer, gyroscope, and magnetometer), barometer, and temperature sensors. This HAT enables the Raspberry Pi to collect comprehensive environmental and navigational data, making it ideal for marine electronics projects, weather stations, and IoT applications. Its compatibility with NMEA 2000 networks and Signal K platforms enhances its utility in modern marine systems, allowing easy integration with other onboard electronics and data-sharing capabilities.

Prerequisites

Step 1: Prepare the Raspberry Pi

  1. Download and install the latest Raspberry Pi OS (previously called Raspbian) on your MicroSD card.
  2. Insert the MicroSD card into the Raspberry Pi.
  3. Connect the Raspberry Pi to your network via Ethernet or Wi-Fi.
  4. Power on the Raspberry Pi.

Step 2: Install the MacArthur HAT

  1. Power off the Raspberry Pi.
  2. Carefully attach the MacArthur HAT to the GPIO pins on the Raspberry Pi.
  3. Secure the HAT with standoffs if provided.

Step 3: Enable I2C Interface

  1. Power on the Raspberry Pi and open a terminal.
  2. Run sudo raspi-config.
  3. Navigate to “Interfacing Options” > “I2C” and enable it.
  4. Reboot the Raspberry Pi: sudo reboot.

Step 4: Install Required Software

  1. Update your system:
sudo apt update
sudo apt upgrade -y
  1. Install necessary packages:
sudo apt install -y git cmake build-essential libgps-dev gpsd gpsd-clients python3-pip
  1. Install the MacArthur HAT Python library:
sudo pip3 install macarthur-hat

Step 5: Configure the MacArthur HAT

  1. Create a new Python script to test the HAT:
nano ~/test_macarthur.py
  1. Add the following content:
from macarthur_hat import MacArthurHAT
import time
 
hat = MacArthurHAT()
while True:
    print(hat.read_all())
    time.sleep(1)
  1. Run the script to test the HAT:
python3 ~/test_macarthur.py

Step 6: Set Up NMEA 2000 Interface

  1. Connect your NMEA 2000 to USB adapter to the Raspberry Pi.
  1. Install the NMEA 2000 library:
sudo pip3 install pycanboat
  1. Create a new Python script for NMEA 2000 data:
nano ~/nmea2000_reader.py
  1. Add the following content:
import can
from pycanboat import PGNs
 
bus = can.interface.Bus(channel='can0', bustype='socketcan')
pgns = PGNs()
 
for msg in bus:
    decoded = pgns.decode(msg)
    if decoded:
        print(decoded)
  1. Run the script to test NMEA 2000 data reception:
python3 ~/nmea2000_reader.py

Step 7: Install and Configure Signal K

  1. Install Node.js and npm:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install -y nodejs
  1. Install Signal K:
sudo npm install -g signalk-server
  1. Create a new Signal K configuration:
signalk-server-setup
  1. Start the Signal K server:
signalk-server

Step 8: Connect MacArthur HAT and NMEA 2000

Open a web browser and navigate to

Go to Server > Plugin Config.

Install and enable the following plugins:

signalk-macarthur-hat signalk-canboat-parser Configure the plugins:

For signalk-macarthur-hat, set the update interval and select the sensors you want to use.
For signalk-canboat-parser, set the NMEA 2000 interface (usually /dev/ttyUSB0 for Actisense NGT-1).

Restart the Signal K server:

sudo systemctl restart signalk.service

Step 9: Verify the Setup

Navigate to your web browser.