Here is the solution presented in a portable HTML format. You can save this as an `.html` file (e.g., `boat-autopilot.html`) and open it in any browser. ```html Linux Autopilot for Yamaha HARMO

Project: Linux Autopilot for Yamaha HARMO

Goal: Control a Yamaha HARMO electric drive via NMEA 2000 using a Linux computer and Open Source software (Signal K / PyPilot) with a focus on low cost and high reliability.

Important Note on HARMO: The Yamaha HARMO system is a sophisticated drive-by-wire system. While it utilizes NMEA 2000, Yamaha sometimes utilizes proprietary PGNs (Parameter Group Numbers). Successful integration depends on the Linux stack's ability to send standard "Heading/Track Control" messages (PGN 127252) that the HARMO ECU accepts.

The Cheapest Reliable Solution: SocketCAN

The absolute cheapest way to interface a Linux computer with NMEA 2000 is to use a generic USB-to-CAN adapter supported by the Linux kernel's SocketCAN subsystem. This avoids expensive proprietary gateways.

1. Hardware Interface

You need a device that bridges USB to the CAN-Bus physical layer.

Recommended Device: CANable / CANable Pro

Alternative: Any adapter using the PCAN-USB driver (Peak System clones) or Lawicel protocol. Avoid cheap ELM327 OBD2 scanners; they are too slow for autopilot control loops.

2. Cabling (DIY)

NMEA 2000 is electrically compatible with CAN Bus, but the connectors differ.

3. Software Stack

This is where the magic happens. We will use Signal K as the translation layer.

Step 3.1: Configure Linux Network

Plug in the USB-CAN adapter. Check if it is recognized:

ip link show

You should see an interface like can0. Set the bitrate (NMEA 2000 runs at 250kbps):

sudo ip link set can0 up type can bitrate 250000

Tip: Add this command to your rc.local or systemd startup script so it runs on boot.

Step 3.2: Install Signal K Server

Signal K is the modern standard for marine data on Linux. It handles the heavy lifting of converting NMEA 2000 (binary) to JSON and vice versa.

  1. Install Node.js on your Linux computer.
  2. Install Signal K Server: sudo npm install -g signalk-server
  3. Run the server: signalk-server

Step 3.3: Enable the NMEA 2000 Plugin

  1. Open the Signal K dashboard in your browser (usually http://localhost:3000).
  2. Go to Appstore -> Install signalk-to-nmea2000.
  3. Go to Settings -> Plugin Config.
  4. Enable the plugin and ensure it is linked to your can0 interface (SocketCAN).

4. Autopilot Control Logic (PyPilot)

PyPilot is a fantastic open-source autopilot, but it is typically designed to control a servo motor via a motor controller.

Since you have a HARMO, you do not need a servo; you need to send data commands. You have two paths here:

Path A: PyPilot + Signal K (Recommended)

PyPilot acts as the "Brain". It calculates the required Rudder Angle or Heading.

Path B: OpenCPN (Simpler Navigation)

If you just want the boat to follow a route calculated by OpenCPN:

The "Cheapest Reliable" Shopping List

Item Est. Cost
CANable USB Adapter (USB-CAN) $30 USD
NMEA 2000 Drop Cable (to hack) $15 USD
Linux Computer (You already have this) $0
Total ~$45 USD

Why this is better than serial converters

Cheap serial converters (like NGT-1 clones) often buffer data too slowly, causing lag in the autopilot loop. SocketCAN puts the CAN interface directly into the Linux networking stack, providing the lowest possible latency and high reliability for a fraction of the cost of a commercial gateway like the Actisense NGT-1 ($300+).

```