Connect MCU to car's OBD-II: Page 2 of 3

December 13, 2013 // By Nishant Sood
Connect MCU to car's OBD-II
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.

"01," depicts the mode of operation. The second byte, "0C," is a hex that corresponds to the respective vehicle parameter.

Not all cars support all the possible PIDs. The PIDs I was able to make work with my 2003 Ford Ikon 1.6, for instance, included:

010A0133-No Data010C0105010301070105010A010E010F0111

Design example
This design example uses the LPC 1768 in the form of an mBed, which turns out to be a great tool for working with OBD communication. It already has an inbuilt CAN interface/controller, so only a CAN transceiver is needed to get a complete hardware system rolling. For that you can use a breakout board like this:

The developers of the breakout board above provide also a great library to work with mBed LPC1768. That library can be found here. You can look onto the library file ecu_reader.h to add or subtract PIDs depending on the vehicle you may be dealing with.

The following code is an example:

#include "mbed.h"

#include "ecu_reader.h"

#include "globals.h"


Create ecu_reader objects for different CAN bus speeds


ecu_reader obdii1(CANSPEED_125);

ecu_reader obdii2(CANSPEED_250);

ecu_reader obdii3(CANSPEED_500);

int main() {

   char buffer[20];

  pc.printf("nrCAN-bus demo");

  while (1) {

    if (obdii3.request(ENGINE_RPM, buffer) == 1)

      // Get engine rpm and display on USB port

       pc.printf("%snr", buffer);


        pc.printf("Engine Request failednr"); if(obdii3.request(ENGINE_COOLANT_TEMP, buffer) == 1)

       pc.printf("%snr", buffer);


       pc.printf("Engine Coolant Temp failednr");

   if(obdii3.request(VEHICLE_SPEED, buffer) == 1)

       pc.printf("%snr", buffer);


       pc.printf("Vehicle Speed failednr");

   if(obdii3.request(THROTTLE,buffer) == 1)

       pc.printf("%snr", buffer);


       pc.printf("Throttle failednr");

    if(obdii3.request(MAF_SENSOR,buffer) == 1)

       pc.printf("%snr", buffer);


        pc.printf("Maf sensor failednr");




That should be enough to get you started working with your vehicle's OBD. There are two things to keep in mind, however.

1) You may need to keep the vehicle on to run the OBD. This means keeping the key in the

Design category: 

Vous êtes certain ?

Si vous désactivez les cookies, vous ne pouvez plus naviguer sur le site.

Vous allez être rediriger vers Google.