Skip to content

Instantly share code, notes, and snippets.

@MrPoofy
Last active April 17, 2024 23:18
Show Gist options
  • Save MrPoofy/8450b725ec45988c27e5e59bb99be383 to your computer and use it in GitHub Desktop.
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 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