Arduino OBDII Bluetooth Car Engine RPM Shift Light

It 's about an Arduino project connected to an ELM-327 OBDII Bluetooth through a HC-05 bluetooth module.
The HC-05 is connected to Arduino with serial UART, and is configured (with AT commands) as Master to connect to ELM-327 OBDII Bluetooth which is the slave.
As soon as connection established begins the initialitation (with AT commands) of ELM-327.
After that we can read Engine RPM from car's ECU.
Next just display the RPM to 7-segment LEDS.
Shift Lights going ON at the RPM that we configure pressing the button at desired Engine RPM, value is stored to EEPROM.
Please feel free to comment or suggest or contact me.
Code needs some comments, i hope i can post soon, schematics will post as soon as possible.

Kostas

http://www.ebay.co.uk/itm/251208216925?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

1 Like

Hello, you have the source code available? I liked your project, i have one ELM/327 OBD2 OBDII Bluetooth and i use it with my Android phone, but with your Bluetooth module for arduino i can make something different :slight_smile:

I think that finally i got the code completed.
It is working with great accurancy.

But because i am not pro, be free to suggest any improvement or ask for some explanations.

http://www.kokoras.com/OBD/Arduino_HC-05_ELM327_OBD_RPM_Shift_Light.htm

Hello, in your code you have setupBlueToothConnection where you put the AT commands, it is necessary run this code every time that we start the circuit? The last changes\configurations are not saved on the bluetooth module memory if we dont use the 'Reset' command?

P.S.: How you found the address of your Elm327? for example, if i have this: "00:02:03:ac:a1:d3"..

Hi, I am looking for a similar Project, using an Arduino Uno, one, HC05 Serial BT, an a OBD2 BT device. The fact is if you can use an automated procedure to connect serial BT HC05 and OBD2 BT every time you put power to HC05 serial BT ( or the Arduino in which it is connected). The procedure is simple, first ger the MAC addres of the OBD2 BT, simply connecting to it with a BT device and pairing it, an android phone or a PC, are suitable to do, then in properties of the OBD2 BT device you can find the MAC. When you get it, then you must to insert this MAC as a pairable ítem in the Serial BT HC05, al so a simple fact. First take a RS232 USB module (in DX.com you can find a cheap one), and connect it to de serial BT HC05, put the HC05 in AT command mode shorting pin 34 (pio11) with VCC using a resistance about 470Ohms or so, when short VCC-Pin34 at boot, the module enters in AT command mode, so you can program it, then the short must be opened. With a few googling you can find USB RS232 driver (CP210x Windows XP/2003/Vista(32/64)/7(32/64)/8(32/64) Driver v6.6.1 , file is CP210x_VCP_Windows.zip) that is mandatory to use usb serial. In a Hyperterm sesión, open the COM port that is created, the module BT enters in AT mode, and you can create a Hyperterm sesion with 32800,1,0,None. The AT commands are defined in a tutorial or datasheet of HC05 (see this versión, nor HC06/04) like this (google) HC-0305_serail_module_AT_commamd_set_201104_revised.pdf. The commands AT can be entered in lower case, and after you send it hitting Return. Activate Echo in Hyperterminal sesión to see the commans in screen. Fisrt command to put is AT, an OK is the response. Then put the module in Master mode (slave is the default): AT+ROLE=1, then AT+CMODE=0 to allow the BT module to connect to any BT specified, then AT+BIND=bind MAC, this bind MAC is the one you take of the OBD2 BT, but with a special format. The special format is, i.e. if the MAC is: 00:01:02:03:04:05, then AT+BIND=0001,02,030405. Then if you powers off the BT Serial, and put power again, the module seeks for OBD2 BT and pairs with it without doing nothing more.
My tries to make work a LCD1604 using program that displays OBD2 parameters but using an RS232 cable instead a BT serial module don´t Works using BT serial, but with Kostas code and a little time, sure I finally make it works. if someone wants to make a working group with me, feel free to contact me at farmaestrada2@yahoo.es.

Thanks for the info, i configured the HC-05 and now he it is paired and linked with OBDII successfully.. i upload a small test just to send and received the commands correctly with Arduino IDE..:

#include <SoftwareSerial.h>
#define RxD 7                //Arduino pin connected to Tx of HC-05
#define TxD 8                //Arduino pin connected to Rx of HC-05

SoftwareSerial blueToothSerial(RxD,TxD); 

void setup()
{
 Serial.begin(38400); 
 blueToothSerial.begin(38400);
 pinMode(RxD, INPUT);
 pinMode(TxD, OUTPUT);
   
 } 
 
 void loop() {
  
  if (blueToothSerial.available()) {        //PORTA DO BLUETOOTH RX1 + TX1 (7 e 8)
    char inByte = blueToothSerial.read();
    Serial.write(inByte); 
   }
  

  if (Serial.available()) {   // Ler a porta Serial Arduino
    char inByte = Serial.read();
    blueToothSerial.print(inByte);   
  }
}

I think its ok..

Sorry for not replying for long time...had some laptop problems.

almamater you are doing great as i can see, and thnx aestrada for the very detailed explanation of HC-05 bluetooth module functions.

almamater:
Hello, in your code you have setupBlueToothConnection where you put the AT commands, it is necessary run this code every time that we start the circuit? The last changes\configurations are not saved on the bluetooth module memory if we dont use the 'Reset' command?

P.S.: How you found the address of your Elm327? for example, if i have this: "00:02:03:ac:a1:d3"..

Well i run this function every time, although it doesnt needed except first time, just in case, simply.

:0

My First Test:

Great Job almamater....

