Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Project Detroit: How to Read Your Car’s Engine Data with OBD-II

In this article we will look at the OBD-II sub-system and instrument cluster application of the Project Detroit Mustang we built with West Coast Customs.  If you're not familiar with this project, you can find out more about it here and here.


OBD stands for On-Board Diagnostics.  In the world of cars, this can be thought of as the computer which has a variety of data points which can be queried, such as speed, fuel level, and even trouble codes that relate to the check engine light.  If you've ever taken your car in for service, your service center has hooked up the car to a computer via the OBD port to get the status of the car and what may not be working properly.

Getting Started

To use the OBD library with your vehicle, first you need an OBD to USB or serial cable.  These can be found in numerous places, but we recommend this cable from ScanTool.net, which was used with the Project Detroit car and our software.  Here's how to get connected:

  1. With the car off, plug the OBD end into your vehicle.  The port is in a different location in every vehicle, but it's guaranteed to be somewhere near the driver's location. IMG_0545
  2. Plug the USB/serial end of the cable into your computer and note which COM port the cable is connected to.
  3. Update the app.config file of the InstrumentCluster project with that COM port.
  4. Start the car.
  5. Run the InstrumentCluster application, and data should start flowing.

Calling the OBD library programmatically

  • Create an instance of the ObdDevice class
  • Call the Connect method with the appropriate COM port, baud rate, and, if known, OBD protocol
  • From here, the library works in two ways: automatic polling or manual polling
    • Automatic – Pass true to the Connect method. This will poll the OBD as quickly as it can requesting RPM, MPH, MPG, Fuel Level and Engine Coolant Temperature. Note that not all vehicles will support all of these. In this mode, hook the ObdChanged event to receive an ObdState packet with the new data.
    • Manual – Pass false to the Connect method. Then, create your own thread and call the ObdDevice's Get methods to retrieve the data you want as quickly as you want it.  This is the way we used the library in Project Detroit.  We polled manually, collecting the speed, RPM, and other critical data as quickly as possible, while only reading things like fuel level every few seconds.

OBD is a polled system, so data can only be returned as quickly as the time it takes to request it and return it. In short, only retrieve what you need when you need it.

ObdDevice obd;

obd = new ObdDevice();
obd.ObdChanged += _obd_ObdChanged;

// com port, baud rate, protocol (if known), automatic polling
obd.Connect("COM1", 115200, ObdDevice.UnknownProtocol, true);


void obd_ObdChanged(object sender, ObdChangedEventArgs e)

Customizing the Instrument Cluster

The Instrument Cluster application is a WPF application that has 3 different skins which can be viewed by swiping left or right in the application, either with a finger, or the mouse.  This is a simplified version of the actual application we used in the Project Detroit car, modified to talk straight to the OBD port instead of our intermediate WCF service.  Please note that this isn't a robust, drop-in replacement application for a car dashboard, but only a sample of how the OBD library can be used.

Internally, the application uses the OBD library and hooks the ObdChanged event.  The ObdChanged event returns a minimal amount of important data.  When the event fires, the the SetInstrumentClusterValues method is run, which sets the OBD values to each gauge in whichever skin is currently visible.

private void SetInstrumentClusterValues(ObdState measurement)
    foreach (var item in _skins)
        item.IsMalfunctionVisible = measurement.MilLightOn;
        item.IsLowFuelVisible = item.Fuel < 10;
        item.MPG = measurement.MilesPerGallon;
        item.MPH = measurement.MilesPerHour;
        item.RPM = measurement.Rpm;
        item.Fuel = measurement.FuelLevel;
        item.Temperature = measurement.EngineCoolantTemperature;


More Information

