CANBUS adapter for the Raspberry Pi

Similar projects worth following
This is an electrically isolated CANBUS adapter for your Raspberry Pi. Even if you screw up the connections somehow, nothing will be damaged. It also fits within the normal Raspberry Pi footprint, meaning that you can use it with most enclosures.

The board is designed with KiCAD

What is it?

Here you'll find the hardware design files for a CAN controller for the Raspberry Pi SBC.

It is designed to be easy to use. The CAN transceiver keeps the RPi and the CANPi elctrically isolated, so you do not need to worry about voltage levels. All you need to do is connect the CAN signals and a voltage supply @ 6-25V DC, which usually can be shared with the device you want to communicate with. The power input is reverse polarity protected.

Note that while the CAN transceiver is rated for up to 5000V isolation, the board layout most definitely is not! Voltages up to 25V is no problem though.

If you just want the PCB, it can be ordered from here:

How do I use it?

When your Raspberry Pi has been properly setup, you will have access to a /dev/canX interface. Through the magic of socketcan, this works a lot like a network interface.

Follow these instructions to configure your RPi: . The hardware used in those instructions is a bit different, but the CAN controller and the interface to the RPi is the same so there is no difference in practice.

  • 1 × Raspberry Pi Single-board computer running Linux
  • 1 × MCP2515 CAN Controller with SPI interface
  • 1 × ADM3054 Isolated CAN transceiver
  • 1 × BA05FP Voltage regulator

  • CANPi Hello World!

    RasmusB03/14/2014 at 13:39 0 comments

    I haven't had time to properly test my CAN adapter for the Raspberry Pi until now. In the picture the CANPi adapter is on the Raspberry Pi, and it is talking to the purple PCB in the middle of the picture. The red Arduino shield is only used to interconnect everything for this quick test.

  • CANPi v1.1

    RasmusB03/14/2014 at 13:38 0 comments

    I got the latest revision PCB:s from today. This time, I also ordered a laser-cut mylar stencil from I'm not planning on building lots of these, but I wanted to get more familiar with improvising solder paste printing at home.

    My kludged together stenciling rig looks awful, but it worked well enough for a single board. The coverage was a bit uneven on some of the larger pads, but my poor squeegeeing technique is probably the cause of that.

    After shielding my plastic vice using kitchen aluminum foil and kapton tape, I used my hot-air rework station to reflow the solder paste. The components self-aligned as expected, and the circuit board came out pretty good!

    Using a solder paste stencil was overkill for this project, but I thought it would be fun to try before i really need to use one :) By doing this, I realized that I need to come up with a more proper way to hold the stencil and PCB in place.

    I taped a few circuit boards together for support. Looks ugly but worked fine.

    The top pads were unevenly covered, but I felt there was enough solder paste on all pads.

    The components have been placed. R2, R3 and C6 are left unpopulated on this board.

    After reflowing with a hot air rework station

    Careful measurements pays off. The new board fits perfectly within the RaspberryPi footprint.

    The new board fits perfectly in an unmodified enclosure.

  • v1.0 is always easy to recognize

    RasmusB03/14/2014 at 13:34 0 comments

    This is how you recognize a true V1.0 PCB. Not only sloppy soldering, but also green wiring and kapton tape on the board ;)

    Well it doesn't have to look good as long as it is working! :D Now I know what needs doing to V1.1.

    On a related note, using 0.1mm magnet wire (that's just under 4 mil for anyone in the unenlightened non-metric part of the world) is probably overkill for this job but that was all I had at home.

  • My first add-on board for the Raspberry Pi

    RasmusB03/14/2014 at 13:31 0 comments

    This is a CAN interface, using an MCP2515 controller and an ADM3054 transceiver. The CAN transceiver is insulated from the controller and has its own voltage regulator. Input power can be anything between 6-25V DC and has reverse polarity protection.

    Also, having separate power supplies not only protects the Raspi, but also solves the problem of interfacing a 5V transceiver with the 3.3V system.

    The next part is getting the kernel drivers working. Not my thing really, I prefer soldering ;)

View all 4 project logs

View all 4 instructions

Enjoy this project?



Donna.W wrote 09/18/2017 at 17:05 point

