Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use Arduino Can-Bus Shield: Examples, Pinouts, and Specs

Image of Arduino Can-Bus Shield
Cirkit Designer LogoDesign with Arduino Can-Bus Shield in Cirkit Designer

Introduction

The Arduino CAN-Bus Shield (Manufacturer Part ID: DEV-10039) by SparkFun Electronics is a versatile shield designed to enable Arduino boards to communicate using the Controller Area Network (CAN) protocol. CAN is a robust communication standard widely used in automotive, industrial, and embedded systems for reliable data exchange between microcontrollers and devices.

This shield is ideal for applications such as:

  • Automotive diagnostics and data logging
  • Industrial automation and control systems
  • Robotics and sensor networks
  • Communication between multiple microcontrollers

The shield is built around the MCP2515 CAN controller and MCP2551 CAN transceiver, providing a complete solution for CAN communication.


Explore Projects Built with Arduino Can-Bus Shield

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino Sensor Shield with I2C LCD and Bluetooth Interface
Image of wallE: A project utilizing Arduino Can-Bus Shield in a practical application
This circuit features an Arduino Sensor Shield v5.0 interfaced with an I2C LCD Display and an HC-05 Bluetooth Module. The LCD Display is connected for power, ground, and I2C communication, allowing it to display data or messages. The HC-05 Bluetooth Module is wired for serial communication with the Arduino Sensor Shield, enabling wireless data exchange with other Bluetooth-enabled devices.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Sensor Shield-Based Smart Home Monitoring System with Bluetooth and I2C LCD
Image of Proyecto final: A project utilizing Arduino Can-Bus Shield in a practical application
This circuit is an environmental monitoring system using an Arduino Sensor Shield. It includes sensors for gas (MQ-2), light (LDR), and temperature (DS18B20), and features a 16x2 I2C LCD for display, an HC-05 Bluetooth module for wireless communication, and a fan motor, buzzer, and LEDs for alert mechanisms.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO Bluetooth-Controlled Robotic Car with Ultrasonic Distance Sensing
Image of Arduino Robot With Bluetooth Controller: A project utilizing Arduino Can-Bus Shield in a practical application
This circuit is a Bluetooth-controlled robotic vehicle. It uses an Arduino UNO to interface with an L293D motor driver shield, which controls four DC motors for movement. The vehicle's direction is controlled via commands received from an HC-05 Bluetooth module, and it also includes an HC-SR04 ultrasonic sensor for distance measurement.
Cirkit Designer LogoOpen Project in Cirkit Designer
Bluetooth-Controlled Robotic Vehicle with Adafruit Motor Shield
Image of motor: A project utilizing Arduino Can-Bus Shield in a practical application
This circuit is a motor control system that uses an Adafruit Motor Shield to drive four hobby motors, with additional sensors including an IR sensor, an ultrasonic sensor, a metal detector, and a Bluetooth module for remote communication. The system is powered by a battery case and controlled via a rocker switch.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with Arduino Can-Bus Shield

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of wallE: A project utilizing Arduino Can-Bus Shield in a practical application
Arduino Sensor Shield with I2C LCD and Bluetooth Interface
This circuit features an Arduino Sensor Shield v5.0 interfaced with an I2C LCD Display and an HC-05 Bluetooth Module. The LCD Display is connected for power, ground, and I2C communication, allowing it to display data or messages. The HC-05 Bluetooth Module is wired for serial communication with the Arduino Sensor Shield, enabling wireless data exchange with other Bluetooth-enabled devices.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Proyecto final: A project utilizing Arduino Can-Bus Shield in a practical application
Arduino Sensor Shield-Based Smart Home Monitoring System with Bluetooth and I2C LCD
This circuit is an environmental monitoring system using an Arduino Sensor Shield. It includes sensors for gas (MQ-2), light (LDR), and temperature (DS18B20), and features a 16x2 I2C LCD for display, an HC-05 Bluetooth module for wireless communication, and a fan motor, buzzer, and LEDs for alert mechanisms.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Arduino Robot With Bluetooth Controller: A project utilizing Arduino Can-Bus Shield in a practical application
Arduino UNO Bluetooth-Controlled Robotic Car with Ultrasonic Distance Sensing
This circuit is a Bluetooth-controlled robotic vehicle. It uses an Arduino UNO to interface with an L293D motor driver shield, which controls four DC motors for movement. The vehicle's direction is controlled via commands received from an HC-05 Bluetooth module, and it also includes an HC-SR04 ultrasonic sensor for distance measurement.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of motor: A project utilizing Arduino Can-Bus Shield in a practical application
Bluetooth-Controlled Robotic Vehicle with Adafruit Motor Shield
This circuit is a motor control system that uses an Adafruit Motor Shield to drive four hobby motors, with additional sensors including an IR sensor, an ultrasonic sensor, a metal detector, and a Bluetooth module for remote communication. The system is powered by a battery case and controlled via a rocker switch.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

