Skip to content

Instantly share code, notes, and snippets.

@MrPoofy
Last active April 12, 2023 08:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save MrPoofy/8450b725ec45988c27e5e59bb99be383 to your computer and use it in GitHub Desktop.
List of PIDs and calculations to retrieve Fiat 500e (2020 version) information from OBD
var command = [
"ATZ",
"ATD",
"ATE0",
"ATS0",
"ATAL",
"ATH0",
"ATSP7",
"ATCP18"
];
var command = [
"ATSHDA44F1",
"ATFCSH18DA44F1",
"ATCRA18DAF144",
"22A029",
"22A010",
"22A009",
"22A011",
"22A00A",
"22A042",
"ATSHDA40F1",
"ATFCSH18DA40F1",
"ATCRA18DAF140",
"22013C"
];
// SOH calc
// > 22A029
// 00A
// 0:62A029F9FFOO
// 1:04B00493000000
// ahrTotRead = [1][0-3]
// ahrResRead = [1][4-7]
var ahrTotRead = parseInt("04B0", 16)/10;
var ahrResRead = parseInt("0493", 16)/10;
var REAL_SOH = Math.round((ahrResRead/ahrTotRead)*1000)/10;
console.log("REAL_SOH: ", REAL_SOH);
// SOC
// > 22A010
// 009
// 0:62A0106D6D6C
// 1:6E6C6B00000000
// SOC [0][10-11]
var SOC = (parseInt("6C", 16)/255)*100;
console.log("SOC: ", SOC);
// VOLT MIN & MAX
// > 22A009
// OOF
// 0:62A009390F0E
// 1:350E3101108013
// 2:80120000000000
// voltMax [0][10-11] [1][0-1]
// voltMax [1][2-5]
var voltMax = parseInt("0E35", 16)/1000;
var voltMin = parseInt("0E31", 16)/1000;
var voltDelta = voltMax - voltMin;
console.log("voltMax: ", voltMax);
console.log("voltMin: ", voltMin);
console.log("voltDelta: ", voltDelta);
// BATERY TEMP
// > 22A009
// 00F
// 0:624009390F0E
// 1:360E3101108013
// 2:80120000000000
// baterytempRead [1][12-13]
var baterytempRead = parseInt("13", 16);
if(baterytempRead >= 128 ){
baterytempRead = baterytempRead - 256;
}
var bateryTemp = baterytempRead;
console.log("bateryTemp Celsius: ", bateryTemp);
// VOLT
// > 22A011
// 022
// 0:62A0110DA20D
// 1:A10DA0125FOCDA
// 2:0CC60B8F0CCBOC
// 3:C60CC50CC70D9F
// 4:04125F0B8F125E
// VOLT [1][2-5]
var VOLT = parseInt("0DA0", 16)/10
console.log("VOLT: ", VOLT);
// AMPERE
// > 22A00A
// 62A00A80108039
// AMPERE [6-9]
var AMPERE = ((parseInt("8010", 16)-32768)/20);
console.log("AMPERE: ", AMPERE);
// OBD VOLT
// > 22A042
// 62A0423723
// obdVolt [6-9]
var obdVolt = parseInt("3723", 16)/1000;
console.log("obdVolt: ", obdVolt);
// AMBIENT TEMP
// > 22013C
// 62013C70
// ambientTemp [6-7]
var ambientTemp = (parseInt("70", 16)/2)-40;
console.log("ambientTemp Celsius: ", ambientTemp);
KW = Math.round((VOLT*AMPERE)/100)/10;
console.log("KW: ", KW);
@SamuelBrucksch
Copy link

SamuelBrucksch commented Mar 31, 2023

@MrPoofy , thanks for providing these in the first place. PID commands are normally 22xxxx, so they have 4 digits/chars after the 22, yours have 5. Could you please try if it works if you omit the last one too?

So like this:

var command = [
	"22A029",
	"22A010",
	"22A009",
	"22A011",
	"22A00A",
	"22A042",
	"22013C"
	];

We had the same on other cars previously and the extra digit actually didn't have any effect at all, so to avoid confusion and to avoid any upcoming issues in our OBD parser we try to avoid those...

@MrPoofy
Copy link
Author

MrPoofy commented Apr 1, 2023

Hi @SamuelBrucksch!

Just checked and i can confirm that you can remove the last digit for the command list. I already updated the list of data commands from the gist and i also updated the init commands list because i missed some.

@SamuelBrucksch
Copy link

SamuelBrucksch commented Apr 2, 2023

Hi @MrPoofy

thanks for updating. So one last adjustment before putting this into a json for ABRP, we normally don't have such an extended init list. Also we use ATH0, to avoid getting the headers in front of the message, the reason is as simple as that it makes parsing easier if we do not need to deal with the header.

So can you please try the following:

  • remove ATH1 (or set it to ATH0)

As sample for soh it should rather look like this then:
before:

18DAF144 100A62A029F9FF00
18DAF144 2104B00493000000

after:

0A62A029F9FF001:04B00493000000

or similiar.

Once that is confirmed to work as expected we can convert it into our internal format and it can be deployed in a very short time (please also update the data responses so we can check if they are in the format we expect).

@MrPoofy
Copy link
Author

MrPoofy commented Apr 3, 2023

HI @SamuelBrucksch!

Thank you so much for the help on this. I took a better lock at the init list commands that you said looked a bit extended and after some tests I checked exactly what commands are really necessary and the ones that aren't.

