ESP32 + UART Adapter V1 - Does Not Get Past OBDUART.begin()

Inquiry and support for Freematics products
Post Reply
subarulogger
Posts: 2
Joined: Sat Feb 03, 2024 4:11 pm

ESP32 + UART Adapter V1 - Does Not Get Past OBDUART.begin()

Post by subarulogger »

Trying to get a simple test sketch to run using the ESP32C3 and UART V1 kit. The behavior described below is the same whether the OBDII UART module is connected to my 2007 Subaru Impreza or not.

Based on my troubleshooting: Inside of the COBD class's "begin()" method (OBD2UART.cpp), the calls to "OBDUART.begin(baudrates[n], SERIAL_8N1, 16, 17);" in OBD2UART.cpp do not return before the setup() code runs again.

With OBDUART being a label for Serial1, I am not sure why "Serial1.begin(baudrate, config)" is hanging. The code below shows the setup() function in the test sketch I am trying to run:

Code: Select all

#include <OBD2UART.h>

COBD obd;

void setup()
{
  Serial.begin(115200);
  Serial.println("1: Before obd.begin()");
  // we'll use the debug LED as output
  // pinMode(13, OUTPUT);
  // start serial communication

  obd.begin();

  Serial.println("2: after obd.begin()");
  // initiate OBD-II connection until success
  while (!obd.init())
  {
    Serial.println("Failed init");
    delay(1000);
    // digitalWrite(13, HIGH);
    // delay(1000);
    // digitalWrite(13, LOW);
  }
}
Below is the output from the serial monitor. I added println statements to OBD2UART.cpp to get an idea of where the program was getting stuck. After the "ESP32 defined" line, the output repeats.
Image

The circuit: An Adafruit GPS breakout board and MicroSD module are connected to rx, tx and SS, MOSI, MISO, and SCK respectively. Disconnecting these modules had no impact on the program's behavior.
Image

I'm a college student trying to use this kit for my senior project, so any help is appreciated!
subarulogger
Posts: 2
Joined: Sat Feb 03, 2024 4:11 pm

Re: ESP32 + UART Adapter V1 - Does Not Get Past OBDUART.begin()

Post by subarulogger »

Found out that switching the RX/TX pin values of 16, 17 to 18, 19 in the hanging call to OBDUART.begin() fixed the issue. My OBD2UART library did not have the preprocessor directive for the "ARDUINO_ESP32C3_DEV," possibly due to an out of date OBD2UART library getting installed through the VS Code Arduino extension.

Hopefully this helps someone else.
Post Reply