Problem connecting to ELM327

When I try to connect to the ELM327 from the ESP32 using the library bluetoothSerial, I can get it to connect but only if I go onto my phone and connect the ELM327 to the app CarScanner and then disconnect it again. Then just power on the ESP32 and it connects no problem and can display any of the support PIDs of the ELMduino library but if i power off the ESP32 and then power it on again it will not connect unless I connect it to my phone again. The serial monitor shows "Couldn't connect to OBD scanner - Phase 1" I am not sure if this is just a problem with the particular ELM327 that I have or if there is something in the code that you have to do that I am unaware of.

What I am using
ESP32
ELM327

#include "BluetoothSerial.h"
#include "ELMduino.h"


BluetoothSerial SerialBT;
#define ELM_PORT   SerialBT
#define DEBUG_PORT Serial


ELM327 myELM327;


uint32_t rpm = 0;


void setup()
{
#if LED_BUILTIN
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
#endif

  DEBUG_PORT.begin(115200);
  //SerialBT.setPin("1234");
  ELM_PORT.begin("ArduHUD", true);
  
  if (!ELM_PORT.connect("OBDII"))
  {
    DEBUG_PORT.println("Couldn't connect to OBD scanner - Phase 1");
    while(1);
  }

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

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


void loop()
{
  float tempRPM = myELM327.rpm();

  if (myELM327.status == ELM_SUCCESS)
  {
    rpm = (uint32_t)tempRPM;
    Serial.print("RPM: "); Serial.println(rpm);
  }
  else
    myELM327.printError();
}

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