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){

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.

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

1 Answer 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
#define OBDUART Serial1

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.

  • 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.
    – ShP
    Jun 4, 2016 at 15:50

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.