Not sure if OBD-II UART adapter v1 is connecting

Inquiry and support for Freematics products
Post Reply
jhsqq4
Posts: 1
Joined: Mon May 23, 2022 6:50 am

Not sure if OBD-II UART adapter v1 is connecting

Post by jhsqq4 »

I'm trying to set up an real-time MPG readout with an Arduino Uno in my 2004 Subaru Outback, and I am not sure if the car and Arduino are communicating properly. Running the built-in LED RPM test doesn't do anything, and the serial output from obd_uart_test doesn't display any of the information it's supposed to:
output2.PNG
output2.PNG (14.42 KiB) Viewed 6142 times
As far as I can tell from my research, the 2004 Outback uses either ISO9141-2 or KWP2000, both of which are supported by the adapter unless I am mistaken. My end goal is to display MPG on a TM1637-powered 7-segment LCD using this code:

Code: Select all

#include <OBD2UART.h>
#include <Arduino.h>
#include <TM1637Display.h>
 
//set display pins here
#define CLK 2
#define DIO 3

COBD obd;

TM1637Display display(CLK, DIO);

void setup()

{
  obd.begin();
  // initiate OBD-II connection until success
  while (!obd.init());  
}

void loop()

{
   int k;
  uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
  uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
  display.setBrightness(0x0f);
  //read fuel mass flow rate
  int maf;
  obd.readPID(PID_MAF_FLOW, maf);
  //read vehicle speed
  int vss;
  obd.readPID(PID_SPEED, vss);
  //fancy math to make units good
  vss = vss * 710.7;
  float mpg;
  mpg = vss / maf;
  mpg = mpg * 100;
  //output mpg to display with leading zeros
  display.showNumberDec(mpg, true);
  delay(100);
}
Any ideas or help would be greatly appreciated!
stanley
Site Admin
Posts: 1039
Joined: Sat Mar 01, 2014 3:15 am

Re: Not sure if OBD-II UART adapter v1 is connecting

Post by stanley »

Be aware you can't use USB serial as Arduino's hardware serial is connected to the adapter.
Post Reply