Return to site

Toyota Obd1 Serial Interface For Arduino

broken image


Interfacing Arduino to OBD-II. As far as I've researched, there are several alternative ways to interface an Arduino with car's OBD-II port and each has different pros and cons. Sparkfun CAN BUS shield. This shield gives the Arduino CAN-Bus capability. It uses the Microchip MCP2515 CAN controller with MCP2551 CAN transceiver. Toyota Obd1 Serial Interface Adapter Rating: 5,0/5 9254 votes Ok, i think ive figured out the perfect cable that requires minimal custom work. I finally got my cable and yesterday evening i was on the road to test the whole thing.

ObdiiUartMkrShield is a socket board for Arduino MKR board to talk with vehicles through ODB-II interface.

  • 14,443 views
  • 33 comments
  • 88 respects

Components and supplies

Toyota Obd1 Serial Interface For Arduino
Arduino MKR1000
×1
OSH Park Custom fabricated PCB
×1
Sparkfun - OBDII to DB9 cable
×1

Apps and online services

About this project

Background

Previously, I published a blog of 'IoT4Car' demonstrating how to collect the vehicle data using a SparkFun OBD-II UART board and an Arduino MKR1000 board, and uploading the data into clouds for real-time monitoring. That prototype was made on a breadboard with a lot of wires, which makes it vulnerable to vibrations and bad contact. So I decided to make a customized PCB board, so called ObdiiUartMkrShield, that has similar functionalities but compatible to Arduino MKR board form factor and IO voltage tolerance.

Design Flow

On-board diagnostics (OBD) is an automotive term referring to a vehicle's self-diagnostic and reporting capability. Up till now, OBD has evolved to OBD-II standard with 16 pins interface. 5 signaling protocols are permitted in the OBD-II interface, being SAE J1850 PWM, SAE J1850 VPW, ISO 9141-2, ISO 14230 KWP2000, and ISO 15765 CAN. To simply the design, this PCB only supports Controller Area Network (CAN) protocol.

The communication between an Arduino board and a vehicle is realized by two chips. MCP2551 is used as the interface between a CAN physical layer and a CAN protocol controller. STN1110 is a multiprotocol OBD to UART interpreter that supports all 5 protocols. Here we only use its CAN protocol translation functionality. The schematics of the connection is shown in the attachment.

Though both chip datasheets provide sample circuit schematics, It is worth noting that selection of the capacitors for the crystal is critical. Differential crystal may have different cap loading. Selecting wrong cap values will result in different oscillation frequency, and thus the communication between STN1110 and MCP2551 will fail. Adafruit has a good tutorial of how to calculate the value of the capacitors that attach to the crystal. A general rule of thumb is C1, C2 = 2*CL - 2*Cstray, where CL is the crystal's load capacitance, Cstray is the parasitic capacitance and is approximately 2-5 pF.

PCB Design

The PCB layout is implement in KiCAD, which has no limitation on board size or number of connections. Siouxsie and the banshees once upon a time rar free programs free. The schematic can be found in the attachment. Below is a screenshot of the layout.

The 3D model is rendered by raytracing engine in KiCAD.

Assembly

The PCB was fabricated by OSHpark. It usually takes 10 days to fab, and a few more days for shipping. After get the boards back, and purchasing the required components, the device is ready to be assembled. For a hobbyist like me, I usually choose through hole components because they are easy to solder. Electrical engineer veterans and professionals should use SMT components because they are cheaper.

Test

Toyota Obd1 Serial Interface For Arduino
Arduino MKR1000
×1
OSH Park Custom fabricated PCB
×1
Sparkfun - OBDII to DB9 cable
×1

Apps and online services

About this project

Background

Previously, I published a blog of 'IoT4Car' demonstrating how to collect the vehicle data using a SparkFun OBD-II UART board and an Arduino MKR1000 board, and uploading the data into clouds for real-time monitoring. That prototype was made on a breadboard with a lot of wires, which makes it vulnerable to vibrations and bad contact. So I decided to make a customized PCB board, so called ObdiiUartMkrShield, that has similar functionalities but compatible to Arduino MKR board form factor and IO voltage tolerance.

Design Flow

