Hi,
I can’t get my head around this. For the last few days i tried to read the signals for my jaguar but i don’t get any signals back.
I’m using the library OBD9141 from Iwanders, heres the link for it https://github.com/iwanders/OBD9141.
And the code i found att Macchina website which i have changed a little bit so i do not need to use the samNonDuePin library.
Here is the code.
/*
* Example based on code found here.
* https://github.com/iwanders/OBD9141
*
* Put the "OBD9141 in Libraries folder.
*
*/
#include "OBD9141.h"
// The RX pin of the Serial1 connected to 9141 K RX of tranciever.
#define RX_PIN LIN_KRX
// The Tx pin of the Serial1 connected to 9141 K TX of tranciever.
#define TX_PIN LIN_KTX
// The Enable pin connected to 9141 SLP pin of tranciever.
#define EN_PIN LIN_KSLP
#define OBD9141_DEBUG
OBD9141 obd;
void setup(){
SerialUSB.begin(115200);
delay(2000);
pinMode(EN_PIN, OUTPUT);
digitalWrite(EN_PIN, HIGH);
obd.begin(Serial1, RX_PIN, TX_PIN);
}
void loop(){
SerialUSB.println("Looping");
obd.set_port(false);
bool init_success = obd.init();
SerialUSB.print("init_success:");
SerialUSB.println(init_success);
// 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 = true;
while(res){
SerialUSB.println(obd.readUint8());
res = obd.getCurrentPID(0x11, 1);
if (res){
SerialUSB.print("Result 0x11 (throttle): ");
SerialUSB.println(obd.readUint8());
}
res = obd.getCurrentPID(0x0C, 2);
if (res){
SerialUSB.print("Result 0x0C (RPM): ");
SerialUSB.println(obd.readUint16()/4);
}
res = obd.getCurrentPID(0x0D, 1);
if (res){
SerialUSB.print("Result 0x0D (speed): ");
SerialUSB.println(obd.readUint8());
}
SerialUSB.println();
delay(200);
}
}
delay(3000);
}
I do not really know what i’m doing wrong here. But the init function doesn’t seem to work for me, it’s probably something I’m missing.
Any help is really appreciated.