Hello guys,
I'm an Arduino newbie and I want to do some car can bus sniffing with an UNO and a CAN BUS shield.
I have this exact shield MCP2515 EF02037 CAN BUS Shield Controller Board Communication Speed Hi – diymore.
They say it's an ElecFreaks EF02037 CAN-BUS Shield.
I have soldered the pin headers on the board including the SPI 2x3 pin header. The AREF and GND remained disconnected on the shield because I didn't have the proper pin header (I had a 1x6 instead of an 1x8), I'm not sure if this is a problem or not. I'll attach a photo with the boards.
Anyway, I've connected the Arduino with the CAN shield mounted to my laptop (the shield not connected to anything) and I've tried running a simple example from this library GitHub - coryjfowler/MCP_CAN_lib: MCP_CAN Library
My problem is that the MCP2515 initialization fails every time, I've tried CS pin 9 and CS pin 10, but no luck. Here's the exact code I'm trying to run.
void setup()
{
Serial.begin(115200);
// Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK)
Serial.println("MCP2515 Initialized Successfully!"); \
else
Serial.println("Error Initializing MCP2515...");
CAN0.setMode(MCP_NORMAL); // Set operation mode to normal so the MCP2515 sends acks to received data.
pinMode(CAN0_INT, INPUT); // Configuring pin for /INT input
Serial.println("MCP2515 Library Receive Example...");
}
It always fails at CAN0.begin, meaning it returns 1 (CAN_FAILINIT) instead of 0 (CAN_OK).
I'm not sure what to do or how to troubleshoot this. Can you guys help?
Thanks a lot.