MCP2515 CAN

A CAN bus interface module pairing Microchip's MCP2515 SPI CAN controller with a TJA1050 transceiver, for cars, robots and industrial networks.

  • CAN controllerCAN 2.0B, up to 1 Mb/s, standard and extended frames, 0 to 8 data bytes
  • Buffers and filters3 transmit buffers, 2 receive buffers, 6 × 29-bit filters, 2 × 29-bit masks
  • SPIUp to 10 MHz, modes 0,0 and 1,1
  • MCP2515 supply2.7 V to 5.5 V, 5 mA active typical
MCP2515 CAN, A CAN bus interface module pairing Microchip's MCP2515 SPI CAN controller with a TJA1050 transceiver, for cars, robots and industrial networks.
In short

The MCP2515 module connects a microcontroller to a CAN bus: Microchip's MCP2515 implements CAN 2.0B at up to 1 Mb/s behind a 10 MHz SPI port (Microchip DS20001801J, p. 1), and a TJA1050 transceiver drives the CANH and CANL wires from a 4.75 V to 5.25 V supply (Philips TJA1050 specification, p. 2). Because the transceiver needs 5 V and the MCP2515's SPI inputs then need 0.7 × VDD (3.5 V) (DS20001801J, p. 74), the module wires straight to an Uno but needs a level shifter on an ESP32 or a Pico. The autowp-mcp2515 library sends and receives frames.

CAN is the two-wire differential bus inside cars, e-bikes, 3D printers and industrial machines. The MCP2515 handles the protocol: it frames and checks messages, filters what to accept with six 29-bit filters and two masks, and buffers three outgoing and two incoming frames (Microchip DS20001801J, p. 1). The TJA1050 turns its logic signals into the CANH/CANL differential pair, rated for up to 1 Mbaud and at least 110 nodes on one bus (Philips TJA1050 specification, p. 2).

The common blue module has a 7-pin header printed INT, SCK, SI, SO, CS, GND and VCC, a screw terminal for H and L, a crystal for the MCP2515 (usually 8 MHz, read its marking) and a jumper that adds a 120 Ω termination resistor. Both chips run from the one VCC pin, and the TJA1050 needs 4.75 V to 5.25 V, so VCC is 5 V in practice.

With VCC at 5 V, the MCP2515's SPI inputs need 3.5 V to read a high and its SO output swings to about 5 V (DS20001801J, p. 74). A 5 V Uno connects directly. On an ESP32 or a Pico, put a level shifter on SCK, SI, CS and SO and slow the SPI clock to suit it. The ESP32 also has a built-in CAN controller (TWAI) that only needs a 3.3 V transceiver, a simpler route for ESP32 designs.

MCP2515 CAN pinout

tinkered.ai/components/mcp2515-canMCP2515 CANINTInterrupt (active low)SCKSPI SCKSISPI MOSISOSPI MISOCSSPI CS (active low)GNDGroundVCCSupplyHCANHLCANL
PinFunctionType
INTInterrupt (active low)VCC leveloutput
SCKSPI SCKHigh from 0.7 × VCCinput
SISPI MOSIHigh from 0.7 × VCCinput
SOSPI MISOVCC leveloutput
CSSPI CS (active low)High from 0.7 × VCCinput
GNDGroundpower in
VCCSupply5 V (TJA1050 needs 4.75 V to 5.25 V)power in
HCANHbidirectional
LCANLbidirectional

How to wire the MCP2515 CAN

Pin by pin, for the board you have.

MCP2515 CANArduino UnoNote
VCC5V
GNDGND
CSD10
SID11
SOD12
SCKD13
INTD2
H / LCANH / CANL of the busFit the 120 Ω jumper only if this module is at one end of the bus.
Design this circuit on an Arduino Uno

MCP2515 CAN code

Every example here compiles for its board.

Libraries: autowp/autowp-mcp2515
// MCP2515 CAN on Arduino Uno: wiring and a free simulation at https://www.tinkered.ai/components/mcp2515-can
// MCP2515 CAN module on an Arduino Uno: CS D10, SPI D11/D12/D13. 500 kbit/s, 8 MHz crystal.
// Sends a frame with ID 0x123 every second and prints every frame received.
#include <SPI.h>
#include <mcp2515.h>

MCP2515 mcp2515(10); // CS pin
struct can_frame rx;
unsigned long lastSend = 0;
uint8_t counter = 0;

void setup() {
  Serial.begin(115200);
  mcp2515.reset();
  mcp2515.setBitrate(CAN_500KBPS, MCP_8MHZ); // use MCP_16MHZ if the crystal reads 16.000
  mcp2515.setNormalMode();
  Serial.println(F("CAN ready at 500 kbit/s"));
}

void loop() {
  if (millis() - lastSend >= 1000) {
    lastSend = millis();
    struct can_frame tx;
    tx.can_id = 0x123;
    tx.can_dlc = 2;
    tx.data[0] = counter++;
    tx.data[1] = 0xAB;
    bool ok = mcp2515.sendMessage(&tx) == MCP2515::ERROR_OK;
    Serial.println(ok ? F("Sent 0x123") : F("Send failed (no other node acknowledging?)"));
  }
  if (mcp2515.readMessage(&rx) == MCP2515::ERROR_OK) {
    Serial.print(F("Received ID 0x"));
    Serial.print(rx.can_id, HEX);
    Serial.print(F(" data:"));
    for (uint8_t i = 0; i < rx.can_dlc; i++) {
      Serial.print(' ');
      Serial.print(rx.data[i], HEX);
    }
    Serial.println();
  }
}
Compiled for arduino:avr:uno on 2026-10-30

