ELMduino icon indicating copy to clipboard operation
ELMduino copied to clipboard

How to implement custom PIDs?

Open jumpjack opened this issue 1 year ago • 7 comments

Given these data:

Name PID Expression Unit Init
Soc 229002 [B4:B5] * 0.01 % ATSP7;ATSHDADBF1;ATFCSH18DADBF1;ATFCSM1;ATCRA18DAF1DB;

How do I implement in the source code the call to PID 229002? I.E. how do I get Service and PID from number 229002?

jumpjack avatar Feb 27 '25 09:02 jumpjack

Have a look at this example sketch. ELMduino will parse the PID for you. (FYI, it's Service:0x22 and PID 0x9002 above). https://github.com/PowerBroker2/ELMduino/blob/master/examples/ESP32_CustomHeader/ESP32_CustomHeader.ino

jimwhitelaw avatar Feb 28 '25 15:02 jimwhitelaw

Have a look at this example sketch. ELMduino will parse the PID for you. (FYI, it's Service:0x22 and PID 0x9002 above). https://github.com/PowerBroker2/ELMduino/blob/master/examples/ESP32_CustomHeader/ESP32_CustomHeader.ino

So does jumpjack change myELM327.sendCommand("2204FE"); to myELM327.sendCommand("229002");

to get his desired input, then apply his needed math to get his desired value?

asking because I am looking for a ford transmission temp that is 221674 Thanks

Maximize0987 avatar Mar 04 '25 16:03 Maximize0987

@Maximize0987, yes that’s correct. In your case you would call

myELM327.sendCommand("221674”);

jimwhitelaw avatar Mar 05 '25 00:03 jimwhitelaw

any help on formulas? I am hoping to include these in a sketch would the call you stated return a and b?

ModeAndPID / Name / Min / Max Unit / Formula / Header

221674 / Trans Fluid Temp / 0 / 250 F / ((A*256)+B)/8 / 0

Maximize0987 avatar Mar 05 '25 00:03 Maximize0987

@jimwhitelaw

@Maximize0987, yes that’s correct. In your case you would call

myELM327.sendCommand("221674”);

So I think I need to check the different bytes to find the A and B values then apply the math until I find a

answer that equals my scan tool

in the example int A = myELM327.payload[6];

I found in another git someone was looking for 221e1c trans temp where I have the formula (((A256)+B)(9/8)+320)/10

their sketch used rxWord1[9] and rxWord1[12] in their equation

so I'll start with payload[9] and payload[12] and then try offsets from there.

CAN YOU RECOMMEND A INEXPENSIVE BLUETOOTH OBD ADAPTER THAT IS SAFE TO NOT KILL THE BATTERY WHEN PARKED????

THanks again

Maximize0987 avatar Mar 06 '25 15:03 Maximize0987

Part of the challenge is that every manufacturer can have their own definition for a custom PID and how to process it. So a spec found for a particular PID on one vehicle isn’t necessarily valid for another vehicle. See this for info on OBD2 responses:

https://en.wikipedia.org/wiki/OBD-II_PIDs#Standard_PIDs

OBD2 spec requires the vehicle to supply constant 12v power to the OBD2 port. I don’t know of any adapters that have a shutdown or sleep feature.

jimwhitelaw avatar Mar 06 '25 16:03 jimwhitelaw

@jimwhitelaw

EDIT: I just tested an alternative header "7E0" and its working

Thanks for helping me get me started Jim

ok that is not my biggest concern I have a obdlink mx+ that seems to be working, I just wouldn't prefer to have a $140 device set to this task if it can be done with a < $30 device.

I just did a test run with errors, and I'm not sure atm if I have correct header, and if so I am getting timeouts of 0ms which seems like with bluetooth is a very short timeout.

09:26:12.590 Connected to CP210x device 09:26:16.355 Clearing input serial buffer 09:26:16.359 Sending the following command/query: AT D 09:26:16.368 ^IReceived char: A 09:26:16.370 ^IReceived char: T 09:26:16.373 ^IReceived char: _ 09:26:16.373 ^IReceived char: D 09:26:16.374 ^IReceived char: \r 09:26:16.376 ^IReceived char: O 09:26:16.378 ^IReceived char: K 09:26:16.380 ^IReceived char: \r 09:26:16.382 ^IReceived char: \r 09:26:16.383 ^IReceived char: > 09:26:16.385 Delimiter found. 09:26:16.387 All chars received: ATDOK 09:26:16.478 Clearing input serial buffer 09:26:16.481 Sending the following command/query: AT Z 09:26:16.720 ^IReceived char: A 09:26:16.722 ^IReceived char: T 09:26:16.723 ^IReceived char: _ 09:26:16.725 ^IReceived char: Z 09:26:16.727 ^IReceived char: \r 09:26:17.350 ^IReceived char: \r 09:26:17.353 ^IReceived char: \r 09:26:17.353 ^IReceived char: E 09:26:17.355 ^IReceived char: L 09:26:17.357 ^IReceived char: M 09:26:17.358 ^IReceived char: 3 09:26:17.360 ^IReceived char: 2 09:26:17.362 ^IReceived char: 7 09:26:17.363 ^IReceived char: _ 09:26:17.364 ^IReceived char: v 09:26:17.366 ^IReceived char: 1 09:26:17.368 ^IReceived char: . 09:26:17.370 ^IReceived char: 4 09:26:17.372 ^IReceived char: b 09:26:17.373 ^IReceived char: \r 09:26:17.375 ^IReceived char: \r 09:26:17.378 ^IReceived char: > 09:26:17.379 Delimiter found. 09:26:17.380 All chars received: ATZELM327v1.4b 09:26:17.471 Clearing input serial buffer 09:26:17.475 Sending the following command/query: AT E0 09:26:17.519 ^IReceived char: A 09:26:17.522 ^IReceived char: T 09:26:17.523 ^IReceived char: _ 09:26:17.525 ^IReceived char: E 09:26:17.526 ^IReceived char: 0 09:26:17.547 ^IReceived char: \r 09:26:17.549 ^IReceived char: O 09:26:17.551 ^IReceived char: K 09:26:17.552 ^IReceived char: \r 09:26:17.554 ^IReceived char: \r 09:26:17.555 ^IReceived char: > 09:26:17.557 Delimiter found. 09:26:17.558 All chars received: ATE0OK 09:26:17.650 Clearing input serial buffer 09:26:17.653 Sending the following command/query: AT S0 09:26:17.708 ^IReceived char: O 09:26:17.710 ^IReceived char: K 09:26:17.712 ^IReceived char: \r 09:26:17.714 ^IReceived char: \r 09:26:17.715 ^IReceived char: > 09:26:17.717 Delimiter found. 09:26:17.719 All chars received: OK 09:26:17.809 Clearing input serial buffer 09:26:17.813 Sending the following command/query: AT AL 09:26:17.848 ^IReceived char: O 09:26:17.849 ^IReceived char: K 09:26:17.852 ^IReceived char: \r 09:26:17.853 ^IReceived char: \r 09:26:17.854 ^IReceived char: > 09:26:17.857 Delimiter found. 09:26:17.859 All chars received: OK 09:26:17.950 Clearing input serial buffer 09:26:17.953 Sending the following command/query: AT ST 00 09:26:18.009 ^IReceived char: O 09:26:18.012 ^IReceived char: K 09:26:18.013 ^IReceived char: \r 09:26:18.015 ^IReceived char: \r 09:26:18.016 ^IReceived char: > 09:26:18.018 Delimiter found. 09:26:18.020 All chars received: OK 09:26:18.111 Clearing input serial buffer 09:26:18.114 Sending the following command/query: AT SP A0 09:26:18.191 ^IReceived char: O 09:26:18.193 ^IReceived char: K 09:26:18.194 ^IReceived char: \r 09:26:18.196 ^IReceived char: \r 09:26:18.198 ^IReceived char: > 09:26:18.200 Delimiter found. 09:26:18.201 All chars received: OK 09:26:18.203 Clearing input serial buffer 09:26:18.206 Sending the following command/query: 0100 09:26:18.210 ^IReceived char: S 09:26:18.211 ^IReceived char: E 09:26:18.213 ^IReceived char: A 09:26:18.214 ^IReceived char: R 09:26:18.216 ^IReceived char: C 09:26:18.218 ^IReceived char: H 09:26:18.219 ^IReceived char: I 09:26:18.221 ^IReceived char: N 09:26:18.223 ^IReceived char: G 09:26:18.224 ^IReceived char: . 09:26:18.227 ^IReceived char: . 09:26:18.228 ^IReceived char: . 09:26:18.229 ^IReceived char: \r 09:26:18.775 ^IReceived char: S 09:26:18.777 ^IReceived char: T 09:26:18.778 ^IReceived char: O 09:26:18.781 ^IReceived char: P 09:26:18.783 ^IReceived char: P 09:26:18.784 ^IReceived char: E 09:26:18.785 ^IReceived char: D 09:26:18.787 ^IReceived char: \r 09:26:18.788 ^IReceived char: \r 09:26:18.790 ^IReceived char: > 09:26:18.792 Delimiter found. 09:26:18.793 All chars received: SEARCHING...STOPPED 09:26:18.798 ELM responded with error "STOPPED" 09:26:18.800 Setting protocol via AT TP A%c did not work - trying via AT SP %c 09:26:18.806 Clearing input serial buffer 09:26:18.808 Sending the following command/query: AT SP 0 09:26:18.831 ^IReceived char: O 09:26:18.831 ^IReceived char: K 09:26:18.832 ^IReceived char: \r 09:26:18.834 ^IReceived char: \r 09:26:18.836 ^IReceived char: > 09:26:18.837 Delimiter found. 09:26:18.839 All chars received: OK 09:26:18.841 Connected to ELM327 09:26:18.843 Clearing input serial buffer 09:26:18.845 Sending the following command/query: ATSH 7e1 09:26:18.851 ^IReceived char: O 09:26:18.853 ^IReceived char: K 09:26:18.855 ^IReceived char: \r 09:26:18.856 ^IReceived char: \r 09:26:18.858 ^IReceived char: > 09:26:18.860 Delimiter found. 09:26:18.861 All chars received: OK 09:26:18.863 Clearing input serial buffer 09:26:18.866 Sending the following command/query: 221E1C 09:26:18.870 ^IReceived char: S 09:26:18.872 ^IReceived char: E 09:26:18.873 ^IReceived char: A 09:26:18.875 ^IReceived char: R 09:26:18.877 ^IReceived char: C 09:26:18.878 ^IReceived char: H 09:26:18.880 ^IReceived char: I 09:26:18.882 ^IReceived char: N 09:26:18.884 ^IReceived char: G 09:26:18.886 ^IReceived char: . 09:26:18.886 ^IReceived char: . 09:26:18.888 ^IReceived char: . 09:26:18.890 ^IReceived char: \r 09:26:20.860 Timeout detected with overflow of 0ms 09:26:20.862 Received: SEARCHING... 09:26:20.865 ERROR: ELM_TIMEOUT 09:26:25.960 Clearing input serial buffer 09:26:25.962 Sending the following command/query: 221E1C 09:26:27.958 Timeout detected with overflow of 0ms 09:26:27.962 Received: 09:26:27.963 ERROR: ELM_TIMEOUT 09:26:33.059 Clearing input serial buffer 09:26:33.062 Sending the following command/query: 221E1C 09:26:35.058 Timeout detected with overflow of 0ms 09:26:35.061 Received: 09:26:35.062 ERROR: ELM_TIMEOUT 09:26:40.158 Clearing input serial buffer 09:26:40.160 Sending the following command/query: 221E1C 09:26:42.156 Timeout detected with overflow of 0ms 09:26:42.160 Received: 09:26:42.161 ERROR: ELM_TIMEOUT 09:26:47.256 Clearing input serial buffer 09:26:47.259 Sending the following command/query: 221E1C 09:26:49.255 Timeout detected with overflow of 0ms 09:26:49.259 Received: 09:26:49.260 ERROR: ELM_TIMEOUT 09:26:54.356 Clearing input serial buffer 09:26:54.358 Sending the following command/query: 221E1C 09:26:56.355 Timeout detected with overflow of 0ms 09:26:56.358 Received: 09:26:56.359 ERROR: ELM_TIMEOUT 09:27:01.455 Clearing input serial buffer 09:27:01.457 Sending the following command/query: 221E1C 09:27:03.454 Timeout detected with overflow of 0ms 09:27:03.457 Received: 09:27:03.458 ERROR: ELM_TIMEOUT 09:27:04.303 Disconnected

Maximize0987 avatar Mar 06 '25 16:03 Maximize0987