PID Support Checker Sketch
Posted: Mon Apr 13, 2015 11:11 am
Here's a little sketch that uses freematics obd library to go through the list of pid's and report back which ones are supported by your car.
Code: Select all
#define SD_LOG
#define LAST_PID 128
#define DEBUG Serial3
#define DEBUG_BAUD 115200
#define LOOP_DELAY 500 //milli delay between pid's
#include <Arduino.h>
#include <OBD.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
File logFILE;
COBD obd;
void setup()
{
DEBUG.begin(DEBUG_BAUD);
DEBUG.println("PID TESTER");
#ifdef SD_LOG
pinMode(SS, OUTPUT);
SD.begin(10);
char* filename = "PID_TEST.TXT";
SD.remove(filename);
logFILE = SD.open(filename, FILE_WRITE);
logFILE.print("PID TESTER\r");
logFILE.flush();
#endif
obd.begin();
obd.init();
}
void loop()
{
static byte pid = 0;
int value;
DEBUG.print(pid);
#ifdef SD_LOG
logFILE.print(pid);
#endif
if (obd.read(pid, value)){
DEBUG.println(" RESPONSE");
#ifdef SD_LOG
logFILE.println(" RESPONSE");
logFILE.flush();
#endif
}else{
DEBUG.println(" N/A");
#ifdef SD_LOG
logFILE.println(" N/A");
logFILE.flush();
#endif
}
pid++;
delay(LOOP_DELAY);
if(pid > LAST_PID){
DEBUG.println("DONE");
#ifdef SD_LOG
logFILE.println("DONE");
#endif
while(1){};
}
}