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

How to Use CAN BUS: Examples, Pinouts, and Specs

Image of CAN BUS
Cirkit Designer LogoDesign with CAN BUS in Cirkit Designer

Introduction

The CAN (Controller Area Network) BUS module is an electronic communication interface used for connecting multiple microcontrollers in applications without a host computer. It is commonly used in automotive and industrial systems for allowing microcontrollers and devices to communicate with each other within a vehicle or machinery without a central computer.

Explore Projects Built with CAN BUS

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Dual Raspberry Pi 2B CAN BUS Communication Interface with Pushbutton Interaction
Image of BSP4: A project utilizing CAN BUS in a practical application
This circuit features two Raspberry Pi 2B microcontrollers connected to separate CAN BUS modules, forming a CAN network for data exchange. A pushbutton is included for user interaction, interfaced with GPIO pins on both Raspberry Pis.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO WiFi CAN Bus Interface with Sensor/Actuator Module
Image of CAN : SN65HVD230 via NS-LS2(LevelConverter)2: A project utilizing CAN BUS in a practical application
This circuit features two Arduino UNO R4 WiFi microcontrollers interfaced with NS-LS2 light sensors and CAN_SN65HVD230 CAN bus transceivers. The Arduinos are configured to read light intensity data from the NS-LS2 sensors and communicate with each other over a CAN network, likely for a distributed sensing application. Power distribution is managed with 3.3V and 5V connections to the respective components, and the ground connections are shared across the devices to complete the circuit.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Nano OBD-II Data Logger with TFT Display and CAN Bus Interface
Image of inzynierka: A project utilizing CAN BUS in a practical application
This circuit is an OBD-II vehicle diagnostic interface that uses an Arduino Nano to communicate with a vehicle's CAN bus via an MCP2515 CAN controller. It includes a 7805 voltage regulator to step down the vehicle's 12V supply to 5V, powering the Arduino and other components, and a 1.44-inch TFT display for visual output. A pushbutton is also included for user interaction.
Cirkit Designer LogoOpen Project in Cirkit Designer
STM32 and ESP32 CAN Bus Communication System with MCP2515
Image of CAR HACKING: A project utilizing CAN BUS in a practical application
This circuit integrates multiple microcontrollers (STM32F103C8T6, ESP32, and Raspberry Pi Pico W) with MCP2515 CAN controllers to facilitate CAN bus communication. The microcontrollers are connected to the MCP2515 modules via SPI interfaces, and the circuit includes USB-to-serial converters for programming and debugging purposes.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with CAN BUS

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 BSP4: A project utilizing CAN BUS in a practical application
Dual Raspberry Pi 2B CAN BUS Communication Interface with Pushbutton Interaction
This circuit features two Raspberry Pi 2B microcontrollers connected to separate CAN BUS modules, forming a CAN network for data exchange. A pushbutton is included for user interaction, interfaced with GPIO pins on both Raspberry Pis.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of CAN : SN65HVD230 via NS-LS2(LevelConverter)2: A project utilizing CAN BUS in a practical application
Arduino UNO WiFi CAN Bus Interface with Sensor/Actuator Module
This circuit features two Arduino UNO R4 WiFi microcontrollers interfaced with NS-LS2 light sensors and CAN_SN65HVD230 CAN bus transceivers. The Arduinos are configured to read light intensity data from the NS-LS2 sensors and communicate with each other over a CAN network, likely for a distributed sensing application. Power distribution is managed with 3.3V and 5V connections to the respective components, and the ground connections are shared across the devices to complete the circuit.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of inzynierka: A project utilizing CAN BUS in a practical application
Arduino Nano OBD-II Data Logger with TFT Display and CAN Bus Interface
This circuit is an OBD-II vehicle diagnostic interface that uses an Arduino Nano to communicate with a vehicle's CAN bus via an MCP2515 CAN controller. It includes a 7805 voltage regulator to step down the vehicle's 12V supply to 5V, powering the Arduino and other components, and a 1.44-inch TFT display for visual output. A pushbutton is also included for user interaction.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of CAR HACKING: A project utilizing CAN BUS in a practical application
STM32 and ESP32 CAN Bus Communication System with MCP2515
This circuit integrates multiple microcontrollers (STM32F103C8T6, ESP32, and Raspberry Pi Pico W) with MCP2515 CAN controllers to facilitate CAN bus communication. The microcontrollers are connected to the MCP2515 modules via SPI interfaces, and the circuit includes USB-to-serial converters for programming and debugging purposes.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • Automotive systems (e.g., engine management, infotainment, sensors)
  • Industrial automation and control systems
  • Robotics
  • Aerospace and defense systems

