According to me, the most cool part of a CARPC is where you get OBD2 data to your touch screen interface. It is really cool. I wrote about the protocol called VAN in another article. OBD2 is the way to get data from your engine control unit which also called ECU.
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 requirements. So I started to develop my own CARPC front-end. Multimedia applications, navigation, watching TV via 3G and so on..
Getting data from my OBD2 port of my Citroen C4 was different. I tried OBD2 applications like ScanTool.NET, OBDview, etc. always there was missing functionality that one app cannot provide.
Physical Connection to get OBD2 Data
Let me talk about physical connection; In Cars, there is a port with standard 16 pins OBD2 pinout. This is the port when you get your car to technical service used to connect.
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, then the OBD2 socket to your car. It behaves as a COM port through your USB. This means you can test and also get data from HyperTerminal program or Putty. Its command set is like a modem; using AT commands.
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? Clearly.. “NO”.
Using ELM327 to get OBD2 Data
To begin retrieving data from your engine, you need to initialise 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 vendor and model.
Usually, each value in OBD2 (speed, rpm, engine load..) uses 4 digits Hex number as identifier. You send the request with their identifier id and it responds to you by its identifier id. 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 initialisation commands using 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 try each command one by one, the best way is to use putty. Use the initialisation 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.
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 shortly, ATSP1, ATSP2, ATSP3, ATSP4, ATSP5 are the protocols.
0100 command is to test if the connection is OK.
ELM327 PIDs
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 respond to that pids.
I can get; 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.
February 18, 2012 at 04:38
Any thoughts on what the appropriate port settings are (baud rate, etc) when trying to connect the device?
February 18, 2012 at 14:15
I am using 38400 8 N 1 N for my ELM327 adapter
March 22, 2012 at 21:13
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
May 12, 2012 at 12:58
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.
September 13, 2012 at 16:10
You can also try chipkit max32 and Chipkit Network Shield from Digilent Technologies and they are 32bit microcontrollers and are expected to be faster.
July 6, 2012 at 18:31
This seems pretty simple to use, any plans for a mac version?
July 24, 2012 at 06:50
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 [email protected]
July 24, 2012 at 19:18
this commands are usually not generic ones. these commands are brand specific codes. you cannot get these codes by a standard elm327 adapter.
February 4, 2013 at 08:28
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….
May 28, 2013 at 17:53
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.
February 25, 2013 at 05:50
Thanks, You Really Helped Me
August 19, 2013 at 01:50
hi
August 19, 2013 at 02:00
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 —- > [email protected]
August 21, 2013 at 19:16
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 😉
August 20, 2013 at 13:11
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.
August 21, 2013 at 19:13
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.
August 26, 2013 at 15:20
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.
August 26, 2013 at 15:31
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.
November 14, 2013 at 17:24
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.
November 16, 2013 at 13:09
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.
February 13, 2014 at 14:48
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?
February 14, 2014 at 08:03
I mean how to correctly initiate ELM327?
February 14, 2014 at 13:56
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.
February 14, 2014 at 13:03
no first you should initilize the elm327 by sending this commands
December 11, 2014 at 23:12
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?
February 3, 2015 at 00:14
Probably you did not christe right OBD protocol to talk to your car.
March 26, 2015 at 14:52
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?
April 6, 2015 at 16:17
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.
May 17, 2015 at 20:56
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,
June 30, 2015 at 20:35
Hi, great post!
July 29, 2015 at 22:11
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.)
September 17, 2015 at 11:32
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
January 23, 2016 at 15:28
Any suggestions on using the elm327 wifi connections with C#?
July 17, 2018 at 13:10
Hi
I would like to create a wrapper application (C#) which will communicate with OBD to get the speed parameter.
Please let me know if you have a suggestion for that.
Thanks, Eli