4

I am trying to connect my Arduino Uno board with SeeedStudio Can Bus Shield to my 2006 325i BMW. After compiling and uploading the example program by SeeedStudio, the serial monitor returns "Can Bus Shield Init ok!"

// demo: CAN-BUS Shield, receive data with check mode
// send data coming to fast, such as less than 10ms, you can use this way
// loovee, 2014-6-13

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

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;

MCP_CAN CAN(SPI_CS_PIN); // Set CS pin

void setup() {
  Serial.begin(115200);
START_INIT:
  if(CAN_OK == CAN.begin(CAN_500KBPS)) {
  // init can bus : baudrate = 500k
    Serial.println("CAN BUS Shield init ok!");
  } else {
    Serial.println("CAN BUS Shield init fail");
    Serial.println("Init CAN BUS Shield again");
    delay(100);
    goto START_INIT;
  }
}

void loop(){
  unsigned char len = 0;
  unsigned char buf[8];
  if(CAN_MSGAVAIL == CAN.checkReceive()) {
    // check if data coming
    CAN.readMsgBuf(&len, buf);
    // read data,  len: data length, buf: data buf
    unsigned char canId = CAN.getCanId();
    Serial.println("-----------------------------");
    Serial.println("get data from ID: ");
    Serial.println(canId);
    for(int i = 0; i<len; i++) {
      // print the data
      Serial.print(buf[i]);
      Serial.print("\t");
    }
    Serial.println();
  }
}

So I get the initialize statement returned but I'm not receiving any data. It seems like the if(CAN_MSGAVAIL == CAN.checkReceive()) statement isn't executed. I found my vehicle's Can high and Can low wires and inserted them into my Can Bus Shield. So I'm not sure if it's a code problem or if the wires aren't transmitting the data to the shield. Any help would be great.

  • 1
    How are you connecting to the can bus shield. I stripped two wires and stuck them into can high and can low – Dailen Spencer Jun 9 '15 at 6:01
  • 1
    I'm hooked in to the screw terminals as well. I'm using a single wire system and a ground. I've tried a variety of different sketches, tried modifying the can library file but still no luck – user10545 Jun 10 '15 at 13:16
  • 1
    Any progress on this? – user10545 Jun 23 '15 at 3:44
  • 1
    Yes. Connected Can-Bus Shield to Arduino and also connected to Can High and Can Low. Then turned car on – Dailen Spencer Dec 3 '15 at 17:07
  • 1
    @DailenSpencer - Does the module return "CAN BUS Shield init ok!" without being connected to the car? Mine is saying "CAN BUS Shield init fail" but I'm not sure if it's my connection to the module or the module's connection to the car. Thanks. – Bort Jan 14 '16 at 3:50
2

It may be a dumb question, but are you sure your car CAN bus is 500kbps?
Have a look at this: pdfLink
Maybe try different speeds? 100kbps maybe?

Also, look at the schematics of your shield? Is the bus termination resistor soldered on the board?

0

Make sure to cut the P1 trace (see the link below) and also to connect GND from the OBD-2 to the shield/Arduino. There are two ground pins on the OBD-2 port, Signal and Chassis Ground. I went with Signal GND, but allegedly they are linked anyways.

This guide helped me a lot.

protected by Community Oct 4 '15 at 21:42

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.