Technical Specifications

Key Technical Details

  • Operating Voltage: Typically 5V
  • Current Consumption: Varies with the module, often < 100 mA
  • Differential Voltage Range: ±12V (max)
  • Logic Level: 2.5V (recessive) to 3.5V (dominant)
  • Maximum Speed: Up to 1 Mbps

Pin Configuration and Descriptions

Pin Number Name Description
1 VCC Power supply (5V)
2 GND Ground connection
3 CANH CAN High
4 CANL CAN Low
5 RX Receive data (optional, for some modules)
6 TX Transmit data (optional, for some modules)

Usage Instructions

How to Use the Component in a Circuit

  1. Power Connections: Connect the VCC pin to a 5V power supply and the GND pin to the ground.
  2. CAN Bus Connections: Connect the CANH and CANL pins to the corresponding CANH and CANL lines of the CAN network.
  3. Microcontroller Interface: If the module has RX and TX pins, connect them to the respective TX and RX pins of the microcontroller.

Important Considerations and Best Practices

  • Ensure that the power supply is stable and within the specified voltage range.
  • Terminate the CAN bus properly with 120-ohm resistors at both ends of the bus.
  • Keep the CANH and CANL lines as twisted pairs to reduce interference.
  • Avoid stubs in the CAN bus wiring to prevent signal reflections.
  • Use shielded cables in noisy environments.

Example Code for Arduino UNO

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

// Initialize CAN BUS module with CS pin
MCP_CAN CAN(10); 

void setup() {
  Serial.begin(115200);
  
  // Initialize CAN BUS module at 500kbps speed
  if (CAN_OK == CAN.begin(CAN_500KBPS)) {
    Serial.println("CAN BUS Shield init ok!");
  }
  else {
    Serial.println("CAN BUS Shield init fail");
    Serial.println("Init CAN BUS Shield again");
    delay(100);
  }
}

void loop() {
  // Check if data is available to read
  unsigned char len = 0;
  unsigned char buf[8];
  
  if (CAN_MSGAVAIL == CAN.checkReceive()) {
    CAN.readMsgBuf(&len, buf); // Read data,  len: data length, buf: data buffer
    unsigned long canId = CAN.getCanId();
    
    Serial.println("-----------------------------");
    Serial.print("Get data from ID: 0x");
    Serial.println(canId, HEX);
    
    for (int i = 0; i < len; i++) { // Print each byte of the data
      Serial.print(buf[i], HEX);
      Serial.print("\t");
    }
    Serial.println();
  }
}

Troubleshooting and FAQs

Common Issues Users Might Face

  • No Communication: Check power supply, wiring, and termination resistors.
  • Error Frames: Ensure there are no physical layer issues, such as damaged cables or connectors.
  • Bus Off: The module may go into a bus-off state if errors exceed a certain threshold. Check for noise, incorrect baud rate, or faulty nodes.

Solutions and Tips for Troubleshooting

  • Verify that all connections are secure and correct.
  • Use an oscilloscope to check the signal quality on the CANH and CANL lines.
  • Ensure that all nodes on the network have a unique identifier.
  • Check for software issues, such as incorrect initialization of the CAN module.

FAQs

Q: Can I use the CAN BUS module with a 3.3V system? A: Some CAN BUS modules are 3.3V compatible, but you must check the specific module's datasheet.

Q: How many devices can be connected to a CAN BUS? A: The CAN specification allows up to 112 nodes, but practical limits are lower and depend on the total bus length and the transceiver used.

Q: What is the maximum length of a CAN BUS network? A: The maximum length depends on the baud rate; for example, at 1 Mbps, the maximum length is typically around 40 meters.

Q: Do I need to use termination resistors? A: Yes, proper termination is critical for preventing reflections and ensuring signal integrity on the CAN bus.