Why OBD2 Reader App is necessary for Phones

Why OBD2 Reader App is necessary for Phones


Why does your vehicle need it?

Have you ever thought about different vehicle parameters being displayed in your own Android application? If so, then you’ve come to the right place. We will discuss what it takes to develop an OBD2 reader application.

First, let’s take a quick look at the protocols used in vehicles for diagnostics.

OBD is an acronym for “on-board diagnostics” and refers to vehicle’s self-diagnostics and reporting capability. Originally it was intended to help mechanics run quick vehicle diagnostics. The early versions of it allow checking for possible problems with the engine. Nowadays, in addition to preserving the “diagnostics” part, this system has been dramatically enhanced and allows a vehicle owner to be in control of different parameters like the current fuel consumption rate, gear and transmission modes, GPS module and so on. For a full understanding of how it works and the history behind it, you can read the full article on Wikipedia called “On-board diagnostics”.

Necessary materials


First of all, you would need a OBD2 adapter to be able to use the OBD2 interface. There are many adapters from different manufacturers. Some of them have a COM interface, others have a USB interface, and some have a Bluetooth interface. Theoretically, any adapter can be used by the Android application, but in practice, your best choice is the Bluetooth interface.Also, adapters can be differentiated by supported OBD2 protocols (i.e. by supported vehicles).So if you have a car within reach and good OBD2 adapter we can start developing OBD2 reader application.

Hold on – do you really have a car close enough to your development environment? Actually we can use a simulator for a start. The one that worked for me is OBDSim: it is an open source project available for different platforms. Since Bluetooth is not supported on Windows, rebuilding it from scratch in Linux will be necessary. Please note that most likely it will require you to modify the source code and change RFCOMM channel to the first available instead of channel 1.

What’s more, a hardware emulator can be used instead of a real car. I used ECUsim 2000 standard with ISO 15765 (CAN) protocol enabled. As for the OBD2 adapter – I used ELM327 v.1.5 adapter.


Developing the application

Let’s start with describing the protocol that is used for communication between Android device and OBD2 adapter/vehicle. It is text-based polling type protocol. This means that all you need is to send a command to receive a response. And knowing what commands to send is key.

We will connect to the adapter through Bluetooth. It seems that Bluetooth Low Energy API is just the thing we should use. However, since it is now supported only by several devices, it is too early to use it.

The protocol supports some AT commands like turning echo and control line feed. Another part of the protocol is OBD2 control protocol itself.

The general workflow of the application functionality should go like this:

1) connect to the OBD2 adapter through Bluetooth;

2) initialize OBD2 adapter with AT commands;

3) continuously get data from the vehicle through issuing the corresponding PID codes.

Connecting to the OBD2 adapter is straightforward. But one thing you need to do before connecting is to select the Bluetooth device. Displaying an alert dialogue with single choice items is a good way to go:


Don’t forget to save the selected device address somewhere. Now we can connect to the selected device:


The UUID I mentioned represents a “serial” interface through Bluetooth. Of course, this code should be executed in a non-UI thread. Also, I would recommend checking this article for details and a solution of a bug in Android that can lead to connection failure in some cases. We  can now make the data exchange. We will use a OBD-Java-API library for this. The library is pretty simple to use. It has several classes, which correspond to different OBDII commands. Don’t forget to initialize the OBDII adapter first by issuing configuration commands:

ShowShow code

We are now ready to issue any other commands:


Here I should point that this library has some issues with parsing response and it often crashes because of poor error handling. The first flaw is the “performCalculations” method present in all command classes. It would be good to check the buffer size before accessing buffer data, because in some cases the response may be shorter than required. Of course, the problem of a shorter response is on the OBDII adapter/vehicle side, but the library should be ready for such issues.

Apart from this, there are some other issues, so this library still requires improvements or can be used simply as a reference.

The obtained data can be stored somewhere for further analysis, for example, on the ElasticSearchinstance.

Right now, we are working on a Hours of Service application for commercial vehicle drivers and will continue sharing our experience on OBD2 in our blog. Meanwhile, you can find more information on developing applications for latest IoT gadgets in our experience section Apps for Connected Devices.

Author:By Ruslan Yanchyshyn

  • How to register Autel MaxiDAS DS808 scanner

    This a how-to guide of 2017 Autel MaxiDAS DS808 registration. – Necessary to perform Autel DS808 registration??? – Definitely yes! […]

  • MaxiSys-Pairing your Bluetooth VCI

    Recently,more and more people want to connect the bluetooth to Maxisys device Bluetooth pairing is the best way to communicate the VCI with your MaxiSys; it allows your to diagnose the vehicle without having to be sitting inside. Difficulty: Easy Time: 2 minutes Related posts: Installing the MaxiSys […]

  • Autel ms908 Autel Maxisys Ms908 Support players of the Automotive Diagnostics Master qualify for the National Finals Competition

    Recently, China’s second session of the Standing automotive diagnostic division contest held in Wuhan, Hubei, its said Autel tech has become a unique diagnostic equipment providers in the contest, and it will to help three groups of players with honors successful promotion National Final Competition. Autel ms908 review As this champion, professor Jiang from Huanggang Audi 4S shop give high regards for autel automotive diagnostic products. “Autel MS908 is not only powerful in function, but also very convenient, the operation is very easy, it help me to save a lot of time in the contest, let me fully realize that a professional automotive technician must learn to operate specialized diagnostic equipment.” Related posts: How to Root the Autel Maxisys MS905 or MS908 Ds708 vs MS908 Autel […]

  • autel maxidiag elite md802 Solution for Autel MaxiDiag Elite MD802 Error “Printing Failed”

    I write this blog to share my experience to solve the problem of “Printing Failed” or “not all frame received […]