ELMduino icon indicating copy to clipboard operation
ELMduino copied to clipboard

Protocol Data Point

Open Fichte79 opened this issue 2 years ago • 4 comments

Hello everyone

With which data point can I see which protocol the ELM327 communicates with the vehicle?

I would like to see which protocol is used.

Best regards

Fichte79 avatar Mar 04 '24 07:03 Fichte79

use sendCommand("ATDP") to get the name of the current protocol. AT command "DPN" will return the protocol number.

jimwhitelaw avatar Mar 04 '24 17:03 jimwhitelaw

I would also like to know which protocol is actually used by the ELM327 to communicate with the vehicle.

I am using ESP32 + Vgate iCar2.

When using sendCommand("ATDP"), it seems to only show AUTO:

ELM responded with error "UNABLE TO CONNECT"
Setting protocol via AT TP A%c did not work - trying via AT SP %c
Clearing input serial buffer
Sending the following command/query: AT SP 0
	Received char: O
	Received char: K
	Received char: \r
	Received char: \r
	Received char: >
Delimiter found.
All chars received: OK
Setting protocol via AT SP %c did not work
Connected to ELM327
Clearing input serial buffer
Sending the following command/query: AT DP
	Received char: A
	Received char: U
	Received char: T
	Received char: O
	Received char: \r
	Received char: \r
	Received char: >
Delimiter found.
All chars received: AUTO

When using sendCommand("ATDPN"), only A0 is displayed:

ELM responded with error "UNABLE TO CONNECT"
Setting protocol via AT TP A%c did not work - trying via AT SP %c
Clearing input serial buffer
Sending the following command/query: AT SP 0
	Received char: O
	Received char: K
	Received char: \r
	Received char: \r
	Received char: >
Delimiter found.
All chars received: OK
Setting protocol via AT SP %c did not work
Connected to ELM327
Clearing input serial buffer
Sending the following command/query: AT DPN
	Received char: A
	Received char: 0
	Received char: \r
	Received char: \r
	Received char: >
Delimiter found.
All chars received: A0

wcjxixi avatar Mar 06 '24 03:03 wcjxixi

After setting the auto protocol (ATSP0 or ATTP0), you also need to make a request to initiate the protocol search and then wait for the protocol negotiation to complete. Easiest way to do that is to send command "0100".

Once that returns, you can check which protocol was negotiated.

jimwhitelaw avatar Mar 06 '24 04:03 jimwhitelaw

After setting the auto protocol (ATSP0 or ATTP0), you also need to make a request to initiate the protocol search and then wait for the protocol negotiation to complete. Easiest way to do that is to send command "0100".

Once that returns, you can check which protocol was negotiated.

@jimwhitelaw THX! I also learnt the way to get the data returned by sendCommand_Blocking, the way of sendCommand should be similar, right?

The example code is as follows, others can refer to:

char obdProtocolCode = 0;
......
myELM327.sendCommand_Blocking("0100");
if (myELM327.nb_rx_state == ELM_SUCCESS) {
  myELM327.sendCommand_Blocking("ATDPN");
  if (myELM327.nb_rx_state == ELM_SUCCESS) {
    myELM327.get_response();
    obdProtocolCode = myELM327.payload[1];
  }
}
Serial.println("OBD Protocol: " + String(obdProtocolCode));

wcjxixi avatar Mar 06 '24 06:03 wcjxixi