A Sequential LED TAchometer (OBD2 and HC05 modules)

Will This Code work? Basically i am trying build a sequential led tachometer.

So the rx and tx pins of an hc05 module will be connected to the 2 and 3 pins of arduino. Rest is the leds.
The hc05 module will be set as master and be paired with an ELM327 mini OBD2 thing.
i hope anyone would give any ideas…

EDIT:

A VIDEO ON IT

#include <ELMduino.h>
#include <SoftwareSerial.h>



SoftwareSerial mySerial(2, 3); // RX, TX
#define ELM_PORT mySerial


ELM327 myELM327;


uint32_t rpm = 0;

int ledG1 = 4;
int ledG2 = 5;
int ledG3 = 6;
int ledG4 = 7;
int ledY1 = 8;
int ledY2 = 9;
int ledY3 = 10;
int ledR1 = 11;
int ledR2 = 12;


void setup()
{
  pinMode(ledG1, OUTPUT);
  pinMode(ledG2, OUTPUT);
  pinMode(ledG3, OUTPUT);
  pinMode(ledG4, OUTPUT);
  pinMode(ledY1, OUTPUT);
  pinMode(ledY2, OUTPUT);
  pinMode(ledY3, OUTPUT);
  pinMode(ledR1, OUTPUT);
  pinMode(ledR2, OUTPUT);


  Serial.begin(115200);
  ELM_PORT.begin(115200);

  Serial.println("Attempting to connect to ELM327...");

  if (!myELM327.begin(ELM_PORT))
  {
    Serial.println("Couldn't connect to OBD scanner");
    while (1);
  }

  Serial.println("Connected to ELM327");
}


void loop()
{
  float tempRPM = myELM327.rpm();

  if (myELM327.status == ELM_SUCCESS)
  {
    rpm = (uint32_t)tempRPM;

   if(rpm>900&&rpm<4000);
   {
    if(rpm>900)
     { digitalWrite(ledG1, HIGH); }
    if(rpm>1300)
     { digitalWrite(ledG2, HIGH); }
      if(rpm>1700)
     { digitalWrite(ledG3, HIGH); }
    if(rpm>2100)
     { digitalWrite(ledG4, HIGH); }
      if(rpm>2500)
     { digitalWrite(ledY1, HIGH); }
    if(rpm>2900)
     { digitalWrite(ledY2, HIGH); }
      if(rpm>3300)
     { digitalWrite(ledY3, HIGH); }
    if(rpm>3700)
     { digitalWrite(ledR1, HIGH); }
   }
  }
   else
   { 
      digitalWrite(ledG1, HIGH);
      digitalWrite(ledG2, HIGH);
      digitalWrite(ledG3, HIGH);
      digitalWrite(ledG4, HIGH);
      digitalWrite(ledY1, HIGH);
      digitalWrite(ledY2, HIGH);
      digitalWrite(ledY3, HIGH);
      digitalWrite(ledR1, HIGH);
      digitalWrite(ledR2, HIGH);
      delay(30);
      digitalWrite(ledG1, LOW);
      digitalWrite(ledG2, LOW);
      digitalWrite(ledG3, LOW);
      digitalWrite(ledG4, LOW);
      digitalWrite(ledY1, LOW);
      digitalWrite(ledY2, LOW);
      digitalWrite(ledY3, LOW);
      digitalWrite(ledR1, LOW);
      digitalWrite(ledR2, LOW);
      delay(30);
     }
 
  }
[code]

sketch_jun20a.ino (2.11 KB)

Will This Code work?

What happened when you tried?

Please remember to use code tags when posting code

ELM_PORT.begin(115200) that’s a bit hopeful, for a software serial

TheMemberFormerlyKnownAsAWOL:
What happened when you tried?

Please remember to use code tags when posting code

I didnt get to try it since i waiting for the HC05 module. So What do you think?

AND how to use code tags??

Hi,

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Try here;

Have you googled
ELM327 mini OBD2 arduino

Why not try your code?
Did you write it yourself?
What model Arduino are you using?

Thanks.. Tom... :slight_smile:

bensontom98:
I didnt get to try it since i waiting for the HC05 module. So What do you think?

I think that you should lower your expectations of software serial

TomGeorge:
Hi,

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Try here;
https://forum.arduino.cc/index.php?topic=149453.0

Have you googled
ELM327 mini OBD2 arduino

Why not try your code?
Did you write it yourself?
What model Arduino are you using?

Thanks.. Tom... :slight_smile:

I am Using Arduino Uno. No i only wrote the loop Part. majority is from a person of guy that did a display that displayed obd2 data. i am just second guessing myself. And I have not tried it because i am still waiting for the hc05 module that i ordered. Thanks man, learned about the Code tagging.

TheMemberFormerlyKnownAsAWOL:
I think that you should lower your expectations of software serial

I actually dont really grasp the concept. I am just a beginner who googled and gathered random infos. Yes and i am open to all suggestions and advises. How much should i lower mate?

Hi,
Have you tried ANY code at all on the UNO?
Does the code you have compile in the IDE?

Thanks… Tom… :slight_smile:

yes it does Compile without any errors.
i have used the arduino uno.
sorry i cant draw a circuit diagram now.
The forum you sent me has a lot of codes. 95% not for me. i cant figure out what to use.

It looks good to me. What settings did you use to configure your HC-05? Honestly, it would be easier to use an ESP32.

Also note that some OBD scanners work on 38400 baud instead of 115200.

Power_Broker:
It looks good to me. What settings did you use to configure your HC-05? Honestly, it would be easier to use an ESP32.

Also note that some OBD scanners work on 38400 baud instead of 115200.

I am going to set HC05 as Master and set to the address of the elm327.
yes will change baud rate.
so can i ask you a question?
According to the program, Should i connect Rx & Tx (of HC05) to pins 0&1 OR 2&3??
then would i correctly get the rpm from the obd2 to the variables given?
Pls reply, I am asking these question because i am a little confused?

For HC-05 AT commands, use these (in order):

  • AT
  • AT+UART=115200,0,0
  • AT+CMODE=0
  • AT+ROLE=1
  • AT+RESET
  • AT+INQM=0,5,9
  • AT+INIT
  • AT+INQ
    (discovered the address of the OBD-II scanner is 1D:A5:1F16BB - yours might be different)
  • AT+PAIR=1D,A5,1F16BB,20
  • AT+BIND=1D,A5,1F16BB
  • AT+LINK=1D,A5,1F16BB
  • AT+RESET

As for the wiring, always do RX --> TX and vice versa.

Power_Broker:
For HC-05 AT commands, use these (in order):

As for the wiring, always do RX --> TX and vice versa.

Thanks for that, dont you think 38400 baud rate is enough.

bensontom98:
Thanks for that, dont you think 38400 baud rate is enough.

The module I use communicates at 115200 by default - that's why I used 115200. Some modules, however, use 38400. You'll have to do some experimentation to figure out what baud is the correct one for your module/OBD scanner.

When pairing Hc05 with obd, should i set hc05 as master or slave?
And can anyone help with configuring hc05 to automatically connect with obd? (AT Commands )
I cant get it to pair pls help

Thanks

It was a success you guys.
Only 9600 baud rate seemed to work.

Have Made a video On It.