I followed the instructions in the AN017 TRACKER CAN docs. I got the TrackerOne and OBD-2 connected and I’m reading from the OBD-2 port of my vehicle using your sample code from github. However, I’m not getting the RPM data. If I understand correctly, the response should start with the OBD_CAN_REPLY_ID (7e8). Below is an example of what the canInterface.readMsgBufID is reading. I let it run for 15 minutes and never got the 7e8 code. Could it be different on my car? How can I find this info?
0000093767 [app] INFO: 16c: ff ff ff ff ff ff
0000094771 [app] INFO: 379: ff ff ff ff ff ff
0000095774 [app] INFO: 02f: b3 1e 49 21 ff 1f
0000096778 [app] INFO: 3e8: ff 99 00 00 00 00
0000097781 [app] INFO: 03d: 99 01 00 00 00 00
0000098785 [app] INFO: 02f: 83 1b 48 21 00 20
0000099789 [app] INFO: 353: 38 00 03 fc e0 e0
0000100792 [app] INFO: 49e: ff ff ff 00 00 00
0000101796 [app] INFO: 0b1: 86 05 7f 00 00 d0
0000102800 [app] INFO: 0a1: 3a a4 00 00 02 00
0000103803 [app] INFO: 2b9: 00 00 00 57 6e 81
0000104807 [app] INFO: 098: 04 08 00 00 00 00
Modern cars often have multiple CAN buses (e.g. slow and fast bus) maybe you are listening to the wrong one.
Have you found out which messages you are receiving? This way you should be able to tell which bus you are listening to.
BTW, isn’t 0x00C the PID for engine RPM?
What ScruffR said. It’s quite possible that the ECU does not respond to a request for PID_ENGINE_RPM.
Make sure you’re requesting the right code. OBD-II is not a constant stream of everything going on in your car sent by the engine computer. You need to send the request for the PID you want using sendMsgBuf so make sure that call is not failing as well.
From the sample code:
Request and Reply codes:
const uint32_t OBD_CAN_REQUEST_ID = 0x7DF;
const uint32_t OBD_CAN_REPLY_ID = 0x7E8;
The RPM code:
const uint8_t PID_ENGINE_RPM = 0x0C;
The request:
byte obdRequest[8] = {0x02, SERVICE_CURRENT_DATA, PID_ENGINE_RPM, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc};
Sending the request:
byte sndStat = canInterface.sendMsgBuf(OBD_CAN_REQUEST_ID, 0, 8, obdRequest);
Receiving the response:
canInterface.readMsgBufID(&rxId, &len, rxBuf);
Reading the response code:
if ((rxId & 0x80000000) == 0x00000000) {
// Standard frame
Log.info("%.3lx: %02x %02x %02x %02x %02x %02x ", rxId, rxBuf[0], rxBuf[1], rxBuf[2], rxBuf[3], rxBuf[4],rxBuf[5] );
if (rxId == OBD_CAN_REPLY_ID && rxBuf[0] == 0x04 && rxBuf[1] == 0x41 && rxBuf[2] == PID_ENGINE_RPM) {
lastRPM = (rxBuf[3] << 8) | rxBuf[4];
lastRPM /= 4;
Log.info("rpm=%d", lastRPM);
// We don't process the RPM here, it's done below (with an explanation why)
}
}
That Log.info statement above is where I got the listing of responses in my initial question above. So I know I’m getting to that point and I’m reading the responses. I’m just not getting the “7E8” response which is what I need to enter the lastRPM if statement.
I’m not sure why it’s not working for you. Is the vehicle by chance a heavy-duty truck? There is a possibility that it is using 29-bit CAN PIDs instead of the 11-bit identifiers used in the app note. I’ve never tried to read them, but the CAN library supports them. The code would be different for sending the request and reading the response, however.
No, it’s a 2019 Mercedes coup. I’ve been searching for a source to verify the expected codes, but I haven’t had any luck. The pinout is correct and I’m obviously getting data. I just don’t know how to interpret it. Do you have any idea where I could find such information?
Otherwise, I guess I’ll try another vehicle.
I tried my code on a 2008 Nissan Murano and it worked perfectly. I’m still not sure why it’s not working on my car, but at least I can continue my project. Thanks for your help, guys!