K Line communication help

Hi folks, I saw the forum of @p4prix (Comunicating Uno & ISO9141-2)

I just want to retrieve the vehicle's speed, RPM alone

I need to establish this with the help of Arduino UNO, I've used the same circuit and code from that forum but that's not working.

I have attached some images of my work, I'm not an electronic expert


can somebody help me with this please.

As is obvious from the photographs
Check your wiring very carefully

Please post your code here, using code tags when you do

What happens when you upload the sketch ?

I have resoldered the circuit, I hope this looks a less messy

refer both the circuits

In my circuit:
R1 = 10K
R2 = 47K , 33K(as per the ckt)
R3 = 3.2K
R4 = 530
R5 = 2.2K
Q1,Q2 = BC547

#include "Arduino.h"
#include "OBD9141.h"
#include "AltSoftSerial.h"

#define RX_PIN 8
#define TX_PIN 9
// #define EN_PIN 4

AltSoftSerial altSerial;

OBD9141 obd;

void setup(){
Serial.begin(9600);
delay(2000);

// pinMode(EN_PIN, OUTPUT);
// digitalWrite(EN_PIN, HIGH);

obd.begin(altSerial, RX_PIN, TX_PIN);

}

void loop(){
Serial.println("Looping");

bool init_success = obd.init();
Serial.print("init_success:");
Serial.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;
while(1){
res = obd.getCurrentPID(0x11, 1);
if (res){
Serial.print("Result 0x11 (throttle): ");
Serial.println(obd.readUint8());
}

res = obd.getCurrentPID(0x0C, 2);
if (res){
Serial.print("Result 0x0C (RPM): ");
Serial.println(obd.readUint16()/4);
}

res = obd.getCurrentPID(0x0D, 1);
if (res){
Serial.print("Result 0x0D (speed): ");
Serial.println(obd.readUint8());
}
Serial.println();

delay(200);
}
delay(200);
}
delay(3000);
}

The code uploads fine and working, but it's not communicating with the K Line,

it's just printing

Looping
init_success = 0

again and again

that means the code works fine right
only the communication is not establishing

I don't know where is the problem

please help me out

There is a procedure to use the "K" line which I do not see you addressing. Here is a link that will help: https://www.instructables.com/Low-Cost-OBD2-Communications-on-K-line-ISO-9141-2-/

I followed the instructions on the website, but the code provided there is not beginner-friendly.

I built the circuit as described, but instead of using the Microchip 16f886 microcontroller (as used on the website), I used an Arduino. However, the C code provided is too confusing for me, and I don't know how to implement it.

I want to get the data from the K-line using an Arduino. If you know how to adapt the instructions for use with an Arduino, please help me. Thank you!

1 Like

It is not as simple as it appears, you could get a copy of the ISO-81418-2 and read that. When we put that together many years ago it started at 5 baud and worked its way up until either the car or reader was at maximum. You might also look at CAN as that information is on that bus as well.

someone has already done that :wink:

the circuit you created should still be compatible... hopefully its 'simple' enough to you to understand where to connect your wires! :slight_smile:

hope that helps....