Connect MCU to car's OBD-II

December 13, 2013 // By Nishant Sood
Onboard diagnostic systems (OBDs) are found in almost every car these days, providing a very rich set of information about parameters like coolant temperature, RPM, and the like. The information about all these parameters lets us define the state of the vehicle by diagnosing each and every aspect. Here's a guide to getting started with OBD development using your chosen MCU.

First, a quick overview. OBD-II is the protocol that works in most of our cars that date back from a decade ago until now. It's particularly widespread in cars made in Asia, where almost all makers support the protocol, but it is a global protocol and used in cars worldwide. You can find more on OBD here.

Connection to your car's OBD can occur in several ways. One is to use an OBD scan tool, which is readily available for around $30 to $50. Make sure the tool is OBD-II command-set compliant.

You can also use an MCU with a CAN interface. Some devices, like the ELM 327 (actually a PIC 18), come preprogrammed to extract information from the car's OBD-II ports. The STN1110 is also very popular and has the same functionality as the ELM chip.

More generic MCUs with a CAN connection will also work, although the CAN connection only handles the signaling interface. You will also need software to be able to decode the data. The simple LPC1768 mBed module will work (it has an in-built CAN hardware interface with an MCP2551 CAN transceiver).

If the MCU doesn't offer a CAN interface, you can use a CAN module such as Sparkfun's OBD UART with essentially any other device.

The physical connection to OBD uses a special 16-pin connector, which means you will probably want to use an adapter cable. Two common adapters available are OBD-to-DE9 and OBD-to-USB.

Software
You can extract Information from the OBD port only by making requests to the ECU (engine control unit). You request specific parameters by using the PID (Parameter ID) associated with the information of interest. You can request, for instance, the current RPM of the engine. The ECU then returns back a value like "010C" that your MCU or tool will need to translate into a human-readable/understandable form.

The PID "010C," for instance, has two parts. The first byte,

Design category: