Logging extra OBD data fails
Posted: Thu Feb 09, 2017 4:30 pm
I'm trying to log extra OBD data including preset parameters by editing datalogger.ino file.
Below is line 318-333 of original code.
For OBD data, values in the pids and pids2 are retrieved in the csv file.
Values in the pids are retrieved every time, while values of pids2 are retrieved once a while.
To retrieve other parameters, I tried switching a PID code in pids2[] with FUEL_LEVEL(in FreematicsONE.h).
But the logged data didn't have fuel level data.
I also tried with other PID code, but it also didn't work.
Am I missing something or is there any problem with the original code?
I read through functions logData and readPID and couldn't find any clues.
if (one.state & STATE_OBD_READY) {
byte pids[]= {0, PID_RPM, PID_SPEED, PID_THROTTLE, PID_ENGINE_LOAD};
byte pids2[] = {PID_COOLANT_TEMP, PID_INTAKE_TEMP, PID_DISTANCE};
int values[sizeof(pids)];
static byte index2 = 0;
pids[0] = pids2[index2 = (index2 + 1) % sizeof(pids2)];
// read multiple OBD-II PIDs
if (one.readPID(pids, sizeof(pids), values) == sizeof(pids)) {
one.dataTime = millis();
for (byte n = 0; n < sizeof(pids); n++) {
one.logData((uint16_t)pids[n] | 0x100, values[n]);
}
}
if (one.errors >= 10) {
one.reconnect();
}
Below is line 318-333 of original code.
For OBD data, values in the pids and pids2 are retrieved in the csv file.
Values in the pids are retrieved every time, while values of pids2 are retrieved once a while.
To retrieve other parameters, I tried switching a PID code in pids2[] with FUEL_LEVEL(in FreematicsONE.h).
But the logged data didn't have fuel level data.
I also tried with other PID code, but it also didn't work.
Am I missing something or is there any problem with the original code?
I read through functions logData and readPID and couldn't find any clues.
if (one.state & STATE_OBD_READY) {
byte pids[]= {0, PID_RPM, PID_SPEED, PID_THROTTLE, PID_ENGINE_LOAD};
byte pids2[] = {PID_COOLANT_TEMP, PID_INTAKE_TEMP, PID_DISTANCE};
int values[sizeof(pids)];
static byte index2 = 0;
pids[0] = pids2[index2 = (index2 + 1) % sizeof(pids2)];
// read multiple OBD-II PIDs
if (one.readPID(pids, sizeof(pids), values) == sizeof(pids)) {
one.dataTime = millis();
for (byte n = 0; n < sizeof(pids); n++) {
one.logData((uint16_t)pids[n] | 0x100, values[n]);
}
}
if (one.errors >= 10) {
one.reconnect();
}