My blog moved to burak.alakus.net
For up to date revision of this article use link below
https://burak.alakus.net/en/2011/07/27/to-get-obd2-data-via-elm327-c/
According to me, the most cool part of a CARPC is the part of you’re getting engine data to your touch screen interface. It is really cool. I talked about the protocol called VAN in my previous article. VAN is a sub data protocol of CAN. OBD2 is the way to get data from your engine.
First time when I begin to work on a carpc, I always used free front-ends. But I couldn’t customize the front-end software according to my mind. Because of that I started to write on C#.NET to develop my own CARPC front-end. Multimedia applications, navigation, watching TV via 3G didn’t take my lots of time.
Getting data through my OBD2 port of my car was different. First I tried OBD2 applications like ScanTool.NET, OBDview, etc.
Let me talk about physical connection; In Cars, there is a port with standard 16 pins OBD2 port. This is the port when you get your car to technical service connect to.
The easiest way I know to get data from OBD2 is the OBD2 adapters like ELM327. You can connect that adapter to your PC through USB, and the OBD2 socket to your car. It behaves as a comport through your USB port. This means you can test and also get data from HyperTerminal program or Putty. Its command set is like a modem using AT commands.
So, if you want to get data from your car, connect to your ELM327 adapter through virtual com port using your terminal program. Then send it a AT command. Just it. By knowing this, and if you know just a bit serial programming, do you really need to purchase a Diagnostics application? I answered this question as “NO”.
To start getting informations about your engine status, you need to initialize your ELM327 with your car. OBD2 data protocols varies by car vendors and specs. You need to initialize your OBD2 device according to your car.
Usually, each value in OBD2 (speed, rpm, engine load..) uses 4 digits Hex number to identify themselves. You send the request with their identify number and it responds to you by its identify number. The logic is very easy at all.
Example: Send command “010C”
Receive response “010C001B”
010C is the identifier, 00 1B are the data hex numbers.
the first 00 is the A, and the 1B is the B let’s say.
we will know that the identifier 010C means rpm. To calculate rpm you need to make math between A and B.
rpm=((A*256)+B)/4
Now let’s clarify the initialization process; (C#.NET Code)
serialPort1.PortName = comPort; try { serialPort1.Open(); } catch (System.Exception excep) {} send_data("ATZ"); System.Threading.Thread.Sleep(2000); send_data("ATE0"); System.Threading.Thread.Sleep(1000); send_data("ATL0"); System.Threading.Thread.Sleep(500); send_data("ATH1"); System.Threading.Thread.Sleep(500); send_data("ATSP 5"); System.Threading.Thread.Sleep(500); send_data("01 00"); System.Threading.Thread.Sleep(500);
The code above, starts sending intialization commands with helping threading. ATSP command is important. ATSP 5… number 5 is the protocol for my car. You need the try it with others if this does not work for yours. To make tries, the best way is to use putty. Use the initialization commands by using your keyboard and try ATSP command from 1 to 5. if the protocol you try is not compatible your car, you get “error” or “no data” response. It is not a big issue and can be achived by easy movements.
ATZ command; resets the ELM327.
ATE0, ATL0; disables extended responses. When it is disabled it is easier to process the responses programmatically.
ATH1; enables the responses with their headers. It is good to enable it because in responses you can see the identifier of data. So it is easier to understand the response.
We talked about the ATSP command. But as shortly, ATSP1, ATSP2, ATSP3, ATSP4, ATSP5 are the protocols.
0100 command is to test if the connection is OK.
As I talked above, each value of engine has a PID (010C, 010D)
01 | 0C | 2 | Engine RPM | 0 | 16,383.75 | rpm | ((A*256)+B)/4 |
01 | 0D | 1 | Vehicle speed | 0 | 255 | km/h | A |
To get the other pids meaning you can use the releated wikipedia page; http://en.wikipedia.org/wiki/OBD-II_PIDs
Every car does not response to evey pid. Speed, engine rpm, these are standardized pids. And most cars easily response to that pids.
I can get the ; speed, engine rpm, engine tempature, engine load, engine air flow rate, vehicle battery voltage from my car. (battery voltage is not obd2 releated data, just vc command)
Other thing is threadings.. they are very important because you have to wait for being ready of elm327 before sending a new command. 200 ms is enough for ELM327’s internal process.
Another trick is that you don’t have to try it with your car. there is a simulation application called “obdsimwindows”. It creates a virtual obd2 port
I read about this simulation program in mp3car forum.
This is just a obd2 article for geeks not a step by step tutorial.
Any thoughts on what the appropriate port settings are (baud rate, etc) when trying to connect the device?
I am using 38400 8 N 1 N for my ELM327 adapter
Hi
I am a student of a Software Engineering final year and we have chosen the project that can detect the defects of a car engine basically I am C# developer and I need to know that which micro controller device is the best for……. Is it ELM327 ?
Thanks
Rind Balouch
If you want to do just diagnosing and monitoring, the most suitable one is elm327. As I know it is also a microcontroller based on microchip’s pic.
You can also try chipkit max32 and Chipkit Network Shield from Digilent Technologies and they are 32bit microcontrollers and are expected to be faster.
This seems pretty simple to use, any plans for a mac version?
i want to get data like oil level, fuel level,seat belt condition and transmission gear but i don’t know the command …….
is there somebody who knows the commands ….provide me here…..or mail me jaydeepgt@thegt.com
this commands are usually not generic ones. these commands are brand specific codes. you cannot get these codes by a standard elm327 adapter.
HI,
I was trying to measure some parameter on car (toyota (Model -etios)) by elm327 obd cable and using hyperterminal with baudrate 39800. but when i issue the THE PID 0100 I GET THE RESPOSE IN 8BYTES(LIKE 2A 4B 11….1A) NOT exactly remember,but i have read in link “http://en.wikipedia.org/wiki/OBD-II_PIDs” that this pid will respond with 4 bytes data. please tell me what exactly mean of data in my case,
thanks….
are you sure that you are initiating the connection with right parameter. 39800 is the conn between your adapter and pc i guess. i mean you should check the obd2 protocol.
Thanks, You Really Helped Me
hi
hi
how r u?
i hope u r fine.
i am vs programer
i have citroen c4 2013 , obdlink mx and android mobile
i connected with my car with apps from mobile and pc
i want to control my car with obdlink mx like
(obdcanex–>http://obdcanex.com/o/,
delphi–>http://www.verizonwireless.com/wcms/consumer/devices/vehicle-diagnostics.html)
can you help my
pls if you can help me send to me soon
my email —- > maaa0s0@hotmail.com
It is very easy to use obd2 by using elm327 as you can see from article. The important point not all cars provides full access via obd2. You need to work with can which is more complex to use but more informative choice 😉
Hi,
Thanks for putting across the article, it is quite helpful.
I was wondering if it is possible to get rid of an interpreter chip and get all the OBDII data dump by building a simple CAN interface. Take the dump and store in a flash device for further analysis.
Let me know your comments on this.
Sure you can. It is not very hard by using arduino or microchip based circuit. Also you can modify the elm327 circuit and add yours circuit that sends commands to elm327 and stores the result in somewhere.
Thanks for your reply.
I have to blindly dump the data into SD card without analyzing or interpreting it. Data analysis will be done later and it is not a part of initial project.
So, I guess a circuit with MCP2551 (line-transcoding) will work. MCP2551 will output the CAN-BUS in logic-level signalling. And you can read this output from PIC and store to SD.
Hi,
Do you have an idea to get an analog signal from my 2010 model Renault Grand Scenic OBDII port which uses CAN prothocol. I need this analog signal for Valeo Guideo Lane departure warning unit. In the installation guide booklet of Valeo Guideo it says like that:
“1)Locate the vehicle’s speed information:(either at its radio,or at the speed output used by the GPS, or at the ABS ).
2)Use the multimeter to check that it is indeed speed information:Connect the multimeter’s –connection to the vehicle’s ground, and its + connection to the located speed output.Drive a short distance to check the information; the reading should fluctuate between 0 and 12V.
Note:On certain multiplexed vehicles, the speed information is coded and cannot be used in unmodified form (on the Peugeot 807, for example). In this case, you can connect an electronic decoder (interface) to the multiplexed cable in order to convert the electronic data into electrical speed information that the multimeter can recognise”
Please help.
As I understood it does not use can bus for that. It is using car’s speedometer hardware directly which inputs your ecu. So this is not something related to CAN BUS.
hi,
I want to read only 0131 (Distance traveled since codes cleared).
Have I to send those all commands? (ATZ, ATE0….)
Can I send only 0131?
I mean how to correctly initiate ELM327?
If it is not the first time that you re using elm437 you do not need to set up the connection parameters, so in this case probably atz will be enough for initialisation.
no first you should initilize the elm327 by sending this commands
Hey I tried to connect to an ODB2 Adapter, to read some information. When I tried your connection Sequence, I got back : BUS INIT: ERROR, do you know what went wrong?
Probably you did not christe right OBD protocol to talk to your car.
Hi Burak,
Why we have to wait for 200 msec for the internal process of the elm327. What is the process taking such time ? And is it possible to make it quick?
May be with new release of elm327 it is different. As you can see it is an old article and at that time, if I sent my commands continously, I saw that elm327 gets stack. So practically I solved it by pausing 200 msec. for each command.
Hi there, I want to get SOC, GID, Mileage, Kms driven, Car diagnostics parameters through OBD II scanner?
CAR Model: Nissan LEAF S/ SV (Electric Vehicle) SV
Can you please advise me with which scanner should i purchase from Market
Do they support and compatible with Nissan Leaf S/SV model?
I am looking forward to buy OBD II to WI-FI adaptor? Are these available?
After I build Wi-Fi connection: Is it possible to use standard AT Commands for Extracting Data from Nissan Leaf EV?
Is ELM327 adaptors from OBDII to wifi , would be sufficient and compatible to use. Please help
Is there any limitations on OBDII via Wifi with adaptor
Requesting you to put me in right direction
thanks,
Hi, great post!
Hi,
Thank you for your article it’s very helpful.
I want to test each speaker of the car,
Wondering what kind of commands I can use to isolate each speaker?
(Like turn on the right back door speakers and all other speakers off.)
At Least for my citroen, it is not possible as i know. First you should search if it is possible by using official diagnostic software
Any suggestions on using the elm327 wifi connections with C#?