Toyota GR Yaris Forum banner

Reverse engineering PIDs

2 reading
72K views 149 replies 36 participants last post by  Helmut Eder  
#1 · (Edited)
Thanks to https://gr-yaris.co.uk/forum/threads/oil-pressure-and-other-info-over-obd.4379/ we now know that selecting Toyota Camry 2020 in OBDLink Android app gives us access to additional sensors.

It is relatively easy to snoop Bluetooth traffic on Android devices from bugreports or even live. So I selected a couple of sensors in OBDLink on continuous monitoring and looked into the BT traffic using Wireshark. Here is a little snippet from the quite verbose conversation:

Capture.PNG


These are ELM327 microcontroler, that runs inside OBDLink, AT protocol commands. Interesting ones here are:
* ATSH 0007D0 - sets OBD header for all subsequent OBD commands
* 2162 - queries OBD Mode 21 PID 62 and gets 7D8 05 61 62 03 00 00 0 as a response

First three hex digits in the response (7D8) is the ID of the ECU that has sent the response. Next three bytes (05 61 62) I am not sure what they are. And next three bytes (03 00 00) is the actual data that could be interesting.

So here is the short list of OBD Headers, Modes and PIDs that I was able to figure out from the first initial look and from subsequent help of other forum members below:

SensorCategoryModePIDHeaderFormulaDiag Command
This item indicates that the parking brake is "ON/OFF"Navigation System21627D0BIT(A:1)
Accelerator PositionEngine221059700(A-41) / 1.42
Engine Oil PressureEngine221074700(((A*256)+B) * 10) / 128
M/T Oil TemperatureEngine221638700A + B/256 - 40
+B VoltageCombination Meter2210217C0A/10
Fuel InputCombination Meter2210227C0???
Sub FuelCombination Meter2210237C0???
Fuel Pressure (High)Engine221F6D700???
Fuel Pressure (Low) / Fuel Pressure 2Engine221F6D700???
Intake Manifold Absolute PressureEngine221F87700???
Low Fuel Pressure SensorEngine2210CD700???
ExDID_1BE1Engine221BE1700???
ExDID_15F7Engine2215F7700???
ExDID_1F07Engine221F07700???
Tire ID 1 PressureTPM221005750B * 0.01373atcea2A
atta2A
Tire ID 2 PressureTPM221005750D * 0.01373atcea2A
atta2A
Tire ID 3 PressureTPM221005750F * 0.01373atcea2A
atta2A
Tire ID 4 PressureTPM221005750H * 0.01373atcea2A
atta2A
Tire ID 1 TemperatureTPM221004750A - 40atcea2A
atta2A
Tire ID 2 TemperatureTPM221004750B - 40atcea2A
atta2A
Tire ID 3 TemperatureTPM221004750C - 40atcea2A
atta2A
Tire ID 4 TemperatureTPM221004750D - 40atcea2A
atta2A
Tire ID 1 PositionTPM222021750LOOKUP(A::1=FL:2=FR:3=RL:4=RR)atcea2A
atta2A
Tire ID 2 PositionTPM222021750LOOKUP(B::1=FL:2=FR:3=RL:4=RR)atcea2A
atta2A
Tire ID 3 PositionTPM222021750LOOKUP(C::1=FL:2=FR:3=RL:4=RR)atcea2A
atta2A
Tire ID 4 PositionTPM222021750LOOKUP(D::1=FL:2=FR:3=RL:4=RR)atcea2A
atta2A
Steering Angle2210047B3((SIGNED(A)*256)+B)*1.5
Master Cylinder Sensor TemperatureBrake2210067B0A-80
Temperature Sensor Value in CouplingFour Wheel Drive2210267B1(A*256+B)/128
??? formulas are the tricky part

So this is not much yet, but at least I hope this is enough information for anyone of you to join into this reverse engineering party. :)

CSV file that can be imported into Torque app for the custom PIDs can be found here: https://github.com/2m/gry/blob/main/exportedPIDs.csv
 
#2 ·
As soon as I have some spare time I will contribute to this. I have a reasonable amount of can decoding done for our race car and a tonne of can recording data to go through. Not sure how much will be useful for you guys as I have been focusing on making stuff work without original controllers rather than getting access to data.
 
#4 ·
So PID is what toyota calls thier CAN DBC files?
Yea, kind of. These things are quite interlinked. When using OBD adapter, our apps do not talk CAN protocol. They talk OBD protocol and then OBD adapter translates that to CAN protocol and sends that to car. So the purpose of this thread is to reverse OBD protocol PIDs since most of us use OBD adapters.

There is an effort to reverse engineer CAN protocol messages as well: https://github.com/commaai/opendbc That is way more powerful, but requires a different adapter as well: https://comma.ai/shop/products/panda
 
#5 ·
I have put together some can bus logging stuff but trying to reverse engineer what data is in the different PID packets is a pain. Are there any good tools that can help to understand what is what? I've recorded traffic and I wrote code that visualized (graphs) of how the data changed over time but it's still a pain.
 
#7 ·
Are there any good tools that can help to understand what is what?
Yea, I do not know currently of any. My best bet is BT snooping, where we can at least use the information from the app on what PID has what information. In that case only the formula is left to be figured out. But again, we are playing off selecting Toyota Camry in the app, so GRY might have even more PIDs exposed.

I've recorded traffic and I wrote code that visualized (graphs) of how the data changed over time but it's still a pain.
Yea, but unfortunately it seems that is what most folks are doing:
and https://github.com/alexandreblin/python-can-monitor

