CANBUS shield CAN init failing

Hi, I'm very inexperienced with Arduinos so please go easy...

I'm trying to tap into the CANBUS on my MK5 VW Golf to explore how it works. For this I've purchased a CANBUS shield branded "diymore". According to their website it's an ElecFreaks EF02037 CAN-BUS Shield. This is being used with an Arduino Uno.

To connect it to the car, I'm using an OBD2 to DB9 cable. The CANBUS pins correctly match that of the port in the car and also match correctly the serial port on the shield. OBD2 port pins 6 and 14 for CAN high and low map to pins 3 and 5 of the DB9 connector.

I'm using the Seeed Arduino CAN library ( link ), however I can't get it to do any more than fail to initialise. I've tried the various examples that come with the library, and none of them work.

After some digging around I've found that some say the code needs to be set up to use pin 10 rather than pin 9, however this tweak doesn't fix the issue for me. I've cut down the example code drastically:

#include <SPI.h>

#define CAN_2515

#include "mcp2515_can.h"
mcp2515_can CAN(10); // Set CS pin

void setup() {
    SERIAL_PORT_MONITOR.begin(115200);
    while (!SERIAL_PORT_MONITOR) {}

    while (CAN_OK != CAN.begin(CAN_500KBPS)) {             // init can bus : baudrate = 500k
        SERIAL_PORT_MONITOR.println(F("CAN init fail, retry..."));
        delay(1000);
    }
    SERIAL_PORT_MONITOR.println(F("CAN init ok!"));
}

void loop() {
  SERIAL_PORT_MONITOR.println("This line never gets reached.");
}

The code gets stuck in "CAN init fail, retry...", as the CAN.begin() method always returns 1 (CAN_FAILINIT).

On the shield itself there are four LED's:

  • PWR
  • TX
  • RX
  • INT

The PWR and INT lights stay on while there is no activity on TX or RX lights.

Does anyone have any pointers for what I could be doing wrong? I've spent a few days on this now with no luck - any and all advice welcome!

Cheers

Hi, @why_is_nothing_easy
Is this your shield?

Have you got gnd of the shield/UNO connected to the gnd on the OBD plug?

Tom... :grinning: :+1: :coffee: :australia:

1 Like

Find pin 16 (CS) on the MCP2515 chip and follow the PCB trace until it reaches one of the pins on the Arduino connector. Your code assumes pin 10, but it may be something else.

Hi @TomGeorge ,

I'm really sorry for the huge delay, I've not had the car as it developed not one but three(!) coolant leaks one after the other so this project got very much side tracked. I've now got the car back so this project is back on!

Yes that looks exactly the same as the board I've got.

Regarding the ground, I'm not certain, but here's what information I can find.
A high level look at the setup is car OBD2 port <-> OBD2 to serial cable <-> CANBUS shield.

The pinout for the obd2 port on the MK5 Golf (Source)

Pin 	Signal 	Description
1 	IGN 	Switched to +12V when the ignition is on
2 	J1850 Bus+ 	Not used?
4 	CGND 	Chassis ground
5 	SGND 	Signal ground
6 	CAN High 	ISO 15765-4 and SAE J2284
7 	K-LINE 	ISO 9141-2 and ISO/DIS 14230-4 Not used?
10 	J1850 Bus- 	Not used?
14 	CAN Low 	ISO 15765-4 and SAE J2284
15 	ISO 9141-2 L-LINE 	ISO 9141-2 and ISO/DIS 14230-4 Not used?
16 	+12v 	Battery power

The pin mappings for the cable I'm using (Source removed due to inability to post >2 links as a new user...):
DB9 OBD2 cable mappings

And finally the interface on the shield (Source and other schematic info for the shield)
Image embed removed due to only being allowed to post one image as a new user...

From what I can see the ground comes in from the car on pins 4/5 into pins 1/2 on the shield which appears correct, but I might be wrong there.

Cheers

Hi @mikb55 ,

Again, sorry for the delay.

From what I understand (according to this documentation), the pin with the arrow is the one you're talking about. Hopefully the image is clear enough. The trace heads towards pin 12 however it stops with a circle (I don't know what that means...). I have no idea which pin it ends up at, I presume PCB's have multiple layers and this particular trace continues on a different layer or something?

Cheers

Flip the board over and look for the corresponding circle on the other side.
Alternatively use the continuity feature on a multimeter to see where it goes.

Hi @mikb55 ,

Using a multimeter on the pin shown in the image above, there is continuity onto pin 10.

I hadn't thought about using a multimeter so while there I also checked for continuity between the shield and the arduino. There is continuity on all pins.

Cheers