Unable to receive CAN bus data from OBD port Vehicle ( Arduino, MCP2515)

Hi there, Im having trouble receiving data from OBD port 2 through my setup which is Arduino UNO, MCP2515 and OBD dongle. Below is my setup

#include <CAN.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);

  Serial.println("CAN Receiver");

  // start the CAN bus at 500 kbps
  if (!CAN.begin(500E3)) {
    Serial.println("Starting CAN failed!");
    while (1);
  }
}

void loop() {
  // try to parse packet
  int packetSize = CAN.parsePacket();

  if (packetSize) {
    // received a packet
    Serial.print("Received ");

    if (CAN.packetExtended()) {
      Serial.print("extended ");
    }

    if (CAN.packetRtr()) {
      // Remote transmission request, packet contains no data
      Serial.print("RTR ");
    }

    Serial.print("packet with id 0x");
    Serial.print(CAN.packetId(), HEX);

    if (CAN.packetRtr()) {
      Serial.print(" and requested length ");
      Serial.println(CAN.packetDlc());
    } else {
      Serial.print(" and length ");
      Serial.println(packetSize);

      // only print packet data for non-RTR packets
      while (CAN.available()) {
        Serial.print(CAN.read(), HEX);
      }
      Serial.println();
    }

    Serial.println();
  }
}

Here is a code I used to read data. And below is the testing I made



I am unable to retrieve the data from the OBD port in the serial monitor.

I already tested numerous times and doubled checked every wiring and OBD pin.

Below is a testing I made to ensure whether the setup is working properly through sending a CAN message through a ESP32 to the setup


As the image above, the setup is working by receiving the CAN bus data from the ESP32 however when it is unable to receive the CAN bus data from OBD port vehicle.

Can someone please help me?

your code is merely a bus sniffer and if this is a recent car (2010 or later) most EOMs by then 'protect' the OBD port such that is not possible to view vehicle CAN data from it.

That could explain why you are not seeing anything when you are connected to the car but you can see data coming from the ESP32.

hope that helps....

1 Like

When I was involved there were three classes of messages. User (OBDII [On Board Diagnosis 2], Dealer, and OEM. There are specific protocols the tools use to access this data. Because of tampering etc many manufacturers put in a gateway that limited the data available and did not allow control. OBDII only specified certain pieces of information be made available and that is all there is available on some cars. The later versions also change the CAN (Controlled Area Network) bit rate and package sizes. You can also try swapping the CAN-H and CAN-L connections, this will not hurt anything just do not send anything.

Ouuuh understand, sorry as I have very limited knowledge on this field. Do you have any suggestions on how can I access those data (any hardware i can use?). I just want to access data information to record (speed,rpm, braking etc)

Ouuh i see, so it is just not possible to get access to the data with my current setup.

Is there a available any other hardware I can use to access those CAN bus data? Maybe CAN bus shield by Seed studio?

1 Like

I do not know I am not familiar with all of your hardware. Your UNO picture looks correct but I cannot read the labels, a schematic is much better. Also I am not familiar with your library, I use Cory Fowler's MCP-can library. It comes with a send and receive pieces of test code. Yo need two to test it as CAN must have an IFR (In Frame Response) "acknowledge" from any member on the bus. There is a difference in vehicles, years, and models to be cognoscenti of. If you go this rout just extend the bus to the OBDII port, your receiver will IFR for the message.

First just swap CAN-L and CAN-H and see what happens.

Nope still no response from the OBD port

Should i also use cory's fowler mcp can library? Is it compatible with my setup?

I use it with the UNO, Nano, and WeMos D1R1 without any problems. I do not connect to a CAR or any other vehicle so I do not know for sure although it should work and others have has success.