hello mr. Kostas Kokoras (Thanks for sharing)
I'm attempting the same thing. then when working , modify it to my usage, MPG. (Per my link) its dedicated BT master, like yours. (very few examples in the net doing this app)
http://www.fixkick.com/ELM327/taurus-sim/hacked.html#MPG
, mine was the Seeed BT shield. the model 3030p and does not have your HC05 chip, its quite different a MLS123A1M, and the documents, are near zero. (it only shows commands, in their wiki)
the chatty echos and returned , strings are much different than HC05 and I would have to characterize this fully to use it. or design very smart string parsing..
On can not just do sends blindly or the whole thing will lockup, randomly,
i gave up and will use yours, then do the mods., i see the changes you made, very good !
thanks again.
PS:> one change, will be detecting lockup, then after 1 or 2 full minutes, do a self reset. or a virtual watch dog timer.

good day to you.

OBD-II:
hello mr. Kostas Kokoras (Thanks for sharing)
I'm attempting the same thing. then when working , modify it to my usage, MPG. (Per my link) its dedicated BT master, like yours. (very few examples in the net doing this app)
ECU Engine Simulator
My board is not the HC05 ( but mine has CSR-BC417143 inside , like yours i think) mine is the Seeed BT shield. the model 3030 (i call it my Winchester) .
I think i can get it to work if , I had your schematic from your hc05 to arduino pins.
then i can work it all out to the seed. Can i have your schematic? or a pin list?

i wish to thank mr. Aestrad for the MAC setup. methods. (not tried this yet, but do have the usb-to TTL232 adapter)
I tried the test ATRZ, above , it don't work i guess you use pins 7 and 8 for rx/tx. the seeed uses 7(rx) and 6 (out of box) , my guess, is he already had the mac setup. first, right? for this test?

I have a ECU emulator in my shop that connects to a ELM BT. (a car free setup for testing...) I do know how to use ELM command sets and the OBD2 comm rules, all i need is getting this seed up..

thanks again.

OK, let me see if i understand what you are asking
the pins of arduino i use for connection with HC-05 is
Arduino pin 7 connected to Tx of HC-05
Arduino pin 8 connected to Rx of HC-05
Arduino pin 9 connected to Reset of HC-05 (reset with LOW)
Arduino pin A2 connected to PI011 of HC-05 (enter AT Mode with HIGH)

then i set the HC-05 to AT Command Mode set it as master and establish a connection with the Bluetooth OBDII ELM adaptor.
then i set the HC-05 back to Communication Mode.
After that u can send AT Commands to ELM.
Check my code Arduino Bluetooth OBDII RPM Shift Light

Hope i helped.

thanks, for that, help !!!
my seed card, that can not "AT" command mode, k. (it talks,but the documentation for that chip is ,not available.) there 3030p card.
seed WLS123a1m chip, is DOA doc wise... so im trashing it.
This card uses what they call transparency mode full time. (which means no "AT" prefixes) in fact, no pin 34 PIO11 is even wired, and has a STS box covering it.
so, am using your set up, exactly , getting it to work then changing it to mpg. and closed loop LED.
btw, I read your code, it's really very good. with error detection . BT error, and ODB error. very nice. You are a good code writer, bless you for that. and lots of comments, Pro level 10.

btw2: i found an 05 , card like yours, with full 5v+TTL233 or Real RS232 to 3.3vTTL protection. check that out.
As you may know , many boards have no RX protection for the HC05
do not allow the Arduino to drive 5v (TX) into the HC05, RX pin (or any RS232C real, like real PC com ports) use a CLAMP.

http://www.ebay.com/itm/HC-05-Bluetooth-Transceiver-Host-Slave-Master-Module-Wireless-Serial-6pin-/321151369653?pt=LH_DefaultDomain_0&hash=item4ac61d01b5

thanks again, and will report my progress and all docs. via, link to my project pages. and here.

PS. i dont think we need a reset pin, at all. I see yours is commented out.

OBD-II:
PS. i dont think we need a reset pin, at all. I see yours is commented out.

Correct, i dont need to reset before and after entering AT command mode, because,if i remember correct, i use for communication mode 38400 baudrate which is the same as AT command Mode, please check datasheet for confirmation.

I added your reset line to my base board. and it works. now. ( im building ,smarter connection code now, (response parsing,etc)
i wonder just how many ways one can enter , AT mode on BT? i read all 10 online, HC05 PDFs, most are new useless...
1: 2 ways listed on all PDF , starting at VDD =0v.
2: then one PDF shows, holding reset true (low) (reset bar is the correct name) , and then raise KEY (PIO(11) Cmd pin to 3v high. bang into AT mode. it works, i have it working.
3: ??? can you enter AT mode , with no reset action? it's says so in this pdf. below.

Page 15 of 15 pages
EGBT-046S/EGBT-045MS Bluetooth Module
e-Gizmo Mechatronix Central , on page 8 of 15, best PDF of them all.
for sure the most poorly documented, feature. as is the un expected baud changes, mentioned in same doc.

I now have Roving Networks cards, the are more expensive but , are feature rich and one has its own USB port for debugging. Its worth every penny, the RN product. IMO
Learning how the BT function calls are the most tasking.... (hc05) :astonished:

Hello Kostas Kokoras,
I have a OBD project similar your project. Do you have any circuit schematic?

Hi
It work also with esp8266?

neodev:
Hi
It work also with esp8266?

I don't think the code works with ESP8266, but this OBD2/ELM327 library does, however. It's installable via the Arduino IDE's Libraries Manager (search ELMduino.h)

Example use-case