Introduction: Custom OBD II Gauge in With OEM Look

https://github.com/stirobot/arduinoModularTFTgaugesI built a custom OBD II (on board diagnostics version 2 http://en.wikipedia.org/wiki/On-board_diagnostics) gauge in the clock of my Subaru BRZ (GT86, FRS) and a lot of people wanted me to build them one. Here is how you can build one of your own. My wife is about to give birth to our second son and all the code is open source, so I have nothing to lose by posting this.

(I still may sell the installation as a service or possibly the packaging of a kit in the future, but that won't prevent others from using the open source pieces to do what they want in their own installations, other cars, other displays, etc. and frankly there is no money to be had in this. So, I'd rather share it with the DIY community at large.)

I'll try to point out where I did things that are specific to my model of car and where you might want to change things to suit your needs. Hopefully this will allow others to build on what I've done.

The all important github link:https://github.com/stirobot/arduinoModularTFTgauge...

And more generically my code is here: https://github.com/stirobot/arduinoModularTFTgauges

The car specific forum where all of this is getting discussed: http://www.ft86club.com/forums/showthread.php?p=1967204#post1967204

Step 1: What You Will Need to Do This (parts/tools/software/etc)

Picture of What You Will Need to Do This (parts/tools/software/etc)

Parts (generic/specific):

-An Arduino or Arduino clone – I specifically use the adafruit pro-trinket for its small form factor and 5v logic.https://www.adafruit.com/products/2000

-STN1110/ELM327 board. I chose the Sparkfun one because it is stable, uses UART for communication and doesn't cost and arm and a leg. https://www.sparkfun.com/products/9555

-Assorted hookup wire

-128x32 SPI monochrome OLED display. I used the adafruit one. The ebay ones may work just as well, but I haven't tested them.

-Your OEM clock. I used the OEM clock from a Scion FRS that I got on ebay.

-Some resistors (for the button setup)

-Optional – sensors (autometer oil temp, autometer oil pressure, acceleromter, pressure, temperature). I have some arduino code that will let you plug analog sensors into a system like this. I'll make one of the “steps” pages about this.

Tools:

-Soldering Iron

-Wire stripers

-Wire crimpers

-Helping hands

-scissors

-dremel tool

Code libraries used:

-Arduino ELM327 library: https://www.clusterfsck.io/blog/2014/05/23/arduino-elm327-library/ . I thrashed around with the UART comms to the OBD II board for a long time. (you can see it in my crummy code for the 1.8” TFT version of this). This saved my project and my sanity.

-The Adafruit libraries for the OLED screen and tutorials: https://learn.adafruit.com/monochrome-oled-breakouts I love supporting this vendor as they always provide a lot of extras when you buy from them (support, working code (emphasis on working), tutorials, etc.)

Software:

Sublime Text2 Stino plugin (because real syntax highlighting is refreshing) - http://robot-will.github.io/Stino/

the dot factory – for making monochrome bitmaps into arrays so you can display them on the screen (That's how I got my icons)

windows paint – for drawing icons and splash screens

Step 2: Choosing Your Screen

Picture of Choosing Your Screen

I've been through several projects like this in the past and I have some advice to share on selecting a screen.

-You want the screen to fit in the OEM location with as little modification to the car as possible. I ended up measuring everything and cutting out templates on paper to see what would fit. For an old project similar to this I used a standard 16x2 character LCD. It fit perfectly in the GD Impreza's clock location (https://code.google.com/p/robotmeter/)

-You want as much support as you can get in terms of a graphics API. The adafruit stuff is awesome. Their TFT and OLED graphics API's are great.

-You want the best visibility in all lighting conditions. Cars see night, day and direct sunlight to all their displays. OLED screens are great at this. Transflective LCD's are also good at this. Reflective and Transmissive LCD's are not good at all.

-Polarized sunglasses can sometimes ruin a great design if their polarization lines up the wrong way with the screen you select. Test things out before you dive into coding.

Step 3: Reuse Code From the Community

I reused the wonderful ELM327 library from David Irvine (https://www.clusterfsck.io/blog/2014/05/23/arduino-elm327-library/) and it saved me a lot of headache. Please reuse my code as it might save you some time or at least give you some ideas.

Graphics API's are great, but what's better is looking at the code that uses them. Look at other projects that employ the API you are using and see how they deal with things like screen flicker, drawing bar charts, scatter plotting, etc.

Step 4: (if You Are Using My Code or Making Your Own) Find the Vehicle Specific CAN Codes for Your ECU

Finding the vehicle specific CAN codes for your vehicle can give you much more info than the generic OBD II PID's. In my case the BRZ/FRS/GT86 community has discovered two important codes which show data that you would otherwise not be able to get from these cars via the standard OBD II PID.

For my car these included oil temperature (very important for track/autocross driving) and fuel remaining.

I had to modify/use the David Irvine API to use the Oil Temp PID. For a lot of applications (and for mine), this was a two part process. First you have to express a CAN header and then ask for the PID like you normally would. I added this code to the ELM327 initialization code:

runCommand("AT SH 7E0",data,20); //(FRS/gt86/brz specific CAN header)

Then I queried for the oil temp:

status=getBytes("21","01",values,1);

(I added my own function to the ELM327 class for this.)

So, the hard part is finding what these are for you car. The easiest places to look are:

-The Torque android app forums

-The vehicle specific forums for your make/model of car (I found that this is especially true of a lot of the diesel truck models).

-The Scangauge X-gauge PID library (http://www.scangauge.com/support/x-gauge-commands/)

-And, finally if you can't find what you are looking for you can do some CAN sniffing of your own (which there are other instructables on: https://www.instructables.com/id/CAN-Bus-Sniffing-and-Broadcasting-with-Arduino/ )

After you find the correct PID the next part is picking out the data out of the (sometimes long) string of characters returned. Getting this position correct is sometimes a pain and requires a lot of debugging and possibly a specific arduino sketch where you guess and check positions until you get close. Another approach is to spam the responses to the serial monitor (an arduino mega is helpful here) then graphing them in a spreadsheet to figure out which hex number (converted to decimal) changes with the specific sensor reading you are interested in. You may also want to check this against the ground truth of an actual sensor or a known good OBD II program like the torque app.

Step 5: Disassemble Your Clock

Picture of Disassemble Your Clock

-Find the car make/model specific forum of your choice and find the DIY section to find out how to get the clock out without breaking anything. Be especially careful if the clock shares a PCB with something critical (in my instance the airbag status lights and hazard button are on the same PCB). Sometimes a DIY which describes how to change the color of the clock (popular modification in a lot of cars) will come in handy.

-De-solder (https://www.instructables.com/id/How-To-Desoldering/) the clock or cut it out entirely (depends on your specific car). I have included pictures of what I did to mine for reference.

-On my car this included removing back-lighting LEDS as well.

Step 5: Reusing clock buttons

I was lucky in this regard. My OEM clock has three buttons. I was able to reuse them to control the screen. I assigned them these functions H=high, show the peak measure; M=mode, switch display pages; 00=reset the peak readings.

In order to reuse the buttons I had to remove them from their curcuit and wire them up to a circuit like this: http://tronixstuff.com/2011/01/11/tutorial-using-analog-input-for-multiple-buttons/ .

I ended up pulling them off of the circuit board with pliers and then using electrical tape as insulation. This is far from ideal. The better way to do it is to follow this instructable: https://www.instructables.com/id/Solder-on-PCB-traces/ . Use and exact knife to clear out traces around the one you are interested in.

If you aren't lucky and don't have buttons to reuse, buy some spst buttons of your liking and mount them wherever you'd like. I suggest using ones the come in a screw casing so you can drill a hole and mount them neatly.

Step 6: Test Everything Out Before Taking Everything Apart

Picture of Test Everything Out Before Taking Everything Apart

(yes this is out of order)

This should probably go without saying, but test everything out before you wire it in permanently and before you hack up your clock.

Step 7: A Word About Power Savings

The ST chip used in the OBD II UART device has some excellent power save features. I use the one which puts the chip to sleep when it is not getting power to the UART pins. This allows me to keep everything semi-permanently installed without worrying about it draining the battery. Specifically I make use of this command in the initialization to put it in this mode:

runCommand("STSLU", data, 20); //sleep on UART inactivity and wake on activity

There a whole host of other power save options that you can read about here: http://www.scantool.net/downloads/79/stn11xx-powe... I have yet to test this with a multimeter, but will soon (and hopefully remember to update this page).

Step 8: ​Wire Up and Power Up

Picture of ​Wire Up and Power Up

This is the fritzing diagram of how I have everything plugged in for reference. I did it with the more common arduino form factor instead of the Adafruit Trinket that I am actually using at the moment. Hopefully this will make things more clear for some people.

Step 9: Innovate!

Picture of Innovate!

The world is your oyster here. Things I suggest changing or customizing:

-What is displayed on each page. What OBD II readings you are interested in.

-Find CAN specific PID's for your car and use those.

-Change the button config to only use one button and use long holds to reset things or display highs.

-Scale to a 128x64 OLED or other larger screen.

-Reuse some of my sensor code found in this project to add off the shelf gauge senders/accelerometer/etc to your project: https://code.google.com/p/robotmeter/

-Fork my code. Publish what you've made (here on instructables and elsewhere).

Comments

mostafa_et (author)2015-08-01

Hey JustiN1, found your instructable in a forum while looking for a way to diagnose an overheating problem I have with my 2006 Subaru Legacy. I just logged in to say thank you for the great instructable. To me, your instructable (and your courteous, informative reply to comments/questions) represents the essence of such social networks (and dare I say a diminishing great human quality): helping complete strangers and sharing knowledge without asking for anything in return. Like you used to be, I am a lurker here and your instructable inspires me to one day post my own instuctables to give back to the community.

JustinN1 (author)mostafa_et2015-08-01

Wow thanks for the compliment. I will let you write my next resume.

On the legacy, unfortunately the probability that you need headwork is there. There was some issue with some motors of a certain generation and they required work because of some headgasket issue (my sister had one with this problem). (http://kentbrothersautomotive.com/an-explanation-of-common-subaru-head-gasket-problems/

numbchux (author)2017-09-13

I love this! I was just thinking how badly I'd like to display some other information in place of my broken digital clock on the dash of my Celica. This looks perfect, BUT....

Being a 1991, it doesn't have OBD II. You have code for analog inputs in addition to the OBD II stuff, could it run with just analog inputs and without the OBD II interface?

JustinN1 (author)numbchux2017-09-15

I do have some analog input stuff. In fact I'm doing some of that for my car right now...
I've got turbo pressure, oil pressure, oil temp and in some old projects I did some thermistor stuff to get air temps from the engine bay (which is pretty usesless). You can dig around in my github stuff here https://github.com/stirobot . But I'll just paste the functions that read the boost and such values here (there is test code you can comment out or use for when you just want to make sure your display is working):


void getBoost() {
float rboost = analogRead(A0);
//float ResultPSI = (rboost*(.00488)/(.022)+20)/6.89 - atmo; //leave of the /6.89 for kpa
float ResultPSI = (((rboost / 1023) + 0.04) / 0.004) * 0.145 - atmo; //by 0.145 to calc psi
return (ResultPSI);
}

void getOilPSI() {
float psival = analogRead(A1);
//Serial.print(psival);
if (psival > 722) {
return (0);
}
if (psival < 257) {
return (110); //110 swings higher than the gauge goes which will alert the user to something being wrong
}
if ((psival <= 722) && (psival > 619)) { //722 = 1.42
return 174.7 - (psival * 240) / 1000;
}
if ((psival <= 619) && (psival > 520)) {
return 180.2 - (psival * 250) / 1000;
}
if ((psival <= 520) && (psival > 411)) {
return 169.4 - (psival * 230) / 1000;
}
if ((psival <= 411) && (psival > 257)) { //257 = 100.68
return 141.8 - (psival * 160) / 1000;
}
}

Basically what you want to do is go to a sensor manufacturer (I like autometer and that is what some of my stuff is based on) and ask them for resistance curves for the sensors. A lot of sensors change the resistance based on a change in the environment. You then set these up in a voltage divider circuit (google it, it's fairly straightforward) and that gives you a voltage reading that you read off of one of the analog input pins on the arduino. Then after that it's just a scaling problem to get the right numbers to show up on whatever display you are working with.

numbchux (author)JustinN12017-09-22

Well, got the Trinket and display, installed the test and mocked them up in my clock assembly. I had to cut a slot in my circuit board for the wires, of course the one trace that I'm using for the 3 buttons is preventing it from going any lower. Might have to cut it and run a wire from one side to the other.

Anyway, now onto modifying the program and acquiring sensors.

numbchux (author)JustinN12017-09-15

Awesome. You are my hero!

I gutted my clock, that 128x32 display is virtually the exact same display area as the stock clock. So I ordered it and the pro trinket. I hope to start playing with it next week!

malcolm.ragan (author)2017-04-06

Hi JustinN1, I cannot get any of the sample codes to compile unless I pretty much remove any of the useful OBD parts and in the end, I can only switch modes and look at nice graphics. Are you able to tell me what I should do?

JustinN1 (author)malcolm.ragan2017-04-07

Sure...post what errors you are getting (aka why the OBD parts don't compile). I haven't looked at the ELM code in a while and it is possible that it isn't compatible with newer arduino stuff.

malcolm.ragan (author)JustinN12017-04-08

Hi JustinN1, I think I figured it out but now I need to figure out to to communicate on K-Line and what values to send to retrieve OBD values and convert, print them to my OLED. Cheers!

AlexanderS171 (author)2016-06-14

Hi, thank you very much for this instructable!! I want to build it exactly like you did. It is for a Toyota GT86 also. :)

btw: please update the link to the elm327 lib: https://www.clusterfsck.io/blog/arduino-elm327-library/

JustinN1 (author)AlexanderS1712016-06-14

Cool. I'm excited for someone else to build one. I have only run across one other person who build one and it was in a german car forum.

The https://www.clusterfsck.io/blog/arduino-elm327-library/ link seems to work for me. Maybe the link is blocked in your country or their server was down for a few minutes. The direct link to the library is here: https://github.com/irvined1982/arduino-ELM327

AlexanderS171 (author)JustinN12016-06-15

Your link is: https://www.clusterfsck.io/blog/2014/05/23/arduino... which does not work for me. :)

Thank you for the link to that forum. I am a mod of that forum but did not see that topic :)

JustinN1 (author)AlexanderS1712016-06-14

Here is the link to that german forum: http://forum.gt86drivers.de/index.php?page=Thread&threadID=739

MiebakaI (author)2015-08-26

congratulations, my regards to your wife

LadySith (author)2015-08-12

So I'm not into cars but this looks like a great Instructable.

JustinN1 (author)LadySith2015-08-12

Thank you. I imagine the code for putting data on the OLED screen could be used for other projects that aren't car related.

turbiny (author)2015-06-12

does it work on honda civic 98 (still cant find te OBD connector bought it used i guess some one cut it or hid it)
can u sell me a complete programed kit?

JustinN1 (author)turbiny2015-06-12

A 98 civic should be OBD II compliant so most of what is in my code should work, with the exception of the oil temperature (which uses a brz/frs/gt86 specific PID). You could replace the call to oil temp in my code with a generic one which might work, but IIRC the EG civic doesn't have a built in oil temp sensor. I can't use instructables to sell things like a complete programmed kit. I'm pretty sure its against something I agreed to when getting an account. PM me and I'll see how I can help you.

MoTinkerGNome (author)2014-10-22

Justin, Even though we are competitors in the competitions I really hope you win. and I voted for you.

People might not understand how useful this mod really is and it can save them tons of headache down the road. (pun intended)

This reminds me of the Turbo install in my kid brothers old miata once upon a time. Needless to say we were lucky he had an Apexi fuel airflow computer installed, During the turbo install he damaged his MAF sensor wiring harness and we were able to quickly troubleshoot the break get it resoldered and got the car running after what would have been a frustrating troubleshooting step as the 93 miata does not have ODB.

I am going to have to make one of these for my bag of tricks / auto toolbox. I never thought of making my own ODB2 code reader

JustinN1 (author)MoTinkerGNome2014-10-22

Wow! Thanks for all the kind words. I used to be a lurker on Instructables until I saw this car related contest and (honestly) joined because of it, but I'm beginning to see that this is a nice social network of people who have very similar interests, goals, etc. with mine.

I do have some other car related DIY stuff that is model specific that I may post up later. I also have some other generic instructions that may be useful to others in the car related area (Does a diy on using off the shelf gauge senders (like from autometer, who by the way is very nice and will send you resistance curves via email if you ask) to get data to a 5V logic micro controller using voltage dividers sound good? I was thinking of sharing a spreadsheet I made a while ago to help decide what resistors to use with a thermistor or other resistance based sensor.)

I used to have a miata. What a fun car. I only had it for a few months though, because I had to move across country.

If you or anyone else needs help with any similar projects I'd be happy to see what I can do. Just message me or comment here.

Also, it is kind of weird putting all my code out there for everyone to see. It isn't exactly the cleanest stuff in the world.

MoTinkerGNome (author)JustinN12014-10-22

It is funny I just recently picked up a 92 Miata (albet an automatic) now that I am older and have kids my self I don't need to go so fast but I love a great handling car. Couldn't pass it up that garage queen NA with less then 100k and being an auto it was Cheap.

I think over the years everyone in my family has had one I am going to be the odd duck and keep it bone stock. Well perhaps a Flyin Miata intake.... but mechanically it will remain the simple car Mazda released.


How do you like the 86/BRZ?

JustinN1 (author)MoTinkerGNome2014-10-22

The BRZ is awesome.

For sports cars my history goes 04 Sti -> NA Miata -> e36 m3 -> BRZ

pros: new car smell, handles excellently (balanced like the e36 but more nimble), nice inside and looks good on the outside

cons: new car payments, a little slower than it should be, stock tires were junk (I just replaced them), barely enough room for two car seats in the back (5 year old and soon to be newborn).

Basically I love the car and will be keeping it for a while.

MoTinkerGNome (author)JustinN12014-10-31

Hey bud. I just saw your writeup on the Make facebook feed. Congratulations.

JustinN1 (author)MoTinkerGNome2014-10-31

Thanks. They are fairly liberal about putting stuff up I think. If you suggest your projects it takes a week or two for them to show up.

MoTinkerGNome (author)JustinN12014-11-05

Hey were both finalists WOOOO-hooo Congrats. The funny thing is that while I was looking for my original post here I read through it and noticed that I misspelled OBD (On Board Diagnostics) as ODB (Ol' Dirty Bastard) perhaps It got taken over by the Wu-Tang Clan

JustinN1 (author)MoTinkerGNome2014-11-06

Yeah. I saw that too. It is awesome. Congrats!

There is some good competition. I like all the other projects that made it. What's even cooler is that any of us could use the 3D printer to help with their projects. It is a very appropriate grand prize.

roroid (author)2014-10-31

Hi,
I want to make something similar for my car, but my main topic is doors auto lock/unlock. Basically what I want to do is to close the dors after the car starts and reach 10km/h and unlock when I takeout the keys. Do you know if on obdII is a command to lock unlock the door?

JustinN1 (author)roroid2014-10-31

It sort of depends on the car you are working with. There is not an OBD II command to do what you are trying to do, but there is likely a CAN command that could do that, depending on the car.

What make/model/year are you trying this with?

roroid (author)JustinN12014-10-31

Thanks for answering. It's a 2006 hyunday Tucson.

JustinN1 (author)roroid2014-10-31

Someone might make something like this: http://www.obdinnovations.com/universal-obd2-can-b... for your car.

If not you may want to sniff the canbus like this (https://www.instructables.com/id/CAN-Bus-Sniffing-and-Broadcasting-with-Arduino/) and maybe you'll see a message that correlates with locking the doors. Then you play that message back when you read a certain speed from the obd II. There is a chance that the lock mechanism isn't on the canbus and the switch just hits a couple of relays and actuators to make things lock and unlock.

omni96 (author)2014-10-26

Very nice!

You can use a polish compound (or toothpaste) to remove the H and M :)

JustinN1 (author)omni962014-10-26

Cool. Thanks for the tip. I saw some of the BRZ guys using it to take logos off of head units (car stereos).

dragon fllyer (author)2014-10-24

I wish people wouldn't assume everyone knows what their acronyms mean; being perhaps the most curious person on the planet I always want to know, and it took me way too long to figure out what OBD means...

JustinN1 (author)dragon fllyer2014-10-24

Sorry about that. Let me know if there is anything else confusing on this instructable and I'll see if I can spell it out.

(frankly I should know better...policy at work is to spell it out the first time an acronym shows up in a document or presentation)

dragon fllyer (author)JustinN12014-10-24

Hey, thanks! This project is way above my skill level, but learning new things is pretty much what keeps me going, and I hate missing anything...!

teaMJPx (author)2014-10-24

This is great!!! I wanted to do this before but with your write up I think I can manage it. Thank you for posting this.

You have my vote! Just like MoTinkerGNome below, we are in the same contest... jejeje

Good Luck!

JustinN1 (author)2014-10-22

Can anyone who is readying my ible suggest a good way to get or make an enclosure for the obd board and pro trinket? Right now I'm using a hacked up arduino mega case (hole cut in size for obd cable to go through, etc.)

aschneider2 (author)JustinN12014-10-24

Great instructable! Model a case with Sketchup and either print with your (or your friend's) 3d printer, or order a print from Shapeways?

rpjacks (author)2014-10-23

I'm going to sound like a complete noob, because I am. How do you get the data from the car to the display you have created here? I have an idea for an enclosure in my Toyota that would be outside the dash but still look decent. I have extensive experience in plastic fabrication from military modeling but have little experience with cars. My wife and I bought our Toyota and I miss having oil pressure and state of charge displays like I had in my old GMC. Is there some kind of adapter that I need to connect to the troubleshooting port?

JustinN1 (author)rpjacks2014-10-23

So, I'll try to explain it at noob level, if it's not the right level, confusing or whatever, let me know :)

-All cars build after '96 (in the US) are supposed to have have OBD II diagnostic ports on them that allow you to get a certain data from the ECU (http://en.wikipedia.org/wiki/On-board_diagnostics)... The purpose was for emissions stuff. Some of the data available is mandated, some is extra.

-Most modern cars also have CAN bus systems that allow for extra (deeper, better resolution, more sensors, etc.) data to be read/controlled, etc. Unfortunately most of the PID's (commands) for these are proprietary and not published. Luckily there are a lot of smart enthusiasts out there who have figured some of this stuff out.

-Oil pressure on your toyota may or may not be available (is it listed on here: http://www.scangauge.com/support/x-gauge/toyota-sp... I would expect is isn't available, unfortunately. Generally the oil pressure sensor that sets of a light on your dash is a simple switch that comes on at a set low point.

-Voltage (state of charge) is generally available via the ecu and if it isn't most OBD II devices will just get the voltage from the present at the obdII port.

-So, how do i get the data to the display? I bought a board from Sparkfun electronics that takes commands and turns them over to the ECU and then sends the results on to the arduino board (small microcontoller board...sort of like a tiny computer). I wrote a program that sits on the arduino and that sends commands to the sparkfun obd ii device, gets the results back does some computations and puts them on the screen. (I have to add that there is a library of code that someone wrote that make sending and receiving the commands (quickly with the correct timing) to the sparkfun device easier. I also used a library written by the manufacturer of the display (adafruit) that makes it easier to draw stuff to the screen. Which means my work on this project is more like "systems integration" than from the bare metal manufacturing.)

Blackice504 (author)2014-10-23

nice work i might have to give this a try in the future.

good_apollo (author)2014-10-22

Very nice retrofit. The install is clean and super useful; almost invaluable when it comes to troubleshooting. Keep up the awesome posts!

JustinN1 (author)good_apollo2014-10-22

Is the username a Coheed and Cambria reference?

good_apollo (author)JustinN12014-10-23

Haha, it is! You're the first one to comment on that.

warehouse32 (author)2014-10-22

If only this was standard on cars! You weren't kidding when you said OEM look...great job!

JustinN1 (author)warehouse322014-10-22

Some of the newer fords have stuff like this build into the cluster and the new wrx has a multi function gauge built into the dash above the stereo (http://motorreview.com/2015-subaru-wrx-sti-early-review-track-performance-for-the-daily-drive/).

warehouse32 (author)JustinN12014-10-22

very cool, i had no idea!

Victor Does (author)2014-10-22

Really cool!

Honus (author)2014-10-21

That is super cool- nice job!

LordD (author)2014-10-19

Great job. Thanks for putting the code on github, and for documenting it here.

About This Instructable

69,594views

586favorites

License:

Add instructable to: