1

I have a project where in I have to develop an app with the help of IoT which fetches data of fuel tank level value and odometer value as these values are not available in normal OBD available in the market. I have found that ELM327 communicates through WIFI using WLAN protocol and Serial Communication. But I am out of ideas as to how to establish this communication with Arduino esp32 module. Any ideas on this would be of great help.

nerd_god
  • 25
  • 1
  • 6

1 Answers1

0

You can do it easily with the right steps:

  1. Make sure to setup classic bluetooth with "BluetoothSerial.h"
  2. When calling .begin(), make sure to include the second argument (bool true)
  3. Call .connect("OBDII") to connect to your ELM327
  4. Ensure you only send a carriage return (no newline!) when sending commands/queries to the ELM327

Here is a simple example program (tested on my own ELM327 today):

#include "BluetoothSerial.h"


BluetoothSerial SerialBT;


#define DEBUG_PORT Serial
#define ELM_PORT   SerialBT


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

  DEBUG_PORT.begin(115200);
  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);
  }
}

Also, ELMduino now supports ESP32 boards for easy connection and vehicle data queries!

P_B
  • 94
  • 6