Vehicle OBD2 Shield Library – Beta Release

Gentlemen, it’s time to start your engines!

The first public version of the Arduino library for our successful Vehicle OBD2 shield is now available for downloading.

We are trying our best to make your life developing with this shield easier.

It’s better to have a starting point or something to play with, when you finally have the Vehicle OBD2 shield at your hands.

Let me show you what you can do with this initial version of the library.

Let’s say you have an Arduino Leonardo, our Vehicle OBD2 Shield and a compatible OBD2 Cable.

Download the library from our github, copy it to the libraries folder of the Arduino 1.0 IDE and run the program.

Then program the Arduino Leonardo using the following sketch:

#include "OBD2.h"
OBD2 obd2;

void setup()
 obd2.Init(&Serial1); //Initialize connection to the Vehicle's ECU

 Serial.begin(9600);  // Init debug interface

void loop()
 obd2.Refresh(); //Refresh OBD2 status

 if(obd2.isIgnitionOn){ //You can talk to vehicle's ECU only when ignition is ON

  int myspeed = obd2.Speed(); //Get speed

  Serial.print("Speed is: ");

  int RPM = obd2.RPM(); //Get RPM

  Serial.print("RPM is: ");


Fit the shield on top of Leonardo, locate your OBD2 port (usually near your steering wheel) and plug it in!

Turn your engine on and watch the Speed and RPM spit out from the USB port to your computer!

Now if that looks like magic to you, let me try to help you a little more by taking this code line by line.

#include "OBD2.h"
OBD2 obd2;

This is where you include the library you have downloaded previously to your sketch so the compiler knows you want to use this library. Then you make an instance of the OBD2 class that you will use through the sketch. We named that instance obd2 using lowercase letters. As you know the naming in Wire and C++ languages is case sensitive, so OBD2 is different than obd2.

void setup()
 obd2.Init(&Serial1); //Initialize connection to the Vehicle's ECU

 Serial.begin(9600);  // Init debug interface

The first thing you have to do when you use this shield is to initialize a connection with your vehicle’s computer (ECU). The function Init() does exactly that. Using the smart algorithm of the STN1110′s IC, it finds automatically the protocol your vehicle ECU is using and initiate a connection.
So, no special configuration is needed if you plug this shield to your car or your dad’s car.
Also you pass as parameter to the Init() function the Serial object you use. This depends on the Arduino you are using , if you use the shield’s pins 0 and 1 for communication or other pins with some kind of software serial.
If you know what you are doing this should help you a lot, if you are totally newbie just use “&Serial1″ with an Arduino leonardo or “&Serial” for the other Arduino boards, like Uno or Mega.

The Serial.Begin(9600) is used for debugging, for Arduino Leonardo this is the USB serial port. We are using it in this sketch to debug the readings from the vehicle.

obd2.Refresh(); //Refresh OBD2 status

You should run the Refresh() function at least one time in every loop. This function will update the library’s parameters all the time so you can easily use them in your code. Parameters like “isIgnitionOn” or “isEngineOn”. So, please always have this in your void loop()!

Let’s go now to the good part.


  int myspeed = obd2.Speed(); //Get speed

  int RPM = obd2.RPM(); //Get RPM

Here you have a decision, “obd2.isIgnitionOn” returns TRUE if you have turn on the key on your vehicle  to the ON state, it’s the last turn on the key before you start your engine. In this state the ECU of the vehicle is powered ON , so we can establish communication.

Then we “ask” for the current speed from the vehicle’s ECU and the return value is stored to the integer variable “myspeed”.

If something goes wrong the speed() function will return -1.

The same applies to the RPM() function , for the vehicle’s RPM values.

So, i think that’s enough to make you start with this shield.

We will continue developing this library, like adding new functions for reading more data from your vehicle.

If you have a request , a comment or you want to report a bug, please leave a comment!


Tags: , ,

11 Responses to “Vehicle OBD2 Shield Library – Beta Release”

  1. AllenApril 18, 2013 at 1:38 am #

    Your shop seems to be down. What’s up with that?

    • KostasApril 18, 2013 at 2:27 pm #

      We are in an improvement process so it will stay down for some days. If you need anything you can contact us directly using our contact form.

      Thank you!

  2. LMJuly 20, 2013 at 11:45 am #

    Hi sir,

    The library could support software serial? My arduino has a RN-42 BT module, I use software serial(pin2, pin3) for Rx and Tx, but the library only use hardware serial — Serial/Serial1.

    • KostasJuly 30, 2013 at 11:05 am #

      You need to do some modification to the serial object in the library to make it work with SoftwareSerial, i will make it easier in the next release by using a flag or something to be able to use a SoftwareSerial object instead.

      • GilmarOctober 2, 2015 at 4:48 pm #

        Hi, did you get a chance to do the modification you mentioned in order to use it with SoftwareSerial?


  3. hanOctober 22, 2013 at 8:38 am #

    just a quick question, does this compatible with OBD2 Uart adapter with arduino mega 2560? I didn’t manage to integrate mine so was hoping for some help.

  4. KostasOctober 22, 2013 at 9:30 am #

    Hello, our Vehicle OBD2 Shield is fully compatible with all the arduino boards and all compatibles even thoses with 3.3V TTL levels.
    If you need help with your shield we will be happy to support you, please contact us using the email on the Contact page.

  5. jsukupMarch 21, 2014 at 3:44 pm #


    I’m trying to use the library and I’m having difficulties reading the speed using the included example. It keeps showing 0, however I was successfully able to pull the RPM information. Any insight would be helpful.

    Thank You

    • KostasMarch 21, 2014 at 8:47 pm #

      it is possible that your vehicle is not supporting the speed PID.. can you tell us the brand/model and the date your vehicle is manufactured?

      • jsukupApril 11, 2014 at 4:12 pm #

        It was a 2013 Mazda 3 that I was testing with. I also tested with a 2012 Chevrolet Silverado. If I use just the AT commands with the board I’m able to pull the speed PID with no problems. Thank you for your help.

  6. LucíaJune 13, 2014 at 6:45 pm #

    Estoy proximo a desarrollar un proyecto en el cual podria utilizar este shield, por lo que me interesa mucho saber que modos maneja la libreria que han desarrollado para este shield, y si pronto saldran a la venta nuevamente?

Leave a Reply to Allen Click here to cancel reply.