On-board diagnostics (OBD) is an automotive term referring to a vehicle's self-diagnostic and reporting capability. Up till now, OBD has evolved to OBD-II standard with 16 pins interface. 5 signaling protocols are permitted in the OBD-II interface, being SAE J1850 PWM, SAE J1850 VPW, ISO 9141-2, ISO 14230 KWP2000, and ISO 15765 CAN. To simply the design, this PCB only supports Controller Area Network (CAN) protocol.

The communication between an Arduino board and a vehicle is realized by two chips. MCP2551 is used as the interface between a CAN physical layer and a CAN protocol controller. STN1110 is a multiprotocol OBD to UART interpreter that supports all 5 protocols. Here we only use its CAN protocol translation functionality. The schematics of the connection is shown in the attachment.

Though both chip datasheets provide sample circuit schematics, It is worth noting that selection of the capacitors for the crystal is critical. Differential crystal may have different cap loading. Selecting wrong cap values will result in different oscillation frequency, and thus the communication between STN1110 and MCP2551 will fail. Adafruit has a good tutorial of how to calculate the value of the capacitors that attach to the crystal. A general rule of thumb is C1, C2 = 2*CL - 2*Cstray, where CL is the crystal's load capacitance, Cstray is the parasitic capacitance and is approximately 2-5 pF.

PCB Design

The PCB layout is implement in KiCAD, which has no limitation on board size or number of connections. Siouxsie and the banshees once upon a time rar free programs free. The schematic can be found in the attachment. Below is a screenshot of the layout.

The 3D model is rendered by raytracing engine in KiCAD.

Assembly

The PCB was fabricated by OSHpark. It usually takes 10 days to fab, and a few more days for shipping. After get the boards back, and purchasing the required components, the device is ready to be assembled. For a hobbyist like me, I usually choose through hole components because they are easy to solder. Electrical engineer veterans and professionals should use SMT components because they are cheaper.

Test

To test the ObdiiUartMkrShield PCB board, I wrote a program that can collect the car speed, and uploaded the code in an Arduino MKR1000 board. The program is available in the attachment. The car speed will be collected and plotted on the screen. Place the ObdiiUartMkrShield PCB under the Arduino MKR1000 as a socket, and connect the PCB with a DB9 to OBD-II cable. The OBD-II connector will be plugged into the car.

Here is a simple demo video. After introduction, you will see the comparison of car speed from the car dashboard and the Arduino serial plotter.

Code

Schematics

Author

zhaoshentech
  • 5 projects
  • 57 followers

Published on

November 5, 2018
Write a comment

Members who respect this project

Loop for mac. and 80 others

See similar projects
you might like

Table of contents

Write a comment

OBD-II (an abbreviation for On-Board Diagnostics, Second Generation) is a set of standards for implementing a computer based system to control emissions from vehicles ( and a lot more ! ). If you are not familiar with OBD-II you can read more about it here.

I just recently acquired an OBD-II UART board and cable

from SparkFun.com, so I can diagnose any car problems. One end of the cable connects to the OBD-II connector on your car, the other end connects to the board. The board can then connect to any serial port via a 6 pin header that needs to be soldered on. Ibanez serial number lookup.

The 6 pin header connects nicely to an FTDI board

Toyota Obd1 Serial Interface For Arduino Programming

that Sparkfun.com also sells. The tutorial about this product shows how to attach an arduino and LCD monitor to capture data from your cars' computer.

The board did not come with any OBD-II diagnostic / analysis software but there are a number of FREE and commercial offerings to choose from.

I like to write my own software and so I came up with this Python script to inquire for and analyze the OBD information. It is too big to post here so just click on the image to download it.

If you'd like to test the Python code but do not have the OBD-II UART, you can substitute any Arduino you might have lying around. I wrote a simple sketch to emulate the OBD-II information coming from a ‘sample' car. Just attach the arduino to your computer via any USB cable, load the sketch and run the Python script.

I tested it with my Aduino Nano.

Here is the sketch:

Toyota Obd1 Code Reader

