Saturday, September 5, 2015

Vehicle On-board Diagnostics (OBD 2)

I got an Check Engine light on my car recently and was thinking about getting one of those handheld diagnostic code scanners to read the On-board Diagnostic information (OBD) and decided to do a quick look for other options instead of a dedicated device. I searched for Arduino shields, USB/serial cables, etc. I found this cool device for about $20 on Amazon --> HERE. It is a WiFi OBD 2 dongle that plugs right into your car's OBD jack and is powered directly off the car connector as well.



The device basically acts like a WiFi Access Point. So you have several options for connecting to it. I first got a free iPhone app called FourStroke which worked just fine. The device gives your phone an IP address of 192.168.0.11 and the dongle is at 192.168.0.10 on port 35000.



 FourStroke works pretty good for a free app but has several features that need to be paid for to work, so I did more research and found the DashCommand App that is feature packed but cost $10.


Both of these apps are able to pull my fault codes and even clear the check engine light, but I was wondering how this thing works and discovered about the ELM327 that the dongle uses. The ELM327 translates the OBD2 protocol to serial. The serial data is presented on a TCP port via the WiFi network. With this knowledge I used the trusty Virtual Serial Port Emulator software VSPE that I have used in my other projects and setup a COM port connector (COM4 <--> COM7) and a TCP client on 192.168.0.10 port 35000 connected to COM7.


Then using Putty I connected to COM4 and bingo, I was at the ELM327 command prompt! Believe it or not ELM327 uses AT commands like the old serial MODEMs. The below output from Putty is showing the output after I issued an "AT DP" to Display Protocol. In this case it returned ISO 9141-2.

Wikipedia says this protocol has an asynchronous serial data rate of 10.4 kbit/s. It is somewhat similar to RS-232; however, the signal levels are different, and communications happens on a single, bidirectional line without additional handshake signals. ISO 9141-2 is primarily used in Chrysler, European, and Asian vehicles.

This makes sense since my car is a Toyota. The ELM327 abstracts all of the above for you. I found the basic commands to read codes from the car at this site --> HERE. The first command 010C is a request for the RPM. The last two bytes are the RPM (0A EC) in hex. 0AEC hex is 2796 in decimal and needs to be divided by 4 to get the actual RPM which is 699 rpm. I queried it again and got 0B0F which is 707 rpm. I performed the other exercises from the site above and everything worked as expected.

The dongle came with some software on a small CD that was a bit questionable, but I did try one called ScanMaster-ELM. I ran it on a WinXP SP3 laptop because it is old software, however it did work and I was able to pull codes like the iPhone apps and clear codes, etc. It did hang a few times so it may be buggy and or touchy in how it is used..

Now that I know that OBD/ELM327 works using a polling method, I should be able to code up a scanner to do anything I need  and perhaps do specific logging for analysis, etc. 

This was much more fun than just buying a dedicated OBD scanner.

73, Dan

1 comment:

  1. Hey Dan,

    Just to offer more resources that I found useful during the development of Fourstroke -- Wikipedia has a whole slew of helpful commands and responses as well as how to decode them into useful values: https://en.wikipedia.org/wiki/OBD-II_PIDs

    Automatic is another interesting app worth looking into as it tracks mileage and location of the car along with a code reader as well.

    FYI if you want to see the connection sequence of FourStroke simply go to the wifi settings after having connected to the OBD system and press and hold the Send Report (even if it is greyed out). After a few seconds it will show you all the commands sent and received.

    Hope this helps :)
    Mike @ FourStroke.ca

    ReplyDelete