Why did you pick a series resonant crystal (which the ATS160SM-1 is as per manufacturer's datasheet) instead of parallel resonant??  The configuration is clearly parallel, given how you have the loading capacitors tied.  And, the MCP2515 needs parallel resonant -- in fact, the MCP2515 datasheets specifically says not to use series resonant part as it will cause the frequency to be out-of-spec (see 8.0 in the datasheet).

Was this a part's specification/selection error?  Or did you intentionally pick a series resonant crystal for a reason?

  Are you sure? yes | no

WmMich wrote 07/21/2016 at 04:11 point

I've reworked my boards with C7 as 0.33uf and C5 as 22uf. All seems to be working nicely at 125Kbps and 1Mbps.  I agree with K.C. Lee that a tantalum for C5 is the way to go. Thanks again RasmusB for sharing!

  Are you sure? yes | no

WmMich wrote 07/18/2016 at 01:47 point

Thanks for making your PCBs and code available on OSH park and GIT hub. I've just completed testing the CANPi V1.1 on a RPI 2 and its working great!  I wanted to let you know that I did run into a problem. Initially, CAN messages were intermittently being dropped, and the bus didn't act solid even at 125Kbps. I discovered that the 5V supply from U3 had a lot of AC noise on the output. The datasheet for the BA05FP regulator suggested that the input capacitor, C7, should be 0.33uf and the output capacitor, C5, should be 22uf or oscillation may occur. I made a quick change of the output capacitor (47uf), and the AC noise went away. The CAN bus is rock solid now. I'm ordering parts to replace C5 and C7 and I'll let you know how it goes. I thought this may be helpful if anyone else is seeing intermittent problems.

  Are you sure? yes | no

RasmusB wrote 07/18/2016 at 08:36 point

Thank you, that is very good to know! I haven't experienced that myself, but the data sheets usually suggest values for a reason :)

What did you use for a power supply. How much ripple did you get?

  Are you sure? yes | no

WmMich wrote 07/19/2016 at 00:16 point

The power supply I'm using is a adjustable bench supply that has good regulation. I set the input voltage to 10V and was seeing about 2 to 3V of ripple on the 5V output. The interesting thing is the CANPi module was mostly working like that!  In my test setup, I was noticing a high number of retransmits (20 to 30%) where I would expect none over two feet cable at 125Kbps between the RPI and my CAN MCU board. After changing C5, the retransmit rate dropped to 0%.

  Are you sure? yes | no

K.C. Lee wrote 07/18/2016 at 09:22 point

In general when the datasheet only mention tantalum or electrolytic caps or bulk decoupling, do not try to use ceramic caps blindly without adding in series resistance.  These parts are designed well before large values MLCC has been invented and as such will have stability issues because of their ultra low ESR.

A regulator relies on feedback to work and if you mess up the  feedfback, they get unstable. See here for the math behind that.

Always make sure they say the part is recommended with ceramic caps.  Parts that were designed in the last 10+years do that.  Your datsheet only mentioned tantalum cap, so you'll need to increase ESR by adding a series resistor in about 1 ohm range.

See bottom of my project log for the before and after waveform by adding a 1 ohm series resistor to the ceramic cap.  

tl;dr ceramic cap with generic 1117 (also very old part) has saw tooth output.  With 1 ohms series resistor added to increase the ESR, I get DC.  I knew ahead of time, so I had the footprint for it.  I was just curios to see what would happen.

Easy way for adding the cap in rework is to rotate the cap by 90 degrees so that you can solder in the resistor on the other pad and solder bridge the two unconnected side together.

  Are you sure? yes | no

WmMich wrote 07/19/2016 at 00:19 point

Thanks for the information and the rework tip.  I'm waiting on parts from Digikey for the final rework. The quick fix with the 47uf capacitor as C5 will get me going until then.

  Are you sure? yes | no

Andrey wrote 01/15/2016 at 18:27 point

Hi, would anyone have mouser part numbers for the connectors? If not, is there anywhere that I can buy complete kits or fully assembled boards?

  Are you sure? yes | no

RasmusB wrote 01/16/2016 at 17:16 point

Hello Andrey. No kits available I'm afraid.
The green terminal connector is Mouser pn 651-1725672

The cheapest option for the connector to the RPi is pn 517-929852-01-13-RB

I added these to the part list that you can find under the Build Instructions. Good luck :)

  Are you sure? yes | no

Jetson wrote 01/05/2016 at 16:26 point

Thanks very much for making this available!

Could you recommend a capacitor for C6? On other schematics a 4.7nF was used here, but the one I got from mouser was too big.

  Are you sure? yes | no

RasmusB wrote 01/05/2016 at 17:32 point

The purpose of C6 is to filter out high-frequency noise from the data bus. I haven't added a specific value since it depends on what data rate you will be using. 4.7nF will work for signal rates up to 1Mbit, which is the maximum speed. If you have problems with noise corrupting your data you can slow down the signal rate and increase the size of C6 to make the filtering a bit more aggressive.

There is a formula for calculating a suitable capacitor value in the section "Split termination" in this appnote: .

