ESP32 Bit Pirate home

Recipe · Intermediate · CAN

Wire an MCP2515 CAN module

CAN mode configures the MCP2515 SPI bus and a compatible CANH/CANL bus connection.

CAN bus connected to an MCP2515 controller module.
Separate the SPI control wiring from the CANH/CANL bus connection.

Documented wiring roles

  • CS → fixed MCP2515 CS GPIO
  • SCK → configured SPI CLK
  • SI → configured SPI MOSI
  • SO → configured SPI MISO
  • GND → GND
  • CANH / CANL → compatible CAN bus

Configure CAN only after wiring

The implementation keeps the MCP2515 CS pin fixed and prompts for SCK, SI/MOSI, SO/MISO and bitrate. Match bitrate and termination to the authorized test bus.

Checks

  • Do not swap CANH and CANL.
  • Use a compatible, authorized CAN bus.
  • Check termination and bitrate before blaming the controller.

MCP2515 CAN wiring FAQ

What is the difference between MCP2515 SPI wiring and CAN bus wiring?

SPI connects the ESP32 Bit Pirate to the MCP2515 controller. CANH and CANL connect the transceiver side to the CAN bus. Both sides must be correct before status, sniff or send tests are meaningful.

Why does wiring look right but CAN status still shows errors?

CAN errors often come from bitrate mismatch, missing termination, swapped CANH and CANL, no other active node, or a module without a compatible transceiver. Check the bus before assuming the SPI side is broken.

Do I need termination for a small CAN bench setup?

Yes, a realistic CAN test bus normally needs proper termination at the bus ends. For a two-node bench, confirm the effective termination before testing receive or transmit behavior.