Connection Issue Between ELM327 and ESP32 WROOM-32D (Stuck at the Same Point)

I’m trying to connect an ESP32 to an ELM327 BLE to read the engine RPM from a Peugeot 2008 2020 and display the data on a TFT screen for a racing dashboard project.

Using the Car Scanner app, the ELM327 works perfectly, connecting and retrieving the RPM after executing the AT command sequence (ATZ, ATE0, ATH1, ATSP0, 0100, 010C). However, on the ESP32, I can detect and connect to the ELM327, but I get the error “Couldn’t connect OBD scanner”.

I’ve been trying for days without making progress and have tested several approaches:

• Used Bluetooth Serial, but it doesn’t work since the device is BLE.

• Tested the NimBLE library, but without success.

• Tried connecting with and without a password, but neither worked.

• The ESP32 detects the device as both OBDII and OBDBLE, but only the OBDBLE establishes a functional connection via the Car Scanner app.

Even after listing the available services and characteristics in my code, I can’t send commands or receive responses. The ELM327 I’m using is similar to this one: ELM327 Mini OBD2 Car Scanner on AliExpress.

Has anyone experienced this before or has any suggestions? Any help would be greatly appreciated!

Read the pinned post re how to get the most from the forum.
So far we have nothing to work with.

’d like to apologize if I’ve made any mistakes in my post. I’m new to this topic and have taken the time to read the pinned post, but I’m still unsure about what I might have done wrong. If possible, I’d greatly appreciate some guidance to help me better understand and follow the rules. I’m genuinely eager to learn and contribute properly.

Thank you for your time and patience!

Wiring diagram, picture of hand drawn is fine. ALL the code in code tags, any error logs also in code tags.

1 Like

Hello again, regarding the wiring diagram, I don't think it's necessary because I'm just using the ESP32 and serial monitor to check, along with the ELM327, for which I have already provided the link earlier. The curious thing is that on the iPhone I only find it as OBDBLE, but on the notebook (which is a bit older) and through the bt_classic_device_discovery, I find the OBDII. Serial monitor:

However, when I use the ESP32_Bluetooth_Serial code, the following message appears: I have also tried using a password, but the message remains the same:

bt_classic_device_discovery

#include <BluetoothSerial.h>

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

#if !defined(CONFIG_BT_SPP_ENABLED)
#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip.
#endif

BluetoothSerial SerialBT;

#define BT_DISCOVER_TIME 10000

static bool btScanAsync = true;
static bool btScanSync = true;

void btAdvertisedDeviceFound(BTAdvertisedDevice *pDevice) {
  Serial.printf("Found a device asynchronously: %s\n", pDevice->toString().c_str());
}

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32test");  //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");

  if (btScanAsync) {
    Serial.print("Starting asynchronous discovery... ");
    if (SerialBT.discoverAsync(btAdvertisedDeviceFound)) {
      Serial.println("Findings will be reported in \"btAdvertisedDeviceFound\"");
      delay(10000);
      Serial.print("Stopping discoverAsync... ");
      SerialBT.discoverAsyncStop();
      Serial.println("stopped");
    } else {
      Serial.println("Error on discoverAsync f.e. not working after a \"connect\"");
    }
  }

  if (btScanSync) {
    Serial.println("Starting synchronous discovery... ");
    BTScanResults *pResults = SerialBT.discover(BT_DISCOVER_TIME);
    if (pResults) {
      pResults->dump(&Serial);
    } else {
      Serial.println("Error on BT Scan, no result!");
    }
  }
}

void loop() {
  delay(100);
}

E o ESP32_Bluetiith_Serial

#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.nb_rx_state == ELM_SUCCESS)
  {
    rpm = (uint32_t)tempRPM;
    Serial.print("RPM: "); Serial.println(rpm);
  }
  else if (myELM327.nb_rx_state != ELM_GETTING_MSG)
    myELM327.printError();
}

I tried to connect ESP32 and ELM327 with version 1.5 and it could connect, but with ELM327 version 2.0, it couldn't connect. I used the code in Arduino IDE like this.

Blockquote

"#include "BluetoothSerial.h"

BluetoothSerial SerialBT;

#define DEBUG_PORT Serial
#define ELM_PORT SerialBT

const int LED_BUILTIN = 2; // Pastikan pin ini sesuai dengan pin LED di ESP32 Anda

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);

DEBUG_PORT.begin(9600);
ELM_PORT.begin("ESP32test", true);

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

if (!ELM_PORT.connect("OBDII")) {
DEBUG_PORT.println("Couldn't connect to OBD scanner");
while(1);
}

DEBUG_PORT.println("Connected to ELM327");
DEBUG_PORT.println("Ensure your serial monitor line ending is set to 'Carriage Return'");
DEBUG_PORT.println("Type and send commands/queries to your ELM327 through the serial monitor");
DEBUG_PORT.println();
}

void loop() {
if(DEBUG_PORT.available()) {
char c = DEBUG_PORT.read();

DEBUG_PORT.write(c);
ELM_PORT.write(c);

}

if(ELM_PORT.available()) {
char c = ELM_PORT.read();

if(c == '>') {
  DEBUG_PORT.println();
}

DEBUG_PORT.write(c);

}
}`