Skip to content

CANBed - Arduino CAN Bus Development Kit


CAN Bus is a common industrial bus because of its long travel distance, medium communication speed and high reliability. It is commonly found on modern machine tools, such as an automotive diagnostic bus.

This CANBed adopts MCP2515 CAN Bus controller with SPI interface and MCP2551 CAN transceiver to achieve the CAN-BUS capability. With an OBD-II converter cable added on and the OBD-II library imported, you are ready to build an onboard diagnostic device.

What's more, the is an Atmega32U4 with Arduino Leonardo bootloader on the board, you can use Arduino IDE to program the board easily.


  • Implements CAN V2.0B at up to 1 Mb/s
  • Industrial standard 9 pin sub-D connector or 4PIN Terminal.
  • OBD-II and CAN standard pinout selectable at sub-D connector
  • 2x4Pin Connector compatable with Grove system from Seeedstudio
  • SPI Interface up to 10 MHz
  • Standard (11 bit) and extended (29 bit) data and remote frames
  • Power input from 9-28V


Parameter Value
MCU Atmega32U4
(with Arduino Leonardo bootloader)
Clock Speed 16MHz
Flash Memory 32KB
Operate Voltage 9-28V
Input Interface sub-D

Hardware Overview

Part List

  • sub-D connector
  • 4PIN Terminal
  • 4PIN 2.0 Connector x 2
  • 9x2 2.54 Header x 1
  • 3x3 2.54 Header x 1

Pin out

1.9x2 IO Pin OUT:

The IO of Atmega32U4 is list out here.


The master of the entire module, mainly used to store data on the TF card or transfer data to the computer through the type C cable. In addition, since it's arduino compatible, you can use it to implement some simple controls, such as triggering a buzzer alarm when the speed exceeds a certain value.

2.Reset Button:

Reset the on-board Atmega chip.

3.Micro USB connector for programming

4. ICSP Header for uploading bootloader

5.CAN RX/TX Indicator

6.sub-D connector or Terminal for CAN Bus

D-Sub CANbus PinOut

pin# Signal names Signal Description
1 Reserved Upgrade Path
2 CAN_L Dominant Low
3 CAN_GND Ground
4 Reserved Upgrade Path
5 CAN_SHLD Shiled, Optional
6 GND Ground,Optional
7 CAN_H Dominant High
8 Reserved Upgrade Path
9 CAN_V+ Power, Optional

7.Switch for the 120Ω terminal resistor for CAN Bus

If you use this slaver on the end of the CAN bus, you need to solder a 120Ω resister between the two pad, if not just leave them alone. For more detail about the CAN bus protocol, please refer to the NI CAN Physical Layer and Termination Guide

8.Grove connector for UART

9.Grove connector for I2C

A.Reset button


Arduino Code

We provide an arduino library for CANBed.

There're many examples for the library, which is consist of,

  • send - How to send a frame to CAN Bus
  • recv - How to recv a frame from CAN Bus
  • set_can_baudrate - set can bus baudrate
  • set_mask_filt - set mask and filt of the module


1. Set the Baud rate

This function is used to initialize the baud rate of the CAN Bus system.

The available baud rates are listed as follows:

#define CAN_5KBPS    1
#define CAN_10KBPS   2
#define CAN_20KBPS   3
#define CAN_25KBPS   4
#define CAN_31K25BPS 5
#define CAN_33KBPS   6
#define CAN_40KBPS   7
#define CAN_50KBPS   8
#define CAN_80KBPS   9
#define CAN_83K3BPS  10
#define CAN_95KBPS   11
#define CAN_100KBPS  12
#define CAN_125KBPS  13
#define CAN_200KBPS  14
#define CAN_250KBPS  15
#define CAN_500KBPS  16
#define CAN_666kbps  17
#define CAN_1000KBPS 18

2. Set Receive Mask and Filter

There are 2 receive mask registers and 5 filter registers on the controller chip that guarantee you getting data from the target device. They are useful especially in a large network consisting of numerous nodes.

We provide two functions for you to utilize these mask and filter registers. They are:


init_Mask(unsigned char num, unsigned char ext, unsigned char ulData);


init_Filt(unsigned char num, unsigned char ext, unsigned char ulData);
  • num represents which register to use. You can fill 0 or 1 for mask and 0 to 5 for filter.
  • ext represents the status of the frame. 0 means it's a mask or filter for a standard frame. 1 means it's for a extended frame.
  • ulData represents the content of the mask of filter.

3. Check Receive

The MCP2515 can operate in either a polled mode, where the software checks for a received frame, or using additional pins to signal that a frame has been received or transmit completed.

Use the following function to poll for received frames.

INT8U MCP_CAN::checkReceive(void);

The function will return 1 if a frame arrives, and 0 if nothing arrives.

4. Get CAN ID

When some data arrive, you can use the following function to get the CAN ID of the "send" node.

INT32U MCP_CAN::getCanId(void)

5. Send Data

CAN.sendMsgBuf(INT8U id, INT8U ext, INT8U len, data_buf);

It is a function to send data onto the bus. In which:

  • id represents where the data comes from.
  • ext represents the status of the frame. '0' means standard frame. '1' means extended frame.
  • len represents the length of this frame.
  • data_buf is the content of this message.

For example, In the 'send' example, we have:

unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
CAN.sendMsgBuf(0x00, 0, 8, stmp); //send out the message 'stmp' to the bus and tell other devices this is a standard frame from 0x00.

6. Receive Data

The following function is used to receive data on the 'receive' node:

CAN.readMsgBuf(unsigned char len, unsigned char buf);

In conditions that masks and filters have been set. This function can only get frames that meet the requirements of masks and filters.

  • len represents the data length.
  • buf is where you store the data.

Generate a New BaudRate

We had provided many frequently-used baud rates, as below:

#define CAN_5KBPS    1
#define CAN_10KBPS   2
#define CAN_20KBPS   3
#define CAN_25KBPS   4
#define CAN_31KBPS   5
#define CAN_33KBPS   6
#define CAN_40KBPS   7
#define CAN_50KBPS   8
#define CAN_80KBPS   9
#define CAN_83KBPS   10
#define CAN_95KBPS   11
#define CAN_100KBPS  12
#define CAN_125KBPS  13
#define CAN_200KBPS  14
#define CAN_250KBPS  15
#define CAN_500KBPS  16
#define CAN_666KBPS  17
#define CAN_1000KBPS 18