I noticed that the command for SOH, SOC, VOLT, AMPERE, OBD VOLT and BATERY TEMP only work if you pre-execute the commands "ATSHDA44F1", "ATFCSH18DA44F1" and "ATCRA18DAF144" and the AMBIENT TEMPERATURE only works if you pre-execute the commands "ATSHDA40F1", "ATFCSH18DA40F1" and "ATCRA18DAF140". But if we execute the commands "ATSHDA40F1", "ATFCSH18DA40F1" and "ATCRA18DAF140" the commands for SOH, SOC, VOLT, AMPERE, OBD VOLT and BATERY TEMP stop working. So they need to be executed in the right order.

I also tested with the ATH0 just as you requested and i can confirm i get something on the lines of what you shown as an example.
I'm leaving a test print screen from Car Scanner Terminal that i use to test all this commands and the resulting responses from them.

SCR-20230403-tz5

@SamuelBrucksch
Copy link

Awesome, this looks exactly like what we need, i'll convert it into our internal format and let you know when it is available for testing.

@SamuelBrucksch
Copy link

SamuelBrucksch commented Apr 4, 2023

Oh one other note, you miss the ATSPx command, should be ATSP6 or ATSP7 normally, can you please check that one? Because some adapters are slow in auto mode, and then the requests time out and we get an error in ABRP, so we prefer to set the right protocol in the init sequence. Maybe it was there initially, so please add the ATSP command.

Edit:
NVM, i just saw it was ATSP7 before, so i'll just take that one when converting it.

@MrPoofy
Copy link
Author

MrPoofy commented Apr 4, 2023

Hi @SamuelBrucksch!

I can confirm, its "ATSP7". I just missed it on the list. I will add it.

@SamuelBrucksch
Copy link

SamuelBrucksch commented Apr 5, 2023

I'm currently adding this to our backend, i just saw that for SoH you seem to use the capacity in Ah, do you also get that value in kWh? We could use that too, total available capacity in kWh (i guess it is the same as ahrResRead? in kWh)

@SamuelBrucksch
Copy link

@MrPoofy i just deployed it, please give it a try

@SamuelBrucksch
Copy link

SamuelBrucksch commented Apr 6, 2023

@MrPoofy for wrong SoC we have more values we can try:

// SOC
// > 22A010
// 009
// 0:62A0106D6D6C
// 1:6E6C6B00000000
// SOC [0][10-11]

In that sequence we have 6D, 6C, 6E, 6B which are all pretty close together and would translate to
6B->107 = 41,96%
6C->108 = 42,35%
6D->109
6E->110 = 45,08%

As the values below 50% should be a bit higher than what the BMS shows (in this case 6C), one of the other values could actually be display soc. I think the best way to find out is to go as low as possible (5-10%) and compare all these values to display, and do the same for 90-100%

But doing it in the low range should actually already provide a good insight on which one is the correct one.

@MrPoofy
Copy link
Author

MrPoofy commented Apr 6, 2023

Hi @SamuelBrucksch!

I will see what i can do! It will take a bit, i'm out of town at the moment but next week i can check the values.

@SamuelBrucksch
Copy link

Hey @MrPoofy

thanks, if you are on it please try somethign else too:

  "ATSHDA40F1",
  "ATFCSH18DA40F1",
  "ATCRA18DAF140",

Some dongles do not support the long ATCRA commands, in that case we need to use ATCP18 before i think. So this one should be

  "ATSHDA40F1",
  "ATCP18",
  "ATFCSHDA40F1",
  "ATCRADAF140",

If i remember correctly. CP18 should be the default though and i think we can omit it completely:

  "ATSHDA40F1",
  "ATFCSHDA40F1",
  "ATCRADAF140",

Could you please check that?

@MrPoofy
Copy link
Author

MrPoofy commented Apr 6, 2023

Hi @SamuelBrucksch!

I took a look at the list of PIDs that i had previously and "ATCP18" was there, i would say that we can add it as well to the list.

From the old list:
var init_command = [ "ATWS", "ATWS", "ATWS", "ATE0", "ATI", "AT@1", "ATAT1", "ATH1", "ATL0", "ATS0", "ATAL", "ATSP7", "ATCP18", "ATSHDA40F1", "ATFCSH18DA40F1", "ATFCSD300000", "ATFCSM1", "ATCFC1", "ATCAF1", "ATCRA18DAF140" ];

Do you see anything that could also help us?

@SamuelBrucksch
Copy link

SamuelBrucksch commented Apr 6, 2023

Yes let's include the ATCP18 again, as that could have an influence on the ATSH command:
image

Many of the others are for formatting, but i'll check again if any of these is relevant.

@MrPoofy
Copy link
Author

MrPoofy commented Apr 12, 2023

@MrPoofy for wrong SoC we have more values we can try:

// SOC
// > 22A010
// 009
// 0:62A0106D6D6C
// 1:6E6C6B00000000
// SOC [0][10-11]

In that sequence we have 6D, 6C, 6E, 6B which are all pretty close together and would translate to 6B->107 = 41,96% 6C->108 = 42,35% 6D->109 6E->110 = 45,08%

As the values below 50% should be a bit higher than what the BMS shows (in this case 6C), one of the other values could actually be display soc. I think the best way to find out is to go as low as possible (5-10%) and compare all these values to display, and do the same for 90-100%

But doing it in the low range should actually already provide a good insight on which one is the correct one.

Hi @SamuelBrucksch!

Sorry about the delay but i was able to create a list with the displayed SOC and the calculated SOC retrieved from the OBD2 port.

I checked the other values from the response and none seem to be the display SOC but you can see here https://docs.google.com/spreadsheets/d/10EZMmmperrv-VWa_TjmzG5to68-SZ6KpvF6UFSXJ0Ck/edit?usp=sharing the deltas between the 2 values.

@SamuelBrucksch
Copy link

Nice, thanks for the comparison, i'll use your values then to calculate a proper offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment