July 08, 2024

Waveshare CAN hat with Signal K & OpenPlotter

Updated 2024-07-08

To get information from the NMEA 2000(N2K) network, to the RPi, I have been using Actisense NGT-1, for a long time, and later also the Yacht Devices YDWG 02 but now it was time for a Raspberry Pi(RPi) CAN hat(CH) from Waveshare(WS). WS have 3 different models but I picked the 2 channel isolated one.

It's recommended to use an isolated one which also is demanded for those interfaces which can be approved by the N2K group.

Introduction
Wiki
There is a very nice Wiki for the hat but will do a short and simple install instruction here with updated info matching a connection to a N2K network.

Terminating resistors
A N2K network have 2 terminating resistors at the end of the network. To confirm this, measure that you have around 60 Ohms between the white/blue, (CAN +/-, H/L), cables when no supply voltage is applied. If your  network miss a terminator, and the CH is at the end of the network, you can set the jumper in ON position otherwise in OFF position. Check picture above.

Logic level
The RPi GPIO pins, connecting the CH, have a logic level of 3,3 VDC so place the jumper accordingly. Check picture above.

Cabling
Connect, CAN0, to a NMEA 2000/SeaTalk NG network with a standard cable

CAN +/H => White
CAN -/L => Blue
Ground => Black

Installing
Mount the CH to the RPi and power up.
Enable SPI interface via "sudo raspi-config"

Add device configuration with "sudo nano /boot/firmware/config.txt
(Before RPi OS Bookworm "sudo nano /boot/config.txt")
and add 

# Waveshare CAN hat
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=23
# dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=25

I'm just using one channel so the third row is just a comment.
After a "sudo reboot now" check that the CH is recognized with
 
dmesg | grep spi

initialize the CH with 

sudo ip link set can0 up type can bitrate 250000
sudo ip link set can0 txqueuelen 65536


Confirm with "ip link

Testing
OpenPlotter
Check the documentation at OpenPlotter.

Signal K
In Signal K "Server => Data Connections => Add" and use info from the picture, end with clicking on "Apply", restart SK and then check with "Data Browser" if you succeeded.

As seen in the picture a filter is added for PGN 130311 which is due to that I have a Tri-ducer which have a defect water temperature sensor.

Other
At the CH Wiki there are some other methods.

Final settings
To keep the settings at reboot we have to edit/create a file with "sudo nano /etc/network/interfaces.d/can0and add the following

auto can0
iface can0 can static
bitrate 250000
post-up /sbin/ip link set can0 txqueuelen 65536

Restart and check that it's working.

No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !