Show or hide header
Welcome Guest, posting in this forum require registration.

Torque » Torque OBD ECU Scanner » Torque Discussion / Ideas » Arduino OBD

Pages: [1]
Author Topic: Arduino OBD
Posts: 25
Post Arduino OBD
on: April 28, 2020 (GMT)

Hi folks,
I successfully connected Arduino via Bluetooth module HC-05 to my car’s ELM327 OBD2 bluetooth adapter.

Currently I’m able to send PID requests and read their responded values on Arduino’s LCD display and also in serial port monitor.

Harder part for me is to understand how to obtain correct bytes for equation after converting HEX response to DEC value.

If someone experienced can help me resolve this I will be very grateful.

Here’s part of my Arduino code:

BuildINString = "";  

Serial.println("213E1");                         //PID request 213E1
delay(1000);                                     //wait 1 sec.

WorkingString = BuildINString.substring(7,9);    //Obtain data for equation    here I'm not sure which bytes to use  
A = strtol(WorkingString.c_str(),NULL,0);        //Converts HEX to DEC; A is defined as Long 
WorkingString = BuildINString.substring(11,13);  //Obtain data for equation    here I'm not sure which bytes to use  
B = strtol(WorkingString.c_str(),NULL,0);        //Converts HEX to DEC; B is defined as Int

DisplayValue = (((A*256)+B)*0.02)-40;            //Equation
DisplayString = String(DisplayValue) + "°C";     //Result of equation with °C
Serial.println(DisplayString);                   //Shows result of equation in serial port monitor
lcd.setCursor(0, 1); 
lcd.print(DisplayString);                        //Shows result of equation on Arduino's LCD display

Responded value from serial port monitor of PID 213E1 were 613E0C13.

Posts: 2892
Post Re: Arduino OBD
on: April 28, 2020 (GMT)

If 213E request response is…

61 3E 0C 13

0x0C13 = 3091

(3091*0.02)-40 = 21.82 °C (71.28 °F)

Torque variable addressing…

A and N0 begin at 0x0C.
R0 at 0x61.


Pages: [1]
WP-Forum by: Fredrik Fahlstad, Version: 2.4
Page loaded in: 0.056 seconds.

  Follow me on twitter