DIY: Adding new Parameters (sensors) to OBD2 for logging.
#1
DIY: Adding new Parameters (sensors) to OBD2 for logging.
Here is a quick guide on how I use an Arduino Uno and a CAN shield to log things the car did not come with like boost pressure, oil temp, or oil pressure.
I found the orignial code here Arduino OBD2 Simulator
and I'll attach my modified code as well.
I found the orignial code here Arduino OBD2 Simulator
and I'll attach my modified code as well.
Last edited by Harlan; 06-08-2016 at 05:09 PM.
The following 2 users liked this post by Harlan:
3toedSloth (03-23-2021),
motodenta (04-26-2020)
#6
Registered
I got time on my hands to build this thing and read oil pressure and temp from external sensors.
It seems that free version of Torque, Car Commander and similar smartphone apps do not allow you to define custom sensors(those that are NOT attached to the OEM Mazda ECU).
I plan to launch it for sale as a complete kit, but more info on that when I sort out everything. Will pretty much be a small box with wires and this as its brain. Reusing hardware from another project, but hey - it does all one can wish for.
5 inputs, for either 4 temperatures(oil/air/fuel) and 1 pressure(oil/air/fuel) , or 4 pressures and 1 temperature, or anything in between.
Todo: find a way of having mazdaedit log boost and emap. Actually that's what I wanted to do from the beginning but figured that the use case is way too limited just for that.
It seems that free version of Torque, Car Commander and similar smartphone apps do not allow you to define custom sensors(those that are NOT attached to the OEM Mazda ECU).
I plan to launch it for sale as a complete kit, but more info on that when I sort out everything. Will pretty much be a small box with wires and this as its brain. Reusing hardware from another project, but hey - it does all one can wish for.
5 inputs, for either 4 temperatures(oil/air/fuel) and 1 pressure(oil/air/fuel) , or 4 pressures and 1 temperature, or anything in between.
Todo: find a way of having mazdaedit log boost and emap. Actually that's what I wanted to do from the beginning but figured that the use case is way too limited just for that.
Last edited by ciprianrx8; 02-11-2023 at 07:29 AM.
#8
I'm doing something similar with a '19 MX5 RF except bypassing the torque app and the smartphone as display. I have an ESP32 connected to the obd port and a esp8266 on the ancillary sensors both transmitting over ESP-NOW to a receiver ESP8266 driving a display. I have an ethanol sensor and oil temp sensor transmitting to my display via ESP-NOW already and wireless code uploading (since the microcontrollers are embedded)
I think I'm close and will be up and running with CANbus communication as soon as I integrate Task Scheduler into the code. my ultimate goal is to parallel a ESP8266 or ESP32 to drive the infotainment display and use that to display whatever code I want. Torque Gauge style info and such right on the infotainment screen. (Mazda AIO doesn't work on newer firmware)
I have other things I'd like to transmit on CAN, like turning on and off the DRLs without having to drill down through the infotainment settings.
I'd like to tag along and have a few questions.
There is a lot of Torque PID info out there to do a whole bunch of stuff engine parameters, lighting, TPMS sensors etc,,,,
What I can't get my head wrapped around is how to translate Torque PID parameters back to CAN frame and haven't found good examples. seems people just skip that part and post what the Torque fields need to be instead of the raw CAN frame and torque PID.
this is an example of a Torque PID I'd like to read off the bus and transmit the integers to my display:
pid: 222A05
name: Tire 1 Pressure
sName: T1Press
Min: 0
Max: 50
Scale: x1
Unit: psi
Equation: ((A * 1373) / 1000) * 0.145037738
Header: 720
Can ya help a fella out with what the CAN frame would look like and why?
I think I'm close and will be up and running with CANbus communication as soon as I integrate Task Scheduler into the code. my ultimate goal is to parallel a ESP8266 or ESP32 to drive the infotainment display and use that to display whatever code I want. Torque Gauge style info and such right on the infotainment screen. (Mazda AIO doesn't work on newer firmware)
I have other things I'd like to transmit on CAN, like turning on and off the DRLs without having to drill down through the infotainment settings.
I'd like to tag along and have a few questions.
There is a lot of Torque PID info out there to do a whole bunch of stuff engine parameters, lighting, TPMS sensors etc,,,,
What I can't get my head wrapped around is how to translate Torque PID parameters back to CAN frame and haven't found good examples. seems people just skip that part and post what the Torque fields need to be instead of the raw CAN frame and torque PID.
this is an example of a Torque PID I'd like to read off the bus and transmit the integers to my display:
pid: 222A05
name: Tire 1 Pressure
sName: T1Press
Min: 0
Max: 50
Scale: x1
Unit: psi
Equation: ((A * 1373) / 1000) * 0.145037738
Header: 720
Can ya help a fella out with what the CAN frame would look like and why?
Last edited by weeblebiker; 03-09-2023 at 02:10 PM.
#9
Registered
pid: 222A05
22 would be the OBD2 mode
2A would be the PID address
05 no clue - there shouldn't be anything there... unless that car uses extended 29 bits can frames. I don't know.
22 would be the OBD2 mode
2A would be the PID address
05 no clue - there shouldn't be anything there... unless that car uses extended 29 bits can frames. I don't know.
#10
I haven't come across "pid mode" or "pid address" before.
How do I format it as CAN frame header, HEX, DEC, bytes like this for coolent temp?
0x7Df, 05, 5, 1
how does the above translate to torque format?
pid:0551
header: 7DF
?
what is the Torque PID for coolent temp?
isn't all the OBD returns between CAN frame headers 0x7DF and 0x7F0 or something like that?
maybe the tire pressure CAN frame would be:
0x720, 22, 2A, 05
or
0x720, 2, 22, A0, 5
?
it doesn't seem like Torque "pid" and header format match CAN frames for OBD header, hex, dec, byte so I'm confused how to parse the Torque pid to what the CAN frame format would look like.
what CAN frame are you transmitting from the Arduino for oil temp and pressure sensors and what Torque setting are you using to read the CAN frame return?
How do I format it as CAN frame header, HEX, DEC, bytes like this for coolent temp?
0x7Df, 05, 5, 1
how does the above translate to torque format?
pid:0551
header: 7DF
?
what is the Torque PID for coolent temp?
isn't all the OBD returns between CAN frame headers 0x7DF and 0x7F0 or something like that?
maybe the tire pressure CAN frame would be:
0x720, 22, 2A, 05
or
0x720, 2, 22, A0, 5
?
it doesn't seem like Torque "pid" and header format match CAN frames for OBD header, hex, dec, byte so I'm confused how to parse the Torque pid to what the CAN frame format would look like.
what CAN frame are you transmitting from the Arduino for oil temp and pressure sensors and what Torque setting are you using to read the CAN frame return?
Last edited by weeblebiker; 03-10-2023 at 05:23 AM.
#11
Registered
No offence, but this CAN business is pretty well documented online. Also, I have mad respect for the OP of this thread because I feel he is trully the one to come up with the idea of expanding the list of PIDs one can grab from CAN. His source code attached in the first picture should answer all your questions; there's no point in me answering every line of your questions because that's just me developing your use-case, but with extra steps.
#12
I'm not trying to have someone develop for me, just don't need Torque or an elm327 obd dongle at all and was having trouble finding code examples that don't use them or their CAN frame shortcuts.
I watched the video more closely and it's starting to click.
This really doesn't need a propriety board.
This sparkfun board gets ya there, even has a voltage regulator up to snuff to handle car voltage.
I'm using a LOLIN c3 mini (esp32 D1mini) and d1 mini power shield to wirelessly transmit analog sensors from the engine bay to a Oled display. it's tiny and fits in the engine bay fuse box so doesn't need an enclosure either. I already have an esp32 OBD dongle I checked out some of the other ESP32 OBD dongle examples and found the similarity in the examples and I finally got requesting and receiving coolant temp so I have a really really short punt for this part of the project of transmitting on CAN. I do want to send commands like turning on the DRLs or roll the windows up or down when the roof closes or opens. though this gives me the idea of getting my kids old nobi android tablet to upload code changes and datalogging with it.
I watched the video more closely and it's starting to click.
This really doesn't need a propriety board.
This sparkfun board gets ya there, even has a voltage regulator up to snuff to handle car voltage.
I'm using a LOLIN c3 mini (esp32 D1mini) and d1 mini power shield to wirelessly transmit analog sensors from the engine bay to a Oled display. it's tiny and fits in the engine bay fuse box so doesn't need an enclosure either. I already have an esp32 OBD dongle I checked out some of the other ESP32 OBD dongle examples and found the similarity in the examples and I finally got requesting and receiving coolant temp so I have a really really short punt for this part of the project of transmitting on CAN. I do want to send commands like turning on the DRLs or roll the windows up or down when the roof closes or opens. though this gives me the idea of getting my kids old nobi android tablet to upload code changes and datalogging with it.
Last edited by weeblebiker; 03-12-2023 at 08:28 AM.
#13
22 is mfr /vehicle specific byte and always 2 following bytes
The CAN request frame would be:
ID: 0x720 (mazda instrument cluster)
Byte0: 0x03 (bytes following)
Byte1: 0x22 (mfr custom request)
Byte2: 0x2A
Byte3: 0x05
Bytes 4-7: 0x00
I'm using a macchina A0 ESP32 based OBD dongle and various ESP modules wirelessly communicating. it's not a big deal to send sensor info to the dongle and transmit it.
Last edited by weeblebiker; 04-06-2023 at 01:54 PM.
#14
Here is a quick guide on how I use an Arduino Uno and a CAN shield to log things the car did not come with like boost pressure, oil temp, or oil pressure.
I found the orignial code here Arduino OBD2 Simulator
and I'll attach my modified code as well.
Creating new OBD2 Parameters for logging! - Networking the Beast 4 –Voiding Warranties Ep 7 - YouTube
I found the orignial code here Arduino OBD2 Simulator
and I'll attach my modified code as well.
Creating new OBD2 Parameters for logging! - Networking the Beast 4 –Voiding Warranties Ep 7 - YouTube
I know this is an old topic, but maybe...
I've tried to do the same stuff in my RX-8.
But as soon as I add a new pid to the can, the ECU claims an error code about the can network.
Did you experienced the same issue or this is just mine implementation?
(maybe just an error in the code/message format maybe?)
Thank you for any answers in advance!
#15
Registered
No offence, but this CAN business is pretty well documented online. Also, I have mad respect for the OP of this thread because I feel he is trully the one to come up with the idea of expanding the list of PIDs one can grab from CAN. His source code attached in the first picture should answer all your questions; there's no point in me answering every line of your questions because that's just me developing your use-case, but with extra steps.
You're given a solid foundation to this, the walls and roof are on you.
#16
I just wanted to know, if the ecu's CAN error code is a valid consequence if I send data to the bus or not.
(The sending works by the way, I can see the new PID values in the app.)
#17
Registered
ECU won't throw codes for this if you allow enough CAN bandwidth for the native stuff - don't think your needs are the only ones the CAN bus has to accommodate.
Thread
Thread Starter
Forum
Replies
Last Post
DannyR3
Series II Interior, Audio, and Electronics
3
07-26-2018 10:07 PM
rickeo
General Automotive
20
05-06-2013 04:41 PM