');='' }='' void='' loop()='' {='' if='' (stringcomplete)='' {='' int='' len='inputString.length();' string='' ans='4' +='' inputstring.substring(1,2)='' +='' '='' ';='' if='' (len='' >='' 4)='' ans='ans' +='' inputstring.substring(3,5)='' +='' ':';='' else='' if='' (len='' >='' 3)='' ans='ans' +='' inputstring.substring(2,4)='' +='' ':';='' else='' if='' (len='' >='' 2)='' ans='ans' +='' inputstring.substring(3,4)='' +='' ':';='' if='' (inputstring.substring(0,3)='' 'atz')='' serial.println('elm327='' v1.4');='' else='' if='' (inputstring.substring(0,2)='' 'at')='' serial.println('ok');='' else='' if='' (inputstring.substring(0,5)='' '01='' 00')='' serial.println('41='' 00:ff='' ff='' fc='' ff');='' else='' if='' (inputstring.substring(0,5)='' '01='' 01')='' serial.println('41='' 01:84='' 07='' 61='' 00');='' else='' if='' (inputstring.substring(0,5)='' '01='' 20')='' serial.println('41='' 20:ff='' ff='' fc='' ff');='' else='' if='' (inputstring.substring(0,5)='' '01='' 40')='' serial.println('41='' 40:ff='' ff='' fc='' ff');='' else='' if='' (inputstring.substring(0,5)='' '01='' 60')='' serial.println('41='' 60:ff='' ff='' fc='' ff');='' else='' if='' (inputstring.substring(0,5)='' '01='' 80')='' serial.println('41='' 80:ff='' ff='' fc='' ff');='' else='' if='' (inputstring.substring(0,5)='' '01='' a0')='' serial.println('41='' a0:ff='' ff='' fc='' ff');='' else='' if='' (inputstring.substring(0,5)='' '01='' c0')='' serial.println('41='' c0:ff='' ff='' fc='' ff');='' else='' if='' (inputstring.substring(0,2)='' '01')='' serial.println(ans='' +='' '00='' 00='' 00='' 00');='' else='' if='' (inputstring.substring(0,2)='' '03')='' serial.println('43='' 03='' 00='' 03='' 01='' 03rn43='' 13='' 01='' 04');='' else='' if='' (inputstring.substring(0,5)='' '09='' 02')='' serial.println('49='' 02:1z3768470804');='' else='' serial.println(ans='' +='' 'no='' data');='' serial.println('>');='' inputstring='; stringComplete = false; } } void serialEvent() { while (Serial.available()) { char inChar = (char)Serial.read(); if (inChar ' n')='' continue;='' if='' (inchar='' 'r')='' {='' stringcomplete='true;' if='' (inputstring='' ')='' inputstring='NULL' ;='' inputstring.touppercase();='' continue;='' }='' inputstring='' +='inChar;' }=''>
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
# from earl@microcontrollerelectronics.com
StringinputString=';
Serial.begin(9600);
Serial.println('>');
if(stringComplete){
Stringans='4'+inputString.substring(1,2)+' ';
if(len>4)ans=ans+inputString.substring(3,5)+':';
elseif(len>3)ans=ans+inputString.substring(2,4)+':';
elseif(len>2)ans=ans+inputString.substring(3,4)+':';
if(inputString.substring(0,3)'ATZ')Serial.println('ELM327 v1.4');
elseif(inputString.substring(0,2)'AT')Serial.println('OK');
elseif(inputString.substring(0,5)'01 00')Serial.println('41 00:FF FF FC FF');
elseif(inputString.substring(0,5)'01 01')Serial.println('41 01:84 07 61 00');
elseif(inputString.substring(0,5)'01 20')Serial.println('41 20:FF FF FC FF');
elseif(inputString.substring(0,5)'01 40')Serial.println('41 40:FF FF FC FF');
elseif(inputString.substring(0,5)'01 60')Serial.println('41 60:FF FF FC FF');
elseif(inputString.substring(0,5)'01 80')Serial.println('41 80:FF FF FC FF');
elseif(inputString.substring(0,5)'01 A0')Serial.println('41 A0:FF FF FC FF');
elseif(inputString.substring(0,5)'01 C0')Serial.println('41 C0:FF FF FC FF');
elseif(inputString.substring(0,2)'01')Serial.println(ans+'00 00 00 00');
elseif(inputString.substring(0,2)'03')Serial.println('43 03 00 03 01 03rn43 13 01 04');
elseif(inputString.substring(0,5)'09 02')Serial.println('49 02:1Z3768470804');
Serial.println('>');
stringComplete=false;
}
voidserialEvent(){
charinChar=(char)Serial.read();
if(inChar'r'){
if(inputString')inputString='NULL';
continue;
inputString+=inChar;
}




broken image