CAN BUS Shield Help

Hi all, i have been trying to get the CAN bus recieve code to work from the wiki site, i have one UNO R3 and sparkfun shield, i can transmit with the sent code and view on my CAN Analyser,

When i upload the Recieve code, and send out some data on address 0X00 as in the send code, and view the serial monitor, i see nothing at all,

I notice there is no serial.begin or serial.print code in the recieve code on the wiki site? is this correct?

Thanks for the help


hey~ yes, there is something wrong in the wiki~ You need to add a code “Serial.begin()”. The guy who design the shield will refresh the wiki soon!

Can you advise on what else is needed and at which point in the code you think it should go?

I have added the serial.begin(9600) to the code as shown below, but as soon as i iopen the serial monitor, it crashes the BUS.

#include “mcp_can.h”
#include <SPI.h>
#include <stdio.h>
#define INT8U unsigned char

INT8U Flag_Recv = 0;
INT8U len = 0;
INT8U buf[8];
char str[20];
void setup()
Serial.begin(115200); ADDED HERE
attachInterrupt(0, MCP2515_ISR, FALLING);

void MCP2515_ISR()
Flag_Recv = 1;

void loop()
Flag_Recv = 0;
CAN.readMsgBuf(&len, buf);
if(buf[0] == 02 && buf[1] == 01 && buf[2] == 00)
unsigned char b[8] = {0x06, 0x41, 0x00 ,0xbe ,0x3f ,0xa8 ,0x13 ,0x00};
unsigned char c[8] = {0x06, 0x41, 0x00 ,0x98 ,0x1e ,0x80 ,0x13 ,0x00};
CAN.sendMsgBuf(0x7e8, 0, 8, b);
CAN.sendMsgBuf(0x7e9, 0, 8, c);

  if(buf[0] == 02 && buf[1] == 01 && buf[2] == 0x0d)
    unsigned char a[8] = {0x03 ,0x41 ,0x0d ,0x00 ,0x00 ,0x00 ,0x00 ,0x00};
    CAN.sendMsgBuf(0x7e8, 0, 8, a);
    CAN.sendMsgBuf(0x7e9, 0, 8, a);


it crashes the BUS ? hey, I am sorry that I can’t understand what you mean exactly, do you mean the can bus shield didn’t get anything or something else?

I meant that the BUS became full of recieve errors,

Deray has now sent me a new library which works great,

Can you help with one issue,

When doing a CAN.readMsgBuf, is there any way of conditioning it to look at only a single specified CAN base Id, such as a message being sent with ID 0x400 for example?

I had a look in the keywords folder and thjere is a GetCANid command, but im unsure of how to implement this,



yes, when you had received a CAN-Bus frame (readMsgBuf()), you can use getCanId to get the ID of the frame~

Hi, I saw this post which was quite some time back, however I am also using the sparkfun shield, and are unable to receive anything.

any suggestion on this?