Arduino – CAN BUS Communication

In this tutorial I am going to show you how to interface the MCP2515 CAN Bus Controller with an Arduino and how to communicate between two Arduinos via CAN BUS.

This tutorial can be a good kickstart for the future development of an individual CAN writer or reader to use it in different applications (car CAN Bus sniffer, connection to an equipment control network, among others).

Parts Required

MCP2515 Can Controller + TJA1050 Can Transceiver

The MCP2515 CAN Bus Controller it’s an IC that supports CAN Protocol version 2.0 and can be used for communication at 1Mbps.

Module used in this project.
U1 – TJA1050
U2 – MCP2515

This particular module is based on the MCP2515 CAN Controller IC and the TJA1050 CAN Transceiver IC. The MCP2515 IC is a standalone CAN Controller and has an integrated SPI Interface for communication with microcontrollers.

MCP2515 IC is the main controller that internally consists of three main subcomponents: The CAN Module (responsible for transmitting and receiving messages on the CAN Bus), the Control Logic (handles the setup and operation of the MCP2515 by interfacing all the blocks) and the SPI Block (responsible for the SPI communication interface).

The TJA1050 IC acts as an interface between the MCP2515 CAN Controller IC and the Physical CAN Bus. Since it acts as an interface between MCP2515 CAN Controller and the physical CAN Bus, this IC is responsible for taking the data from the controller and relaying it on to the bus.


Arduino PinCAN Board Pin
Pinout Arduino <-> Can Board
CAN Board 1 PinCAN Board 2 Pin
Pinout Can Board 1 <-> Can Board 2
Schematic circuit.
Real project circuit.

One Arduino Uno and one Arduino Micro were used in this project, but you can use the version of the Arduino that you have, as long as the connections for MISO, MOSI, CS and SCK are fulfilled.


It is necessary to install a library for the MCP2515 Module. In this project we used this particular one. Here is a guide to install .zip libraries.

Transmitter Code


struct can_frame canMsg1;
struct can_frame canMsg2;
MCP2515 mcp2515(10);

void setup() {
  canMsg1.can_id  = 0x0F6;
  canMsg1.can_dlc = 8;[0] = 0x8E;[1] = 0x87;[2] = 0x32;[3] = 0xFA;[4] = 0x26;[5] = 0x8E;[6] = 0xBE;[7] = 0x86;
  Serial.println("Example: Write to CAN");

void loop() {
  Serial.println("Messages sent");

Receiver Code


struct can_frame canMsg;
MCP2515 mcp2515(10);

void setup() {
  Serial.println("------- CAN Read ----------");
  Serial.println("ID  DLC   DATA");


void loop() {
  if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK) {
    Serial.print(canMsg.can_id, HEX); // print ID
    Serial.print(" "); 
    Serial.print(canMsg.can_dlc, HEX); // print DLC
    Serial.print(" ");

    for (int i = 0; i


Here we are visualizing the data in decimal format, but if you want to see it in hexadecimal, change DEC to HEX in line 29 of the receiver code.






Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!

Hello! We have noticed you are using an ad blocker. Our website is funded by advertising which allows you to access all our content for free. By disabling your ad blocker, you are contributing to the sustainability of our project and ensuring we continue to provide high-quality, useful tutorials. We appreciate your support!