That said, you can probably get away without using C6 at all, as long as you aren't running your cables right next to the microwave oven or something like that... :)

  Are you sure? yes | no

Hey_Allen wrote 10/09/2015 at 16:56 point

The LCD board appears to only use the two I2C pins (#3 and #5) next to pin 1 on the expansion header.
From what I'm able to see in your pictures and the design renders on OSH Park, they don't appear to be connected to anything, so I'm going to have to give it a try and test my luck.
Hopefully my novice attempts at programming will be sufficient to get the job done, eventually!

Thanks again for sharing your work here.

  Are you sure? yes | no

RasmusB wrote 10/09/2015 at 17:10 point

Ok, should be OK then from a hardware point of view :) Good luck!

  Are you sure? yes | no

Hey_Allen wrote 10/08/2015 at 23:16 point

I have a quick question for you on this project, before I order a board from OSH Park.

Will this play nicely stacked under an Adafruit RGB LCD+Keypad board?  

The reasonI ask is that I'm looking to use it in a car to monitor and display engine data, and was hoping to combine the two, and use the RGB backlight to indicate alert and fault conditions.

Thanks for sharing, regardless!

  Are you sure? yes | no

RasmusB wrote 10/09/2015 at 06:40 point


Sorry but I'm not familiar with that LCD board. If i were you, I would start by comparing the schematics and see if the two boards are using the same GPIO as SPI chip select. If that's the case, you could always download my source files and adapt the design to make it work :)

  Are you sure? yes | no

MByD wrote 04/08/2015 at 18:51 point

Seems great. I was about to build one my self, but I found yours first, which is great. Now I'm waiting for my CANPi boards to arrive from OSH Park.

Note for RPi 2 users:

While trying to work with the Raspberry Pi 2 I couldn't find appropriate kernel modules, but after updating the kernel (sudo rpi-update) to 3.18.11-v7 and modifying /boot/config.txt as described here: the can interface was up and running (I still don't have the CANPi so I used SparkFun's CAN shield for arduino)

Thanks :)

  Are you sure? yes | no

RasmusB wrote 04/09/2015 at 06:56 point

Thank you for the updated instructions! Please let me know how the CANPi works out for you :)

  Are you sure? yes | no

MByD wrote 04/09/2015 at 07:16 point

Thank you :) Another thing I had in mind, if you add jumpers to select the SPI SS and the INT pins, you'll be able to connect two CANPi's on top of each other as two SPI devs. This can be very handy for performing CAN in the middle (or) when investigating what messages are sent by a specific ECU.

  Are you sure? yes | no

jengeltx wrote 01/09/2015 at 19:27 point

If you'd like to purchase from Mouser, I put most of the components in an EZ-Buy project.

I left out the connectors. Please let me know if I made any errors.

Thanks for the project, RasmusB!

  Are you sure? yes | no

RasmusB wrote 01/09/2015 at 19:47 point

That's great, thank you! :)

  Are you sure? yes | no

MByD wrote 04/29/2015 at 23:10 point

I used your list to order from mouser and had the boards assembled without any problems. thanks!

  Are you sure? yes | no

jenskaa wrote 10/23/2014 at 19:56 point
What is the P-channel FET doing?

  Are you sure? yes | no

RasmusB wrote 10/23/2014 at 20:51 point
That is the input voltage reverse polarity protection. This video explains the concept pretty well :)

  Are you sure? yes | no

jenskaa wrote 10/26/2014 at 19:54 point
Tnx for clarifying, neat trick.
But in this circuit, I think a rectifier could have done the job, we don't care about small voltage drop since we need to reduce the voltage to 5v anyway.

  Are you sure? yes | no

Reuben wrote 09/27/2014 at 06:36 point
Would you be able to upload a BOM? The schematic only shows component values (not packages), and I'm not really familiar enough with Kicad to extract that info from it.

  Are you sure? yes | no

RasmusB wrote 09/27/2014 at 10:15 point
Hi Reuben! Thank you for noticing the missing BOM. I hade updated the release on GitHub. Just download the zip file again and this time you'll find "CANPi-BOM.csv" included.

The BOM is generated from the board layout program in KiCAD. Look under "File" / "Fabrication outputs" / "BOM file" if you want to generate a BOM for your own projects in the future :)

  Are you sure? yes | no

Henrik Alexandersson wrote 03/09/2014 at 20:58 point
Looks promising, is it possible to share schematics and linux setup?

  Are you sure? yes | no

RasmusB wrote 03/14/2014 at 07:17 point
Yes, that will be here shortly. I just haven't had the time to update this page yet. :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates