View Single Post
Old 05-21-2008, 11:24 PM   #162 (permalink)
jmonroe
EcoModding Lurker
 
Join Date: May 2008
Location: St. Louis
Posts: 28

silverciv - '01 Honda Civic EX 2dr
90 day: 36.13 mpg (US)
Thanks: 0
Thanked 0 Times in 0 Posts
Well, I never got past a few tests.

I was using some test code which simply requests RPM when a button is pressed. It also uses my serial LCD using the software serial library.

Before I experienced some hardware problems, I could send ELM specific commands and receive the output but, the OBD commands would result in "BUS INIT:...>" with no error or anything but then the next command would do the same thing.
Code:
#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3
#define fButtonPin 4
#define keyWait 200

SoftwareSerial LCD = SoftwareSerial(rxPin, txPin);

void setup() {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  
  // start serial connections
  LCD.begin(9600);
  Serial.begin(9600);
  
  // setup button and turn on the internal pull-up resistor
  pinMode(fButtonPin, INPUT);
  digitalWrite(fButtonPin, HIGH);
  
  // set ELM to formated data
  Serial.println("ATFD");
  // turn off command echo
  Serial.println("ATE0");
  
  LCD.print("?a?fELM OUT:?n");
  // reset the ELM
  Serial.println("ATZ");
}

void loop() {
  char temp;
  // if there is something waiting on the serial connection, get that and send to LCD
  while(Serial.available()) {
    temp = Serial.read();
    LCD.print(temp);
  }
  
  // if the front button was pressed, send the ELM command
  if(digitalRead(fButtonPin) == LOW) {
    delay(keyWait);
    LCD.print("?a?f"); // clear the LCD and reset cursor
    Serial.println("010c"); // ask for the engine RPM
  }
}
__________________
  Reply With Quote