Known Issues / Limitations

  • This is known to work with cables that uses the ELM323/327 chipset. The specific cable that was used to develop this library is available from ScanTool.net, however other ELM323/327 OBD-II to USB cables should work.
  • There are a variety of different OBD-II signal protocols. This library only supports a few of them. If your car's OBD protocol is not supported, please feel free to add it and send us the changes to integrate back into the library!
  • If the vehicle has multiple ECUs, the ECU with the most PIDs is used. The other ECUs are ignored.
  • Not every standard PID is supported.
  • No custom manufacturer/model-specific PIDs are supported.


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • Yeah, finally! Thank you Smiley
    Waiting for HUD project. 

  • Finally! Gratz!

    Why don't you post the whole project instead only ODBII library?


  • Dan FernandezDan

    @Gutemberg: We're designing the different components for reusability. For example, a lot of people will want to reuse the instrument cluster, but they wouldn't want to reuse parts like the LED lights for example.

  • Chris HammondChrisHammond DotNetNuke!

    @Dan:I'd Prefer The Whole Thing! Are The Episodes Available On Demand Yet? Sorry For The Caps, Silly Tablet

  • @Dan: I would like to reuse the HUD (front). Do you plan to publish this part? With hardware description please.

  • Clint RutkasClint I'm a "developer"

    @nesher: the HUD requires some pretty extensive alterations to a car. 

  • Dan FernandezDan

    @ChrisHammond: Ideally, people will help build and improve on OBD support so it makes sense to launch that as a separate project without all of the dependencies, but point taken.

  • Chris HammondChrisHammond DotNetNuke!

    I've done a little playing around with a USB OBDII dongle for my Android tablet, would love to do it all in .NET though rather than dealing with java for a while Big Smile 

    I'm not sure I want to do anything with my current 350z, but am looking now looking for another project car to fit the bill. Thanks for making me spend money Big Smile 

  • @Clint: Yes, I know this. That is why I'm asking about it. You have already made it and succeeded. I don't want to take my car apart only to fail. The OBD is nice and good, but not really new. The HUD is something that until now only car manufacturers could make. But you have made it. Maybe the first DIY HUD. We all have seen Xboxes, LEDs, projectors and other not always useful things build by customizing companies in the cars. The HUD IMHO is the first useful thing. It is not just some entertainment, but something that makes car driving really more comfortable and secure. Even if I can't install the HUD on my own, I could go to my local car customizing company and show them your "blueprints" so they not have to reinvent the wheel again.

    So Channel9, please give us more info on HUD Smiley

  • Clint RutkasClint I'm a "developer"

    @nesher:  We're going to release a few more articles and code from Project Detroit.  A full article on the HUD however is not one of them. 

    One of Coding4Fun's goal is we do the hard stuff so you can do the fun, cool, and interesting stuff.  For what we're releasing from Project Detroit, the goal is for stuff the community can actually use without creating a crazy concept car.  The OBD2 library only requires a cheap part that can be bought off the internet.  This means anyone can do it with a modern car, a laptop, and the OBD2 cord can use the library! 

    The issue with our HUD implementation is it required structural changes to the physical car on top of modifying the dash and welding in mounts for the projectors.  The projector also require a power source which means you'll need an inverter to go from DC to AC.  You have to remember, we had one of the world's best automotive shops, west coast customs, helping us implement the HUDs.

    Are the HUDs cool, you bet.  Based on other crazy projects coding4fun has done in the past and how much work I know is required for doing our solution, I don't think this is a good project to for us to release.

  • @Clint: I agree with you that HUD is complicated. And is more hardware project as software. But you must agree, that using OBD2 just with a laptop on a co-driver seat is not very funny. You want to have this information not on a laptop, but on your dashboard or hud. And for any of this you have to change your hardware (car). Also they way you have implemented the HUD is only one way of doing this. How about using laser pico project from MicroVision? On page 6 ( http://www.microvision.com/pdfs/MV_WhitePaper_v.4.pdf ) you can see how they made a HUD prototype with a off the shelf pico projector. Also they have a HUD projector that can be build inside a car ( http://www.microvision.com/vehicle_displays/head_up_details.html ). Unfortunately they don't sell this one to consumers. There is also Pioneer and its AR HUD http://youtu.be/QInEsw-25Qg They want to release it in 2012. It does not requires any modification to the car. But they want to use Android inside. I think Microsoft have to do something about it Wink

    I think if you give the community what you have now, the community will optimize it and reduce the costs and complicated hardware changes to the car. Just give a start point.

  • Clint RutkasClint I'm a "developer"

    @nesher: I'm aware of both.  The off the shelf pico isn't bright enough for the output size we wanted.  I got some microvision picos for testing to verify this early on.  I highly doubt either solution could be installed without modifying your car in some way, shape or form.  Any current hud has a projection system that lives in the dash. 

    As I stated in my prior comment, unless there is something out there I'm not aware of that the public can purchase, a normal person could not implement our solution.  We only want to release stuff that you guys can actually leverage.

    What we provided with OBD-II, you could do what we did and leverage it as the instrument cluster.  That skin is from the detroit project even.

  • @Clint: Why did you build HUD if you don't want to release it?
    To use OBD-II as instrument cluster you also have to modification a car. Or you can buy a car with a tablet instead of dashboard in USA?

    If you build, then release it. If you don't want to release it, then don't show it.

    Very disappointing this project. Definitely not coding4fun!


  • Clint RutkasClint I'm a "developer"

    @nesher:  I will ask that the comments go back on track to Brian's amazing OBD-II library and questions related to that.  If you have issues, please email me directly.  Clint.Rutkas@Microsoft.com

  • @Clint: I'm sorry for misusing this thread for offtopic. And big thanks to Brian for releasing this great library! I hope you will change your mind about HUD.

  • stevesteve

    Interesting tho some of your followers are expecting the impossible lols.
    OBD-II is possible because its an emission's standard based on ISO/SAE -making OBD-II equipment via windows easy to obtain & displaying values like RPM & engine temp possible.

    They will have to build the rest themselves :)
    PS. Im using silverlight in my project but not using off-the-self Elm tool, my own scan tool based on AT90CAN AVR.

  • @steve: already building Smiley

  • http://pioneer.jp/carrozzeria/cybernavi/avic_vh99hud_avic_zh99hud/

  • Cedric AdamsCedric Adams

    This is sweet, but can it be done with ODB-1? I have a 1982 El Camino I am restoring and finding a dash cluster kit working is expensive, this would be a great alternative.

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.