-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include "Arduino.h" | ||
#include "OBD9141.h" | ||
|
||
#define RX_PIN 0 | ||
#define TX_PIN 1 | ||
#define EN_PIN 2 | ||
|
||
|
||
OBD9141 obd; | ||
|
||
|
||
void setup(){ | ||
Serial.begin(9600); | ||
delay(2000); | ||
|
||
pinMode(EN_PIN, OUTPUT); | ||
digitalWrite(EN_PIN, HIGH); | ||
|
||
obd.begin(Serial1, RX_PIN, TX_PIN); | ||
|
||
} | ||
|
||
void loop(){ | ||
Serial.println("Looping"); | ||
|
||
// only change from reader is the init method here. | ||
bool init_success = obd.initKWPSlow(); | ||
Serial.print("init_success:"); | ||
Serial.println(init_success); | ||
delay(50); | ||
|
||
//init_success = true; | ||
// Uncomment this line if you use the simulator to force the init to be | ||
// interpreted as successful. With an actual ECU; be sure that the init is | ||
// succesful before trying to request PID's. | ||
|
||
if (init_success){ | ||
bool res; | ||
while(1){ | ||
res = obd.getCurrentPID(0x11, 1); | ||
if (res){ | ||
Serial.print("Result 0x11 (throttle): "); | ||
Serial.println(obd.readUint8()); | ||
} | ||
delay(50); | ||
|
||
res = obd.getCurrentPID(0x0C, 2); | ||
if (res){ | ||
Serial.print("Result 0x0C (RPM): "); | ||
Serial.println(obd.readUint16()/4); | ||
} | ||
delay(50); | ||
|
||
|
||
res = obd.getCurrentPID(0x0D, 1); | ||
if (res){ | ||
Serial.print("Result 0x0D (speed): "); | ||
Serial.println(obd.readUint8()); | ||
} | ||
Serial.println(); | ||
|
||
delay(200); | ||
} | ||
delay(200); | ||
} | ||
delay(3000); | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters