Hello all,
As always, I'm not sure if this is the right section & if it isn't, please feel free to move it.
Anyway, I am working on a sketch that queries the OBD port on my 2023 Toyota Tacoma for info on transmission temps, battery voltage, and a couple of other values, and processes the data into human-readable values that display on a 4" TFT.
After a quest worthy of Sir Lancelot, I have the relevant codes for my truck. They are as follows:
Battery voltage:
Header 701 Mode 22 PID 1F42
Returns 2 bytes
Transmission pan temp.
Header 701 Mode 22 PID 1627
Returns one byte
torque converter return oil temp.
Header 701 Mode 22 PID 1628
Returns one byte
Engine coolant temp.
Header 701 Mode 22 PID 1F05
Returns one byte
Transmission current gear.
Header 701 Mode 22 PID 1621
Returns one byte
torque converter lock status
Header 701 Mode 22 PID 1620
Returns one byte
The sketch has a struct that holds the data to be transmitted:
struct canMsg1;
canMsg1.can_id = 0x16;
canMsg1.can_dlc = 8;
canMsg1.data[0] = 0x00;
canMsg1.data[1] = 0x00;
canMsg1.data[2] = 0x00;
canMsg1.data[3] = 0x00;
canMsg1.data[4] = 0x00;
canMsg1.data[5] = 0x00;
canMsg1.data[6] = 0x00;
canMsg1.data[7] = 0x00;
//The send message command:
mcp2515.sendMessage(&canMsg1);
My first question is where do I place the OBD header (always 701)? The first struct value is the ID, which I assume is the mode (always 22). The dlc is the length, I think. I don't know if that is the value of the expected return, or just leave it at 8. There is a lot of confusing information out there, it's akin to listening for the sound of a pin dropping on a pillow in the middle of an AC/DC concert. Any and all advice is appreciated. TIA.
Gary
Edit: I'm happy to include any other information needed. The entire sketch is cumbersome, being mostly touchscreen and display stuff.