Comments: OBD II Uart Hookup Guide

Pages

Comments 5 comments

  • ——————– Tech Support Tips/Troubleshooting/Common Issues ——————–

    If you are having issues reading the characters sent back from the OBDII UART in the serial terminal (assuming that you are using Tera Term) after typing a command, it’s most likely due to the settings of your serial terminal. After sending the atz command into the terminal window and hitting the “enter” button, I received this as the response:

    >LM327 v1.3a
    

    Try changing the setting in your terminal window’s “New-line” field for Receive from CR to CR+LF. The characters will not overwrite itself after changing these settings. You will be able to see the expected output as shown in the tutorial:

    atz
    
    ELM327 v1.3a
    >
    
  • When 0100 is entered where does the 0x40 come from? The tutorial says it responds with the mode

    The first response byte (in this case 0x41) lists the mode that was requested in the command. Thus the board sends 0x40 + 0x01

    but I don’t understand the 0x40 bit - is it just the arbitrary value of the response?

  • You are missing a / on the first line of the 3rd part of the code, and why wouldn’t you use software serial for both the lcd AND the obd ii board? That would eliminate the need to disconnect it when flashing.

  • In order that the serial communication works, the Baud rate needs to be set to 38.4 KBps

    I checked the ELM327 datasheet too, and it says that the default baudrate for serial communication is set to 38.4 KBps. The tutorial instructs to set the baud rate to 9600 bps. I think the tutorial needs to be updated with the correct baud rate.

  • I noticed that I am having an issue implementing this code with speeds above idle. I added a Serial.println after the program gives the command 010c to ask for RPM data and I notice the serial monitors starts to say STOPPED.

    Notes: My code is almost identical to the one outlined above except that I stripped out the speed sections and focused on RPM and I am using the Liquid Crystal library as opposed to the serial library as I do not know if the lcd I have has a serial interface.

    <#include <LiquidCrystal.h>
    
    LiquidCrystal lcd (12, 11, 5, 4, 3, 2);
    
    char rxData[20];
    char rxIndex=0;
    
    int vehicleRpm=0;
    
    void setup(){
      lcd.begin(16,2);
      Serial.begin(9600);
    
      lcd.setCursor(0,0);
    
      delay(1500);
    
      Serial.println("ATZ");
    
      delay(1500);
    
      Serial.flush();
    }
    
    void loop(){
    
      Serial.flush();
    
      lcd.setCursor(0,0);
    
      lcd.print("        ");
    
      Serial.println("010C");
      delay(1000);
    
      getResponse();
      getResponse();
    
      vehicleRpm = ((strtol(&rxData[6],0,16)*256)+strtol(&rxData[9],0,16))/4;
    
      Serial.println(rxData);
    
      lcd.print(vehicleRpm);
    
      delay(5000);
    }
    
    
    void getResponse(void){
      char inChar=0;
    
      while(inChar != '\r'){
    
        if(Serial.available() > 0){
    
          if(Serial.peek() == '\r'){
    
            inChar=Serial.read();
    
            rxData[rxIndex]='\0';
    
            rxIndex=0;
          } else {
            inChar = Serial.read();
    
            rxData[rxIndex++]=inChar;
          }
        }
      }
    }
    

    My results looking at the serial monitor resulted in the following:

    ATZ
    010C
    
    010C
    ELM327 v1.3a
    010C
    >010C
    010C
    STOPPED
    010C
    >010C
    010C
    STOPPED
    010C
    >a
    010C
    
    010C
    
    010C
    SEARCHSTOPPEDSTOPPED
    010C
    

    Any help would be greatly appreciated.


If you've found a bug or have other constructive feedback for our tutorial authors, please send us your feedback!