Unified CAN Library

I've written up a cross platform CAN library that builds on some of the excellent work out there done on individual CAN controllers. This library allows you to communicate with multiple types of CAN controllers using a consistent API, making CAN communications across development platforms easier through Arduino.

The idea behind this CAN library is to use a similar approach to Adafruit's Unified Sensor library by standardizing CAN function calls, frame structure, filters, masks, buffers, etc to be used with a wide variety of CAN controllers. This library currently supports the following controllers:

The library is available at https://github.com/McNeight/CAN_Library. If you use it, feel free to drop me a line.


I gave it a try, but I got "Your CPU & CAN controller are currently unsupported.". I have an MCP2515 connected to the SPI bus. Perhaps it did not see it. I can understand if it didn't recognize the CPU as it is embedded in an ESP8266. :)

FYI: Also, I got this message using Arduino 1.6.5: WARNING: Category '"Communication"' in library CAN_Library is not valid. Setting to 'Uncategorized'

So I tried this library with two Due’s and the attached MCP2515 board

I first tested all these 2515 CANBUS boards with UNO’s and the special 8 Mhz mcp2515 canbus library here:

which worked fine once I had my wiring straightened out.

I’m using the same canbus board (running at 3.3v) and cant seemt o get them to communicate. The datasheet for the mcp2515 and the attached transceiver says both can wrok at either 5v or 3.3v.

Now posting this, I’m wondering if it is the 8mhz crystal; that is causing the issue ?

be nice to get these cheap canbus boards working with the dues - and yes I know the due has canbus but it requires wiring up can transceivers and what’s the point ? Much easier and more robust just to use an external board.

Worst case, I offload all the canbus stuff to unos but be nice to get the due’s to work with this setup.

Anyone pulled this off ?

KOCHEVNIK the TJA1050 on the Niren MCP2515 CAM module uses 5V VCC. (4.75V min)

Neil has the unified library been updated to include the 8Mhz Niren MCP2515 board?

@Kochevnik did you managed to upload the examples files to the due?

I’m trying to use the niren mcp2515 can module with a due and I didn’t found a suitable library to do so.

Does anyone has an idea?

I have the same problem, it's impossible even to compile with the due and an external MCP2515. Didanybody find a solution? or an appropriate library?

Thank you very much in advance.

Hi, I am using MCP2515 breakout board having SPI interface. I’ve connected to CANOE tool using DB9 connector’s CAN_H and CAN_L to MCP2515 CAN_H and CAN_L. MCP2515 is also connected to NodeMCU. I am using seeed studio library. Data sent by CANOE is not received by NOdeMCU.

value returned by checkReceive() function is 4 i.e (CAN_NOMSG) and by sendMsgBuf(0x18FF043D, 1, 8, stmp) is 6 (CAN_GETTXBFTIMEOUT)


// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = D8;


void setup()


if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
Serial.println(“CAN BUS Shield init ok!”);
Serial.println(“CAN BUS Shield init fail”);
Serial.println(“Init CAN BUS Shield again”);

unsigned char stmp[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
void loop()
unsigned char len = 0;
unsigned char buf[8];
Serial.println(“send message status:”);
Serial.println(CAN.sendMsgBuf(0x18FF043D, 1, 8, stmp));
delay(1000); // send data per 100ms
Serial.println(“rcv message status:”);
if(CAN_MSGAVAIL == CAN.checkReceive()) // check if data coming

Serial.println(“recieve message status:”);
Serial.println(CAN.readMsgBuf(&len, buf)); // read data, len: data length, buf: data buf
unsigned char canId = CAN.getCanId();

Serial.println("get data from ID: ");

for(int i = 0; i<len; i++) // print the data

  • Serial.print("\t");*
  • }*
  • Serial.println();*
  • }*
    If any one tried please help me, thanks in advance.

Hi, When experimenting with the library I strugled to find a setting for the 8MHz board, Is there a setting in the LIB for using the 8MHz crystals ? I didn,t find it in the CAN_MCP2515.h or .cpp file.