Using SoftSerial connecting to Car's Consult

Hey guys so I have an Arudino UNO r3, and I’m trying to connect to my Nissan 240sx Consult port.
Most of the research on how to connect has been done, and people have videos connecting their arudino’s to the consult and reading the data. I’m having trouble just connecting.
Here’s a pdf that shows how the serial communication occurs:

I have this code running trying to connect which I found which people seemed to have luck with:

#include <SoftwareSerial.h>
#define rxPin 10
#define txPin 11

void setup() {

Serial.begin(9600);
init_ECU2();

}

void loop() {

}

int init_ECU ()
{
int read_byte;
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
mySerial.begin(9600);
int i = 0;
mySerial.write ((byte)0xFF);
mySerial.write ((byte)0xFF);
mySerial.write ((byte)0xEF);
//lcd_setCursor(10, 0);
read_byte = mySerial.read();
Serial.print (read_byte);
do{
if (Serial.available()>0)
{
read_byte = mySerial.read();
//lcd_setCursor(0, 1);
Serial.print (read_byte,HEX);
};
if (i>998)
{
//lcd_setCursor(10, 0);
i=0;
mySerial.write ((byte)0xFF);
mySerial.write ((byte)0xFF);
mySerial.write ((byte)0xEF);
};

i++;

}
while ((read_byte!=0x10)));

return (1);
};

Everyone displays the data to a LCD, connecting to the car using the rx and tx pins (0 and 1), but I’ve been trying to get the data displayed back to my computer with no luck.

I’m connecting using a rs232 to ttl adapter which when connected the Rx and Tx lights on the adapter both emit saying there is a signal, the arudino mySerial reads either a -1,1 or 3 with no order. The car should respond with a 0x10 code saying it is ready to communicate, but I can’t seem to figure out why its not. I’ve been trying for the past couple of weeks which no luck.

Thanks guys!

do{
    if (Serial.available()>0)
    {
      read_byte = mySerial.read();
      //lcd_setCursor(0, 1);
      Serial.print (read_byte,HEX);
               };

Read from the SoftwareSerial instance if there is data available on the HardwareSerial port. Are you sure that that makes sense?

Woops sorry that was an old code, I corrected that and it still did not work, I even just tried to do a simple test like this:

int init_ECU2 ()
{
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
mySerial.begin(9600);
int read_byte;
mySerial.print ((byte)0xFF);
mySerial.print ((byte)0xFF);
mySerial.print ((byte)0xEF);
//delay(100);
if (mySerial.available()>0){
read_byte = mySerial.read();

Serial.print (read_byte, HEX);

return 1;

}else

return -1;

};

I have an Arudino Mega R3 coming in the mail today, so I’m hoping to try the designated RX and TX pins it has instead of doing a software serial.

  mySerial.print ((byte)0xFF);
  mySerial.print ((byte)0xFF);
  mySerial.print ((byte)0xEF);

It seems strange to me that the car would do something when it received "FFFFEF". I would expect it to do something when it received 0xFF, 0xFF, 0xFE. THAT would be done using mySerial.write().

A pet peeve of mine is shown in this code. You really don't have a mySerial attached to the Arduino, do you? I could have sworn that you said that you had a Nissan 240sx Consult attached. So, why not make that clear:

SoftwareSerial consult = SoftwareSerial(rxPin, txPin);
consult.begin(9600);

consult.write((byte)0xFF);
.
.
.

Thanks for your help Paul! I worked out some kinks in the code, and used an actual RX TX instead of a Software Serial (Arduino Mega) and it worked. I think without the 64 byte serial buffer, the data-stream couldn’t be received properly. Thanks again!

Hi.

I too am having trouble getting this code to work after a few days now of tearing hair out and now back here pulling up an old post :confused: .

I don't know what else was done to the code to get it to work. I got rid of the (do) part of the skectch and defined a consult serial on RX2 TX2 and now can get the the RX TX lights flashing on my Nissan consult plug.

Im getting -1 back in the serial monitor and don't know what else I should do.

I also tried Crims library on github and get no connection so I sat there for hours going through library folders but there not much I understand. And also tried to contact for help but with no response from emails not much I can do, shame it seems like a good library to use but no support.

Bump