Page 1 of 1

adapter V2.0 with software serial.

Posted: Fri Mar 19, 2021 4:21 pm
by kjh
Hello?

I'm using adapter v2.0 with software Serial.
I plugged adapter's white line to my arduino UNO pin3, and green line to pin2.

I plugged adapter to OBD2 port but It seems nothing happened to my laptop serial monitor.

Is there any error with my code?



#include <OBD2UART.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);

COBD obd;

void readPIDSingle()
{
int value;

if (obd.readPID(PID_RPM, value)) {
mySerial.print(value);
Serial.print(value);
}
mySerial.println();
Serial.println();
}

void setup()
{
mySerial.begin(115200);
while (!mySerial);
obd.begin();

// initialize OBD-II adapter
do {
mySerial.println("Connecting...");
Serial.println("Connecting...");
} while (!obd.init());
mySerial.println("OBD connected!");
Serial.println("OBD connected!");
}

void loop()
{
readPIDSingle();
}

Re: adapter V2.0 with software serial.

Posted: Mon Mar 29, 2021 7:57 pm
by stanley
Be aware software serial is never stable above 38400bps on ATmega328.