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
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.
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.
You need a device that bridges USB to the CAN-Bus physical layer.
can0) in Linux. It is open-source hardware.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.
NMEA 2000 is electrically compatible with CAN Bus, but the connectors differ.
This is where the magic happens. We will use Signal K as the translation layer.
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.
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.
sudo npm install -g signalk-serversignalk-serverhttp://localhost:3000).signalk-to-nmea2000.can0 interface (SocketCAN).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:
PyPilot acts as the "Brain". It calculates the required Rudder Angle or Heading.
steering.autopilot.active and steering.rudderAngle paths to NMEA 2000 PGNs.If you just want the boat to follow a route calculated by OpenCPN:
| 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 |
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+).