Understanding the data from OBDII protocol

2.2k Views Asked by At

I am currently developing an application for Android which connects to an OBD device (Using ELM 327 Mini) and reads its data.

I am relatively new to the OBDII protocol, I just started working with it like a month ago, but using the official documentation, looking around on the internet and using the pires api which creates a good base for the development of what I need (which you can find here and here) I have managed to finish the application and test it on several cars. The results, for the most part, have been great until I tested the application on a Mercedes-Benz Class C w204.

On this car, the data that my application reads from the OBD is something that I am not able to understand. I have tried to look for similar examples but I have not been successful and I find myself totally stuck without being able to find a fix to this problem.

I am going to write you a few examples of this data, but first I would like to inform you how I initialize the OBD everytime my application connects to it, because my gut tells me I have not used the correct commands or there are a few I am missing. But as I said, my application works perfectly with other cars.

The AT commands:

AT Z
AT L0
AT SP 6 or AT SP 0

First of all, after the initialization is done I send the PID 00 (01 00) to know which PIDs from 01 to 20 the car supports. Here is my first problem

Sometimes I receive

[Req] 01 00
[Ans] 01 00 41 00 98 18 00 01
[Ans] 1: 06 41 00 BF FF E8 93

And sometimes

[Req] 01 00
[Ans] 01 00 41 00 95 00 20 13

Note: I have added the [Req] and [Ans] manually for the only purpose to make it more understandable.

What really bothers me it is the fact that the answer is different. Sometimes it answers 41 00 95 00 20 13 and others 41 00 98 18 00 01, how is that even posible? That PID answer should be the same always for the same car, I don't think the car can change dynamicaly which PIDs supports.

Another is why sometimes the PID 00 is answered with 1 or 2 lines. In the first example, you can see that the first line is the normal answer to the pid 00 but then, it has a second answer which is 1: 06 41 00 BF FF E8 93 and I have really no clue what does that mean.

I have another example with the pid 01

[Req] 01 01
[Ans] 01 01 41 01 00 07 E9 00
[Ans] 1: 06 41 01 00 04 00 00

[Req] 01 01
[Ans] 01 01 41 01 00 04 00 00

Is it because it is answering in different protocols at the same time? Is that what the 06 means?

Also, asking for the speed of the vehicle sometimes it returns NO DATA and within the next 2 seconds it returns a correct value, 41 0D 00 (for example) and next 2 seconds it retuns NO DATA again. Meaning, it's totally random when the NO DATA error ocurrs. The problem is the car actually has the PID supported because time to time it can return correct data.

I am pretty sure it's about something in the initialization of the OBD, maybe I need to put a higher timeout or include some more commands, but since I am not an expert in the OBD protocol, I don't really know how should I procced. I would really appreciate any kind of help, just by point out something that I have missed in the official documentation or any silly mistake I might have done. Mostly I want to understand what is happening so I can process the data accordenly.

Thanks a lot!

1

There are 1 best solutions below

0
On BEST ANSWER

So finally I discovered the reason why this is happening it's because the car has two ECUs answering my requets.

I found it out by requesting a few PIDs with the headers ON (AT H1). With this command I was able to see that the answer data was coming from the can IDs 7E8 (engine) and 7E9 (transmission). Here is an example

[Req] 01 01
[Ans] 7E8 06 41 01 00 07 E9 00 
[Ans] 7E9 06 41 01 00 04 00 00

To fix this you can execute the command AT SH 7E0. What this command does it is to tell the OBD to only listen the 7E8.

Source: This page where I asked this question too