0

Can I use Arduino OBD library with "custom" software serial or it needs to be used with hardware UART only? For example if I have D5 and D6 pin as RX and TX in my code hooked on OBD board, how do I initialize OBD library from there?

This is the OBD library that I'm referring to.

And I'm using this Allpro OBD board.

Update Actually I would be satisfied with a answer how to know when entire response from the board is received, because this way is way too messy:

void getResponse(void){
 while(obdSerial.available()){
 Serial.write(obdSerial.read());
 }
}

Here I don't know when the message is received. And if I try to use example from Sparkfun obd-ii-uart-hookup-guide (different board doe) I ended up in infinite-loop since the board never return \r, if I send ELM command to use \n as terminator, and if I disable ELM to echo the command so that I use just one getResponse call I get some readings, but not all the time, I ended up in infinite-loop again.

asked Jun 4, 2016 at 15:31
2
  • What / where is an Arduino OBD library? What does its documentation say? Commented Jun 4, 2016 at 15:35
  • Sorry I have updated my question with links. Commented Jun 4, 2016 at 15:43

1 Answer 1

1

That library is hard-coded to use the single Hardware Serial device on the Arduino Uno or the second Hardware Serial1 device on other boards.

#ifndef OBDUART
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168P__)
#define OBDUART Serial
#else
#define OBDUART Serial1
#endif
#endif

You can edit the library's header file OBD.h to define your own serial port though:

#include <SoftwareSerial.h>
extern SoftwareSerial mySerialPort;
#define OBDUART mySerialPort

And then in your sketch create the mySerialPort SoftwareSerial object.

answered Jun 4, 2016 at 15:47
1
  • I have updated my question again, sorry :) I would really appreciate if you can take another look. But thanks for this one, this is also something that I needed. Commented Jun 4, 2016 at 15:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.