Ellmduino library connection

Hello,
I'm new on the forum and quite new on arduino programming. I am trying to connect to my Honda Civic 2015 (model 2013 Civic 9) using Elmduino library but I always have the message error "Couldn't connect to OBD scanner ELMduino".
I am not using Elmduino instrument I just have my own obd connector connected to my teensy 3.2 with the corresponding power but I at the end, I think it should work too.

Here the code I am using just to try the connection.

#include <SoftwareSerial.h>
#include "ELMduino.h"


SoftwareSerial mySerial(4, 3); // RX, TX
#define ELM_PORT mySerial

ELM327 myELM327;
unsigned int mph = 0;

unsigned int RPM;

void setup() {


  Serial.begin(115200);
  (!Serial);
 
//  mySerial.begin(115200);
//  myELM327.begin(mySerial, true, 2000);//ISO_15765_29_BIT_500_KBAUD, 2000);
 ELM_PORT.begin(115200);

  Serial.println("Attempting to connect to ELM327...");

  if (!myELM327.begin(ELM_PORT, true, 2000))
  {
    Serial.println("Couldn't connect to OBD scanner");
    while (1);
  }

  Serial.println("Connected to ELM327");
}

elapsedMillis DisplayTime; //Establish a timer to prevent unnecessary screen rewrite

void loop(void) {
  //Serial.print(mph);
  //Serial.print("\n");

  //float tempRPM = myELM327.rpm();
  float tempRPM = myELM327.batteryVoltage();
  RPM = uint32_t(tempRPM);
  if (myELM327.nb_rx_state == ELM_SUCCESS)
  {
   RPM = (uint32_t)tempRPM;
    Serial.print("RPM: "); Serial.println(RPM);
      mph = 25;
  }
  else if (myELM327.nb_rx_state != ELM_GETTING_MSG){
    myELM327.printError();
      mph = 150;
  }
  else{
  mph = 40;
  }
}

Why did you create an ELM327 object and then not call myELM327.begin(() to initialize it? You can't expect the library to talk to your serial hardware if you don't tell the library which serial port to use.

Thank you for your answer, I also tried it unremarking the lines above but no succes neither.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.