Before you wire it

Do
  • Run VCC at 5 V: the TJA1050 needs 4.75 V to 5.25 V (Philips TJA1050 specification, p. 2).
  • Match the library's clock setting to the crystal printed on the module (8.000 or 16.000 MHz) and use the same bit rate on every node.
  • Terminate the bus with 120 Ω at its two ends only, using the module's jumper where it sits at an end.
  • Level-shift SCK, SI, CS and SO on 3.3 V boards, and share ground with the bus's other nodes.
Don’t
  • Never connect the module's SO to an ESP32 or Pico pin directly when VCC is 5 V.
  • Never power the module from 3.3 V and expect the TJA1050 to meet its specification.
  • Never test with a single node: a CAN frame needs an acknowledgement from another node, so transmissions fail alone.
  • With VCC at 5 V the MCP2515 needs 0.7 × 5 V = 3.5 V on SCK, CS and SI (DS20001801J, p. 74), above a 3.3 V board's output, which is why the shifter is needed in both directions.
  • A BSS138 four-channel shifter passes SPI reliably at around 1 MHz; the autowp library takes the SPI clock as its second constructor argument.
  • INT goes low when a frame arrives; on a 5 V board wire it to an interrupt pin to avoid polling, on a 3.3 V board shift it down first or poll as these sketches do.
  • For an ESP32-only design, its built-in TWAI controller with a 3.3 V transceiver such as the SN65HVD230 avoids both the MCP2515 and level shifting.
  • Car OBD-II ports usually run CAN at 500 kbit/s on pins 6 (CANH) and 14 (CANL); listen-only mode avoids disturbing the vehicle while you experiment.

Specifications

CAN controller
CAN 2.0B, up to 1 Mb/s, standard and extended frames, 0 to 8 data bytesMicrochip MCP2515 DS20001801J, p. 1
Buffers and filters
3 transmit buffers, 2 receive buffers, 6 × 29-bit filters, 2 × 29-bit masksMicrochip MCP2515 DS20001801J, p. 1
SPI
Up to 10 MHz, modes 0,0 and 1,1Microchip MCP2515 DS20001801J, p. 1
MCP2515 supply
2.7 V to 5.5 V, 5 mA active typicalMicrochip MCP2515 DS20001801J, p. 1
MCP2515 logic levels
SCK, CS, SI high from 0.7 × VDD; SO high at VDD - 0.5 V or moreMicrochip MCP2515 DS20001801J, Table 13-1, p. 74
Transceiver supply (TJA1050)
4.75 V to 5.25 VPhilips TJA1050 High speed CAN transceiver, preliminary specification 1999 Sep 27, p. 2
Bus
Up to 1 Mbaud, at least 110 nodes; CANH and CANL withstand -27 V to +40 VPhilips TJA1050 specification, p. 2

From the Microchip MCP2515 Stand-Alone CAN Controller with SPI Interface, DS20001801J, published by Microchip Technology (MCP2515), NXP (TJA1050).

Common mistakes

  1. Wrong crystal setting

    Most of these modules carry an 8 MHz crystal, but code for 16 MHz shields uses MCP_16MHZ. The bit rate then comes out wrong by a factor of two and nothing is received. Read the crystal's marking and set MCP_8MHZ or MCP_16MHZ.

  2. Testing with one node

    CAN requires another node to acknowledge each frame. With only one module on the bus, sendMessage() reports errors forever. Use two modules, or a known working device on the bus.

  3. No termination, or too much

    A CAN bus needs 120 Ω at each end: about 60 Ω measured between CANH and CANL with power off. Fit the module's jumper only on the two end nodes.

  4. Wiring a 5 V module straight to an ESP32

    SO drives about 5 V back to the microcontroller and the MCP2515 needs 3.5 V highs on its inputs (DS20001801J, p. 74). Use a level shifter, or use the ESP32's own CAN controller with a 3.3 V transceiver.

MCP2515 CAN questions

Does the MCP2515 module work with an ESP32?

Yes, with a level shifter on SCK, SI, CS and SO, because the module runs at 5 V for its TJA1050 transceiver (Philips TJA1050 specification, p. 2). Many ESP32 projects skip the module and use the chip's built-in TWAI controller with a 3.3 V transceiver instead.

8 MHz or 16 MHz crystal?

Check the silver crystal on the board: most blue MCP2515 modules use 8 MHz, some shields 16 MHz. Pass the matching value (MCP_8MHZ or MCP_16MHZ) to setBitrate(), or the bit rate will be wrong.

What bit rate can the MCP2515 reach?

Up to 1 Mb/s for CAN 2.0B (Microchip DS20001801J, p. 1), which the TJA1050 also supports (TJA1050 specification, p. 2). Cars commonly use 500 kbit/s on the OBD-II port.

Which library should I use?

autowp-mcp2515 (arduino-mcp2515) is simple and handles bit rates, filters and modes. MCP_CAN by Cory Fowler is the other common choice and appears in many older tutorials.

Do I need the 120 Ω jumper?

Only on the two nodes at the physical ends of the bus. For a two-module bench test, fit it on both; in a car the bus is already terminated, so leave it off.

Build something with the MCP2515 CAN

  • OBD-II data logger

    Read engine RPM and speed from a car's CAN bus.

    Build this
  • Two-node CAN demo

    A button on one board lights an LED on another over CAN.

    Build this
For AI assistants

This page as plain Markdown, for ChatGPT, Claude or your own agent. /components/mcp2515-can.md

What will you build with it?