Documentation

MCP2515 CAN Bus Module with TJA1050 SPI Interface | ShillehTek Product Manual
Documentation / MCP2515 CAN Bus Module with TJA1050 SPI Interface | ShillehTek Product Manual

MCP2515 CAN Bus Module with TJA1050 SPI Interface | ShillehTek Product Manual

Overview

The MCP2515 + TJA1050 module gives any 5V Arduino, ESP32, or other microcontroller a fully isolated CAN bus 2.0B interface in a single small board. Combined, the two chips handle the SPI-to-CAN protocol conversion (MCP2515 controller) and the differential physical-layer transceiver (TJA1050) needed to talk on a CAN bus — the same bus used in every car built since the late 1990s, plus industrial automation, marine electronics, drones, and any kind of long-distance, multi-drop communication where reliability matters.

Use it to read OBD-II data from a car (engine RPM, vehicle speed, throttle position, fuel level, error codes), build a CAN-based home / industrial automation network, communicate between Arduinos over a 40-meter twisted-pair link, or interface with a CAN-equipped sensor or actuator. The 8 MHz crystal sets the CAN clock; the included 120 ohm jumper terminator can be enabled or disabled via a solder bridge.

The module supports CAN bit rates from 5 kbps up to 1 Mbps. Standard ID (11-bit) and extended ID (29-bit) frames are both handled. With the popular MCP_CAN Arduino library or pythonCAN on a Pi, sending and receiving CAN messages takes about 10 lines of code.

At a Glance

Controller IC
MCP2515 (SPI-to-CAN)
Transceiver IC
TJA1050
Crystal
8 MHz
Operating Voltage
5V
CAN Speed
Up to 1 Mbps
Termination
120 Ω jumper-selectable

Specifications

Parameter Value
Controller Microchip MCP2515 (SPI interface)
Transceiver NXP TJA1050
Crystal 8 MHz
Operating Voltage 5V (TJA1050 needs 5V; logic inputs are 5V)
CAN Standard CAN 2.0A and 2.0B (standard + extended frames)
CAN Bit Rate 5 kbps - 1 Mbps (configurable)
SPI Mode Mode 0 (CPOL=0, CPHA=0)
SPI Clock Up to 10 MHz
Termination 120 Ω (jumper-enabled)
Connector 2-pin screw terminal (CAN_H, CAN_L)
Pin Header 2×5 (10 pins) 2.54 mm
Operating Temperature -40°C to +85°C

Pinout Diagram

MCP2515 CAN bus module pinout showing the MCP2515 controller, TJA1050 transceiver, 8 MHz crystal, INT/SCK/SI/SO/CS/GND/VCC SPI header, CAN_H/CAN_L screw terminals, 120 ohm termination jumper, and power LED

Wiring Guide

Bus topology: CAN is a multi-drop bus — multiple nodes share a single twisted-pair cable. The two physical endpoints of the bus must each have a 120 Ω termination resistor; intermediate nodes leave it disabled. Most modules ship with the jumper enabled. For a 2-node test setup, leave both jumpers on. For a longer bus with 3+ nodes, only the two endpoints should terminate.

Arduino UNO / Mega 2560 SPI Connection

Module Arduino UNO Arduino Mega
VCC 5V 5V
GND GND GND
CS D10 D53
SO (MISO) D12 D50
SI (MOSI) D11 D51
SCK D13 D52
INT D2 (interrupt-capable) D2 / D3 / D18-21

CAN Bus Wiring (Between Modules)

Connect CAN_H to CAN_H and CAN_L to CAN_L between all modules on the bus. Use twisted-pair cable for noise immunity. The bus can be up to ~40 m at 1 Mbps and longer at lower speeds.

Module A Module B
CAN_H CAN_H
CAN_L CAN_L
120 Ω jumper: ENABLED 120 Ω jumper: ENABLED
Tip: The two grounds don't need to be connected for short runs, but for long runs (over a few meters) ground reference can drift. A separate ground wire (or a shielded cable with shield to ground) helps stability.

Code Examples

Send a CAN Message (Arduino, MCP_CAN library)

can_send.ino
#include <SPI.h>
#include <mcp_can.h>

MCP_CAN CAN(10);  // CS

void setup() {
  Serial.begin(115200);
  while (CAN.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) != CAN_OK) {
    Serial.println("CAN init fail; retrying");
    delay(100);
  }
  CAN.setMode(MCP_NORMAL);
  Serial.println("CAN init ok");
}

void loop() {
  unsigned char data[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0x00, 0x00};
  byte sndStat = CAN.sendMsgBuf(0x100, 0, 8, data);
  Serial.println(sndStat == CAN_OK ? "sent" : "fail");
  delay(1000);
}

Receive a CAN Message (Arduino, MCP_CAN library)

can_recv.ino
#include <SPI.h>
#include <mcp_can.h>

MCP_CAN CAN(10);  // CS

void setup() {
  Serial.begin(115200);
  while (CAN.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) != CAN_OK) {
    delay(100);
  }
  CAN.setMode(MCP_NORMAL);
}

void loop() {
  if (CAN_MSGAVAIL == CAN.checkReceive()) {
    long unsigned int rxId;
    unsigned char len, buf[8];
    CAN.readMsgBuf(&rxId, &len, buf);
    Serial.print("ID: 0x"); Serial.print(rxId, HEX);
    Serial.print("  data:");
    for (int i = 0; i < len; i++) {
      Serial.print(' '); Serial.print(buf[i], HEX);
    }
    Serial.println();
  }
}

Frequently Asked Questions

Why MCP_8MHZ? My module's crystal is 8 MHz, right?
Yes. The MCP2515 needs to know the crystal frequency to compute timing. Pass MCP_8MHZ to begin() for this module. Some other MCP2515 boards use 16 MHz crystals — check your board before assuming.
My CAN bus shows errors / no messages received.
Most likely a termination issue. CAN requires exactly two 120 Ω terminators — one at each end of the bus. Too many or too few causes problems. Also check H/L wiring (don't swap), verify both nodes use the same baud rate, and confirm both modules have power and are configured for the same CAN clock (8 MHz here).
Can I read OBD-II data from my car?
Yes — that's one of the main hobby uses. Connect to the OBD-II port (cars built after 2008 in the US use ISO 15765-4 / CAN at 250 or 500 kbps). Use a CAN OBD-II library (like arduino -OBD2) to send PID requests. Be careful: some vehicles have writable / dangerous CAN messages — never inject random data into a moving car's CAN bus.
What baud rate should I use?
125 kbps is the safest "default" for most low-bandwidth automation. 500 kbps is the most common automotive rate. 1 Mbps is fast but limits cable length to ~25 m. Always run all nodes on the bus at the same rate.
Can I use this with 3.3V boards (ESP32, Pi)?
The TJA1050 needs 5V, so don't power-replace VCC. The TJA1050 logic-side pins are 5V CMOS, so you need a level shifter on the SPI lines if your MCU is 3.3V. Some users replace the TJA1050 with an SN65HVD230 (3.3V CAN transceiver) on dedicated 3.3V CAN modules — or use a 3.3V CAN board designed for ESP32.
How long can the CAN bus be?
Approximate maximum bus length vs speed: 1 Mbps ≈ 40 m, 500 kbps ≈ 100 m, 250 kbps ≈ 250 m, 125 kbps ≈ 500 m, 50 kbps ≈ 1 km. Slower = longer. Use twisted-pair cable for best noise immunity.