HC05 Bluetooth Module Not Working with Arduino Uno

My HC05 bluetooth module is not working with Arduino Uno. I am using a L293D IC to control 2 DC Motors.
The LED in the module blinks fine and connects to mobile too but it doesn't receive or transmit any signal. When I send a signal from the serial monitor, the motors move. Here is the schematics for the module -

5V - Arduino's 3.3V
GND - Arduino's GND
TX - Arduino's Digital Pin 2
RX - Arduino's Digital Pin 3

Here is the code -

#include <SoftwareSerial.h>

#define M1A 7
#define M1B 9

#define M2A 4
#define M2B 10

SoftwareSerial BT(3,2); //RX | TX

void setup() {
// put your setup code here, to run once
BT.begin(9600);
Serial.begin(9600);
pinMode(M1A,OUTPUT);
pinMode(M1B,OUTPUT);
pinMode(M2A,OUTPUT);
pinMode(M2B,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()){
char input = Serial.read();
if(input == '1'){
Serial.println("Moving Car Forward...");
digitalWrite(M1A,HIGH);
digitalWrite(M1B, LOW);
digitalWrite(M2A,HIGH);
digitalWrite(M2B,LOW);
}
else if(input == '2'){
Serial.println("Moving Car Backward...");
digitalWrite(M1A, LOW);
digitalWrite(M1B, HIGH);
digitalWrite(M2A,LOW);
digitalWrite(M2B,HIGH);
}
else if(input == '3'){
Serial.println("Moving Car Leftward...");
digitalWrite(M1A,LOW);
digitalWrite(M1B,LOW);
digitalWrite(M2A,HIGH);
digitalWrite(M2B,LOW);
}
else if(input == '4'){
Serial.println("Moving Car Rightward...");
digitalWrite(M1A,HIGH);
digitalWrite(M1B,LOW);
digitalWrite(M2A,LOW);
digitalWrite(M2B,LOW);
}
else if(input == '0'){
Serial.println("Stopping Car...");
digitalWrite(M1A,LOW);
digitalWrite(M1B,LOW);
digitalWrite(M2A,LOW);
digitalWrite(M2B,LOW);
}
}
if(BT.available()){
char input2 = BT.read();
if(input2 == '1'){
Serial.println("Moving Car Forward...");
digitalWrite(M1A,HIGH);
digitalWrite(M1B, LOW);
digitalWrite(M2A,HIGH);
digitalWrite(M2B,LOW);
}
else if(input2 == '2'){
Serial.println("Moving Car Backward...");
digitalWrite(M1A, LOW);
digitalWrite(M1B, HIGH);
digitalWrite(M2A,LOW);
digitalWrite(M2B,HIGH);
}
else if(input2 == '3'){
Serial.println("Moving Car Leftward...");
digitalWrite(M1A,HIGH);
digitalWrite(M1B,LOW);
digitalWrite(M2A,LOW);
digitalWrite(M2B,LOW);
}
else if(input2 == '4'){
Serial.println("Moving Car Rightward...");
digitalWrite(M1A,HIGH);
digitalWrite(M1B,LOW);
digitalWrite(M2A,LOW);
digitalWrite(M2B,LOW);
}
else if(input2 == '0'){
Serial.println("Stopping Car...");
digitalWrite(M1A,LOW);
digitalWrite(M1B,LOW);
digitalWrite(M2A,LOW);
digitalWrite(M2B,LOW);
}
}
}

It will be great if you please figure out the mistake fast because I have to show this in an exhibition in a week.

5V - Arduino's 3.3V
GND - Arduino's GND
TX - Arduino's Digital Pin 2
RX - Arduino's Digital Pin 3

SoftwareSerial BT(3,2); //RX | TX

It appears that you have RX to RX and TX to TX. That will not work.
Is your BT module 5V tolerant? If not you will need a voltage divider to keep the Uno TX signal under 3.3 volts to the BT module RX or you risk damaging the BT module.

Please read the "how to use the forum - please read" stickies to see how to format and post code.

groundFungus:
Is your BT module 5V tolerant?

I don't know. How do I check on that?

Check the datasheet for the BT module you have.

HarshitSomani:
I don't know. How do I check on that?

I bet you don't have a datasheet for your bluetooth. Most Bluetooth modules are on a breakout board, nearly all of which are clearly marked 3.6 - 6v on the back and are thus "5v tolerant".

Note though, that the comms pins are 3.3v, also marked. This means it is good practice to use a 1k/2k voltage divider on the Rx pin to take care of the 5v signal from Arduino. There is no need to do anything about the 3.3v signal from bluetooth Tx. Omitting the divider is not usually fatal.

Note the wiring Rx>Tx and Tx>Rx.

I running several HC05 BT converters and this is what I have learned.

On the back of mine, they say:
State
Rx
Tx
Gnd
+5V
EN

They come from China and have NO manual or data sheet.

With the units I am using, you have to source the power at 5 volts. 3.3 volts will not work. The Uno 5 volt power is fine.

The serial signal going to the HC05 must be 3.3 volt. I am using a voltage divider consisting of a 3.3k Resistor and a 2.5k resistor. When I tried to get away without using a voltage divider I burnt up my RS232 to ttl converter.

The Pin marked Rx is the signal "in" pin. The pin labeled Tx is the "out" pin. Sounds stupid to have to say that but that is not always the case. That is true with Uart 1 on a Mega. Uarts 2 and 3 are OK.

The HC05 baud rate by default is 9600 using 8 bit, 1 stop bit and No parity.

The password is "1234". For binding

In my case, I am using a Mega 2560 and I am using a level shifter on the HC05's Tx pin. I am using a 74HCT125 chip powered with 5 volts from the Mega.

When working with the Blue tooth converters, I first get them talking back and forth between 2 serial ports on my computer. Once I have that working, I start working with the Arduino. Almost any simple modem program will do. I use either X-Ctu (free) or Telcom (Also free).

Have fun

In my BT Module, there's a sign beside the RX and TX pin saying "LEVEL 3.3V". I can't understand the meaning of that. The photo is attached.

images.jpg

I have the same module. The power (Vcc) is 5V, but the signals (RX, TX, DTR) are 3.3V level. So the level converting voltage divider that KenK mentions is required on the BT module RX to Arduino TX line.

The serial signal going to the HC05 must be 3.3 volt. I am using a voltage divider consisting of a 3.3k Resistor and a 2.5k resistor.

The resistor values are not critical, but the ratio should be close to the same.

HarshitSomani:

That is the same module I am using. You have to incorporate the resistors and level shifter I spoke of above.

There is quite a bit of documentation on the devise on-line to tell you how to configure the devise. As is comes to you, it is in the slave mode, runs at 9600 baud and uses 8 data bits, one stop bit and no parity.

Once you get them running, they work very well. I am using 3 of them

Good luck.