Key Technical Details

Parameter Specification
CAN Controller MCP2515 (SPI interface)
CAN Transceiver MCP2551
Operating Voltage 5V (powered by the Arduino board)
Communication Protocol CAN 2.0B (supports standard and extended data frames)
Baud Rate Configurable up to 1 Mbps
SPI Interface Uses Arduino pins D10 (CS), D11 (MOSI), D12 (MISO), and D13 (SCK)
Additional Features MicroSD card slot, serial LCD connector, and reset button
Dimensions Compatible with standard Arduino form factor

Pin Configuration and Descriptions

Pin Function
D10 (CS) Chip Select for SPI communication with the MCP2515 CAN controller
D11 (MOSI) Master Out Slave In - SPI data line for sending data to the MCP2515
D12 (MISO) Master In Slave Out - SPI data line for receiving data from the MCP2515
D13 (SCK) Serial Clock for SPI communication
CANH High line of the CAN bus for differential signaling
CANL Low line of the CAN bus for differential signaling
GND Ground connection
VCC 5V power supply (provided by the Arduino board)

Usage Instructions

How to Use the Shield in a Circuit

  1. Attach the Shield: Plug the CAN-Bus Shield onto your Arduino board, ensuring proper alignment of the pins.
  2. Connect to the CAN Bus:
    • Use the CANH and CANL terminals to connect the shield to the CAN bus.
    • Ensure proper termination resistors (typically 120Ω) are present at both ends of the CAN bus.
  3. Power the System: Power the Arduino board via USB or an external power source. The shield will draw power from the Arduino.
  4. Install Required Libraries:
    • Download and install the MCP_CAN library from the Arduino Library Manager or GitHub.
  5. Write and Upload Code:
    • Use the example code below to initialize the CAN bus and send/receive messages.

Example Code for Arduino UNO

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

// Define the SPI Chip Select pin for the CAN controller
#define CAN_CS 10

// Create an instance of the MCP_CAN class
MCP_CAN CAN(CAN_CS);

void setup() {
  Serial.begin(115200); // Initialize serial communication for debugging
  while (!Serial);

  // Initialize the CAN controller at 500 kbps
  if (CAN.begin(MCP_ANY, 500000, MCP_8MHZ) == CAN_OK) {
    Serial.println("CAN-Bus Shield initialized successfully!");
  } else {
    Serial.println("Error initializing CAN-Bus Shield. Check connections.");
    while (1);
  }

  // Set the CAN controller to normal mode
  CAN.setMode(MCP_NORMAL);
  Serial.println("CAN-Bus Shield is now in normal mode.");
}

void loop() {
  // Example: Send a CAN message with ID 0x100 and 8 bytes of data
  byte data[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
  if (CAN.sendMsgBuf(0x100, 0, 8, data) == CAN_OK) {
    Serial.println("Message sent successfully!");
  } else {
    Serial.println("Error sending message.");
  }

  delay(1000); // Wait 1 second before sending the next message
}

Important Considerations and Best Practices

  • Termination Resistors: Ensure the CAN bus is properly terminated with 120Ω resistors at both ends to prevent signal reflections.
  • Baud Rate Matching: All devices on the CAN bus must operate at the same baud rate.
  • Power Supply: Verify that the Arduino board can supply sufficient current for the shield and any connected peripherals.
  • Shield Stacking: If stacking multiple shields, ensure no pin conflicts occur.

Troubleshooting and FAQs

Common Issues and Solutions

  1. CAN-Bus Shield Not Initializing:

    • Verify the SPI connections (D10, D11, D12, D13) are properly aligned.
    • Check the baud rate configuration in the code. It must match the CAN bus baud rate.
    • Ensure the MCP_CAN library is correctly installed.
  2. No Communication on the CAN Bus:

    • Confirm the CANH and CANL lines are correctly connected to the bus.
    • Check for proper termination resistors (120Ω) at both ends of the CAN bus.
    • Ensure all devices on the bus are powered and operational.
  3. Error Sending or Receiving Messages:

    • Verify the message ID and data length are correctly configured in the code.
    • Check for electrical noise or interference on the CAN bus.

FAQs

Q: Can I use this shield with Arduino boards other than the UNO?
A: Yes, the shield is compatible with most Arduino boards that use the standard form factor, such as the Arduino Mega and Leonardo. However, ensure the SPI pins are correctly mapped.

Q: What is the maximum cable length for the CAN bus?
A: The maximum length depends on the baud rate. For example, at 500 kbps, the maximum recommended length is approximately 100 meters.

Q: Can I use this shield for OBD-II diagnostics?
A: Yes, the shield can be used for OBD-II applications, but you may need additional software or libraries to interpret OBD-II data.


This documentation provides a comprehensive guide to using the SparkFun Arduino CAN-Bus Shield (DEV-10039). By following the instructions and best practices outlined above, you can successfully integrate CAN communication into your projects.