An out-of-box Pi doesn't have CAN support.
This Project14 mini-project shows how you can give it a CAN bus with an .
The end result is a Pi with a physical CAN driver and the Linux CAN-utils software installed and ready to use.
Craig Peacock wrote the instructions to integrate several CAN breakout boards with the Pi.
I'm adding the Arduino MKR CAN Shield to that.
In the spirit of Project14, it's a very simple project. If you happen to own a CAN shield, you can play along.
All signals and voltages are available on the Pi's 40-pin connector.
I used the same Pi pins as Craig.
click to enlarge
Also beware that the MKR Canbus Shield has an error on labeling the Can H and Can L on the BOTTOM of the board.
They are reversed. They are correct on the top of the board (in micro letters).
If the Shield is an end node (first or last unit connected to your CAN bus), set the terminate switch on the shield towards the resistor symbol.
Linux CAN-utils Tools
I literally followed the steps of Craig's post. Do the same.
Follow the Driver Installation and CAN-util sections .
(not needed, because the overlay does it automatically: But first enable SPI interface with raspi-config).
I used a fresh Debian Buster Lite.
First enabled the driver for the MicroChip CAN controller by enabling an overlay.
Attention. The Arduino Shield has a 16 MHz crystal, so the oscillator attribute in the overlay string should be set to 16000000:
I tested if that was successful. dmesg reports a successful load:
Then I installed the CAN-utils package (check Craig's post for instructions).
I'm using the cansend and candump utilities of that package.
action video: hardware setup (with audio)
I used a MicroChip CAN Bus analyser (see links at the end of this project).
Ground, CAN Hi and CAN Lo of analyser and Shield are connected to each other (attention: wrongly labeled on the underside of the Shield).
Can Hi and CAN Lo wires should be twisted.
I then used both devices to exchange data and show the results. In both directions
action video: it works (no audio)
CAN Analyser Road Test
Poor man's CAN:
Make my own CAN Driver: