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.

James Waldby - jwpat7
  • 8,800
  • 3
  • 16
  • 32
  • You made the key on and press gas pedal while Arduino UNO and CAN-BUS Shield are connected to your car? –  Sep 07 '15 at 12:43
  • 1
    Yes. Connected Can-Bus Shield to Arduino and also connected to Can High and Can Low. Then turned car on – Dailen Spencer Dec 03 '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 03:50
  • @Bort Yes. When connected to can wires, Arduino output returns "Can BUS Shield init ok!" – Dailen Spencer Jan 14 '16 at 17:41
  • 1
    @DailenSpencer - I'm sorry, but "Yes" doesn't match the rest of your answer. So, it DOESN'T say "init ok" UNLESS you connect to the car? If I get any further, I'll post how I get it to work! – Bort Jan 14 '16 at 22:24
  • I'm having a similar problem, I can see the light flashing with different operations of the vehicle but no data is spit out to the serial monitor. Are you seeing the led flashing as data being received? –  Jun 09 '15 at 02:03
  • No :/ only the power light – Dailen Spencer Jun 09 '15 at 05:59
  • 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 09 '15 at 06:01
  • 2
    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 –  Jun 10 '15 at 13:16
  • 1
    Any progress on this? –  Jun 23 '15 at 03:44
  • Not yet. Im going to order a different canbus shield from spark and see if that works :/ – Dailen Spencer Jun 23 '15 at 15:59
  • Any progress guys? I am facing the same problem. Mine says "Init OK" even when not connected to the car. (I am using a clone http://www.elecfreaks.com/estore/can-bus-shield.html) I only connect CAN-H and CAN-L. You mentioned also GND... Should I wire that too? – Jaroslav Záruba Mar 10 '17 at 09:16
  • UPDATE: So yes, for me it was the GND. Also when connecting to an in-car bus make sure to break the P1 trace, or at least consider it and read-up about it why you might need to do it. – Jaroslav Záruba Mar 21 '17 at 22:01

2 Answers2

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?

SMFSW
  • 367
  • 2
  • 7
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.