Read/Write CAN Messages over OBD 2 Port

We have recently started using Particle Photon to obtain CAN data over the OBD 2 port. Carloop_minimal gives a good introduction on how to get started with it.

We wanted to know if there are any similar resources to understand how the underlying libraries are written and ways in which we can leverage those functions to create our own applications for streaming the OBD 2 data.

Thanks & Best,
Sahil & Parin

(A2A: @alanm & @jvanier)

1 Like

Hey!
Thatā€™s fantastic you got so far already! What is your end goal? Is there a specific car you are targeting?

Alan

Hey Alan,

Thanks for getting back! Yes, we are trying to work on Honda Civic 9 generation and BMW M235 i. We want to control the carā€™s peripherals For eg: lights, locks etc. though the OBD 2 port using particle photon + carloop.

Can you suggest ways in which we can sniff the IDā€™s and examples to write back to the CAN bus? Would there be any security layer that we need to go through?

Best,
Sahil

The most detailed explanation of the underlying library is in the Particle firmware documentation.

https://docs.particle.io/reference/firmware/photon/#can-canbus-

It documents all the members of the CANMessage structure and has examples for transmitting and receiving.

When transmitting, check the return value of can.transmit(message). If it is true it means the transmit buffer is full which means either youā€™re transmitting too fast or the messages are not being sent properly. Check the wiring and CAN bus speed. can.errorStatus() != CAN_NO_ERROR would also indicate that the messages are not being sent properly.

To sniff the IDs you can use the example and just print out the IDs of every message you receive.

For transmitting, thereā€™s no additional security than not knowing what each byte in each messages represents to the modules receiving those messages.

2 Likes

Hi,

(1) We can read the ID and data out of Honda Civic, but the BMW just throws out ID 0x130 (PID for ignition). Have you seen this before or aware of what could be happening?

(2) Carloop library runs with 500KBps. Is there a simpler way to modify it to access all possible CAN speeds by tweaking the code?

(3) Also, I am unable to locate ā€˜application.hā€™ header file when I try to git clone carloop repo. It will be great if you can redirect me to that header file.

Thanks,
Sahil

Hi @sahilpotnis, here some answers:

(3) Also, I am unable to locate ā€˜application.hā€™ header file when I try to git clone carloop repo. It will be great if you can redirect me to that header file.

For the application.h source code see: Where can I find source code for application.h and application.cpp? - Firmware - Particle

(2) Carloop library runs with 500KBps. Is there a simpler way to modify it to access all possible CAN speeds by tweaking the code?

The easiest way is to include the Carloop library under Particleā€™s Web IDE and then with one line of code:
carloop.setCANSpeed(125000);

(1) We can read the ID and data out of Honda Civic, but the BMW just throws out ID 0x130 (PID for ignition). Have you seen this before or aware of what could be happening?

Not 100% sure you will be able to get CAN bus data (other than OBD-II) on pins 6 and 14 on a BMW or any German car for that matter. In order to get data, you will need to send an OBD request. Here is an example on how to actively request OBD data: https://github.com/carloop/carloop-library/blob/master/firmware/examples/obd_blink.cpp

1 Like

This thread should be linked on the documents page! Super useful thread.

Hi All,

Regarding BMW ID 0x130.
I also have the same issue. It seems that this is new design to show on OBD2 socket only wakeup messages. Other internal messages seems to be suppressed by a gateway (ZGM block).

I can imagine two options here:

  1. There should be either special code to be sent to the gateway (ZGM) to disable filters, or maybe some pin in OBD2 to be pulled to +12.
  2. Another CAN-bus to be used to monitor all activities. There should be a hidden socket or something with another CAN-bus in this case.

Does anybody have some news or ideas on this topic?

@sahilpotnis, did you manage to get things going with the BMW?
@Ledchik is dealing with the same issue.

Also, How about checking out a BMW-specific forum to see if anyone there has encountered the same thing and found a solution?

Please, let us know if you figure it out!

I would recommend getting the factory service manual (online, DVD or print if available) for the car you are targeting. You should find a ton of information about the vehicleā€™s network.
Let me give you an example. In my Honda Odyssey, I wanted to access the Body CAN (BCAN) network, which is not exposed on the OBD2 port. I tapped into the BCAN network at my heated seat module after decoding the pinout using my service manual. I had to build a wiring harness to make it work with the Carloop but that was super easy.

Iā€™m doing that now with my 2014 Dodge Charger. I have the CANBUS layout.
I managed to get 2015 and 2017 chargerā€™s CANBUS layouts too. Can I share that without getting contacted by Chrysler lol?
Iā€™m trying to figure out why I can only control the passenger window through the OBDII port. I can get it to go up and down but thatā€™s the only window I can control lol none of the other windows show up in cansniffer when itā€™s running. I found someone on instagram that makes custom harness so Iā€™m definitely planning something soon. Iā€™m still working on my code

Hey @dubb45, I just got my CarLoop yesterday. Looking to obtain canbus layout for my 2011 Challenger SRT8. Any pointers where to start my journey?

Iā€™ve posted alot of info on the site, just use the carloop socketcan sketch and linux. From
There just push buttons and observe cansniffer. Super simple sounds hard at first but once you read through all the docs and info it becomes clear :joy:

I just noticed the wealth of info youā€™ve posted. This was also very helpful. Thanks! Hopefully Iā€™ll be able to contribute back some wealth of knowledge.

Yea man let me know.
I also contributed to the ā€œzauto tazerā€ made the cluster swap happen!!! All thanks to the carloop! This device is powerful man you just have to code what you want it to do!! I can change vin, enable srt pages, change the 8.4ā€ screen to ā€œdodge, ram, Maserati, Lancia, jeep, chryslerā€ doing that also changes the color of the cluster all with the carloop dude! This thing does it all Iā€™m working on ECU flashing now and it can be done too!

Check out my Instagram @dubb45

Going to follow you on Instagram. Part of Space City LX I see. I am the founder and creator of the NJ Mopar Group. Glad to meet another fellow Moparian hacking their car.

1 Like

dope!!! Man glad to meet you! Yes sir these cars are amazing just want to be able to make my car ā€œmy carā€ :joy:

Sorry for reopening this old topic but, anyone found a solution for the 0x130 ID on the BMW??
Cheers!