Torque pro on Android, it lists all OBD2 ids and shows if you get data or not on each of them
I tried that briefly, but with the default OBD header and did not get too much results. However now with the OBD headers found via BT snooping Torque might give more results. But such discovered PIDs are not really that useful as we do not know the formula, neither any other information what values these PIDs represent.
 
#6 ·
To find all data that is available over OBD2 in the GRY (not "raw" CAN) just run Torque pro on Android, it lists all OBD2 ids and shows if you get data or not on each of them. There are for example four different throttle data channels active on the GRY (pedal, throttle body and two more)
 
#8 · (Edited)
Nice work, good to see my post was useful! These are a couple of (extended?) PID's in obdlink that I logged that had values attached to them that actually changed/had a range, not sure how they correlate to your pid's
ExDID_1BE1 - 6, range 0-16
ExDID_15F7 - 135.8, range 135-136
ExDID_1F07 - 112.67, range 111-121
(Not sure if first number is current or avg tbh)

I haven't driven much due to lockdown so haven't been able to do a lot with this stuff.
 
#11 ·
not sure how they correlate to your pid's
These actually have PID in their names. ExDID_1BE1 means thats its OBD Mode 221 and PID BE1. :)

I was able to get live BT traffic using an older Moto G 2014 phone that runs Android 7 using these instructions. This allowed me quite quickly to figure out PIDs for the senors mentioned in this thread above. I have updated the table in the first post.

Of course formulas are the missing piece to all of this now.
 
#134 ·
Great finds dvim!

I guess you all have the list of OBD2 items that the GRY actually transmits, but I ran a scan and thought I'd post it for reference. Some GPS and other sensor data from the Android phone are always included in the Torque app also.

View attachment 21365
i see there are 2 transmission temperatures listed. my version of Torque Plus, downloaded last week, does not have either of these. any comment??

im also trying to work out if there is a PID for the individual wheel speed sensors. anyone care to comment??
 
#15 · (Edited)
I used the built in CAN driver in an ESP32 and an external SN65HVD230 transceiver. Actually ran a second external CAN driver MCP2515 and transceiver to make it a CAN bridge where I can choose what to transfer/repackage between the two CAN networks. The setup works with all CAN buses I've tried on a BMW M2 and Toyota Aygo. ALL data packages are also sent formated in clear text over the USB port (if you choose so) to save to disk on a pc. I also have a bunch of python scripts to search these logs, visualize data with graphs, count and look for anything with a specific number of occurances (push a switch n times, search the log for anything with n or n*x occurances and so on) Found all buttons on the wheel and center console for example.

Here's one use as an example: https://github.com/MagnusThome/BMW-M2-DCT-Gear-indicator
 
#17 ·
Motivated by completing my OBD2AA dashboard with transmission oil temperature, I tried formula from other Toyota vehicle forums. "M/T Oil Temperature" sensor returns correct values with the "A + B/256 - 40" formula. I have updated the table in the first post. Here is how my OBD2AA dashboard looks now:

Image


Torque and OBD2AA app configs can be found here: https://github.com/2m/gry-obd-pids
 
#19 ·
#21 ·
I got tired of adding multiple small boards to get CAN + ESP32 + 12V and auto shutdown for my car projects so I sat down in EasyEDA and made a board to my liking and ordered five boards (assembled) from JLCPCB. I'm using one as a CAN sniffer interface with www.savvycan.com and another one for over rev warning. Will use one to get live telemetrics from Racechrono and push live data up to a web server when on track (not using CAN there but 12V and BLE + Wifi)

 
#26 ·
Log from driving.

- I begin driving with Torque running a normal pid scan on regular OBD2-data
- Then I turn off Torque and continue driving to see what is broadcast - if anything - on the OBD2 connector (it does but only two pids)
- My own ESP32 asks for oil pressure once every five seconds the whole journey (that's the "SENT" and matching replies you see)
 

Attachments

#33 ·
Toyota CAN PIDS picked up in various places on the net. For a number of different models (Camry 2018 being one, Yaris another but probably previous generations) but you do see patterns emerging
I tried ten or so CAN PIDs from the attachment to try and get some information in RaceChrono using OBDLink in CAN Bus mode. But with every PID I tried I did not see any values. It could be my setup fault, as I have not yet seen RaceChrono give me any values in CAN Bus mode. Do you have some CAN PID that you see any values on GR Yaris?

I think oil pressure is this calculation or are the values maybe a bit off you think?

( a + b/256 ) / 4
I compared the value I get using this formula with what I see in OBDLink, and yea the value seems to be a bit too high.

However then I also tried this formula (((A*256)+B) * 10) / 128 and that seems to produce values very similar to the ones I see in OBDLink. This is the formula that is used for a standard OBD PID 0122 for Fuel Rail Pressure. The value is in kPA.
 
#35 ·
I compared the value I get using this formula with what I see in OBDLink, and yea the value seems to be a bit too high.

However then I also tried this formula (((A*256)+B) * 10) / 128 and that seems to produce values very similar to the ones I see in OBDLink. This is the formula that is used for a standard OBD PID 0122 for Fuel Rail Pressure. The value is in kPA.
I'll run Techstream and compare it's values to the calculations (y)

1635191644459.png
 
#34 ·
@dvim Broadcast packets are not visible on the OBD2 connector in the GRY (apart from two that I've seen). So not much to pick up by just listening there. There you can only run requests that the car will reply to. When hooking up to the different CAN buses you can see tons of broadcasts.

It's always a bit confusing with some things being actual CAN pids and some being ids within the data packets sent with CAN pids like 0x700 in the way the basic collection of OBD2 data works. And what CAN pids you can request to get a reply to and which are only broadcast. I get confused with which is which when it isn't clearly spelled out on different web pages.... Its all pretty new to me so I'm learning as I go along. Which is fun!