So the code I have to consume Stanley's DTC read is:
unsigned int numberofcodes = obd.getDTCCount();
lcd.println(numberofcodes);
if (numberofcodes > 0)
{
uint16_t codes[8];
byte dtcCount = obd.readDTC(codes, numberofcodes);
if (dtcCount == 0) {
lcd.println("No DTC");
}
else
{
for (byte i = 0; i < numberofcodes; i++)
{
lcd.println(codes[i]);
}
}
}
But I get 20484 and 16896 instead of the P codes. How do I convert this into one of the P codes?
DTC codes aren't P0xxx.
Re: DTC codes aren't P0xxx.
Staaaaaanleeeeeeeey HAAALP!
Re: DTC codes aren't P0xxx.
Convert it to HEX.
Serial.println(code[i], HEX);
There is no P as all readable codes are for P (powertrain).
Serial.println(code[i], HEX);
There is no P as all readable codes are for P (powertrain).
Re: DTC codes aren't P0xxx.
I thought I tried that but I'll give it another go.
-
- Posts: 1
- Joined: Thu Feb 14, 2019 11:24 pm
Re: DTC codes aren't P0xxx.
I too face the similar issue reading the DTCs.
On converting to hex I got 100, 200, 300, 4300, 8200, c1 . I got 100,200,300 but how to match with 4300 and 8200 and c1
here is the my piece of code:
char* getDTC() {
uint16_t dtc[7] = {0};
static char dtcbuffer[100] = {0};
char dtc_codes[50] = {0};
int dtcCount = obd->readDTC(dtc, 7);
if (dtcCount > 0) {
Serial.print("DTC:");
Serial.println(dtcCount);
//Serial.print("Error codes are: ");
for (byte n = 0; n < dtcCount; n++) {
Serial.print(dtc[n],HEX);
Serial.print(", ");
sprintf(dtc_codes + strlen(dtc_codes), "%x, ", (dtc[n]));
}
//obd->clearDTC();
}
sprintf(dtcbuffer, "DTC:{%s} ", dtc_codes);
return dtcbuffer;
}
Can you please help me in getting all the DTCs and also to right way of matching the codes?
On converting to hex I got 100, 200, 300, 4300, 8200, c1 . I got 100,200,300 but how to match with 4300 and 8200 and c1
here is the my piece of code:
char* getDTC() {
uint16_t dtc[7] = {0};
static char dtcbuffer[100] = {0};
char dtc_codes[50] = {0};
int dtcCount = obd->readDTC(dtc, 7);
if (dtcCount > 0) {
Serial.print("DTC:");
Serial.println(dtcCount);
//Serial.print("Error codes are: ");
for (byte n = 0; n < dtcCount; n++) {
Serial.print(dtc[n],HEX);
Serial.print(", ");
sprintf(dtc_codes + strlen(dtc_codes), "%x, ", (dtc[n]));
}
//obd->clearDTC();
}
sprintf(dtcbuffer, "DTC:{%s} ", dtc_codes);
return dtcbuffer;
}
Can you please help me in getting all the DTCs and also to right way of matching the codes?
Re: DTC codes aren't P0xxx.
Thanks for sharing such useful ideas.
-
- Posts: 1
- Joined: Wed Sep 25, 2019 12:10 pm
Re: DTC codes aren't P0xxx.
The readDTC function does a hex2uint16 conversion in the body of the code. I am getting a fault code of 770, which seems a bit unlikely since my car has a manual transmission. Any thoughts on how to interpret this output? Can anyone confirm that the fault codes of this function are indeed being returned as integers? 0x770 would be 302 in decimal, which would indicate a cylinder misfire. This seems more likely, but seems wrong from the way the code is written. Any help on this?
Alan
Alan
-
- Posts: 1
- Joined: Thu Jan 09, 2020 8:18 am
Re: DTC codes aren't P0xxx.
Thanks for ideas. Nice!
Re: DTC codes aren't P0xxx.
A DTC code is a series of diagnostic trouble codes used by a vehicle's onboard diagnostics (OBD) system to alert you when a vehicle experiences a malfunction. These codes were created by the Society of Automotive Engineers (SAE) to help vehicles comply with emission regulations.