My HC-05 Bluetooth module isn't working?

Hi
I have a little problem here.
I have bought HC 05 bluetooth module from Here.
I have everything connected correctly: RX to TX on board
TX to RX on board
5V+ to 5V and GND to GND
I'm using arduino MEGA 2560 board and this code:

void setup() {
Serial.begin(9600);
 pinMode(8, OUTPUT); // put your setup code here, to run once:
 }
 
void loop() {
  // put your main code here, to run repeatedly:
 if(Serial.available()>0)
   {     
      char data= Serial.read(); // reading the data received from the bluetooth module
      switch(data)
      {
        case 'a': digitalWrite(8, HIGH);break; // when a is pressed on the app on your smart phone
        case 'd': digitalWrite(8, LOW);break; // when d is pressed on the app on your smart phone
        default : break;
      }
      Serial.println(data);
   }
   delay(50);
}

I was following steps on this tutorial:https://create.arduino.cc/projecthub/SURYATEJA/bluetooth-control-leds-27edbd

A problem is that:

I can't control LED by Smartphone but when I use Serial Monitor I can normally control the LED without problems
Please help I have tried everything and nothing works

I can't control LED by Smartphone but when I use Serial Monitor I can normally control the LED without problems

If the program works over USB from the serial monitor, without the HC05 connected, but not from the phone when it is connected there are a few things to check. Working over usb serial tells you the code is correct.

Check/change the wires from rx>tx and tx>rx. The cheap pin end connector wires can be defective.

Is the phone paired with the module in the Bluetooth Settings of the phone?

What app are you using on the phone to connect to the module. Can you connect the app to the module?

I recommend Kai Morich Serial Bluetooth Terminal

Perhaps the baud rate on the module has been changed. Did you change it? Is the module new from a vendor. Has it been used before by someone else?

You can query the baud rate with AT mode commands. See Martyn Curry's tutorial on the HC05 and AT mode.
http://www.martyncurrey.com/hc-05-with-firmware-2-0-20100601/#HC-05

On the Mega, you can use one of the additional hardware serial ports for the HC05 connection, but using Serial is not the main issue here. Using an alternative port will make it easier to download code and to use the monitor for input as well as the phone through the HC05.

About the only question Cattledog hasn't asked is is your phone an iPhone. If yes, change to Android, or change to BLE, which will work with IOS.

cattledog:

Quote from: cattledog
You can query the baud rate with AT mode commands. See Martyn Curry's tutorial on the HC05 and AT mode.
HC-05 with firmware 2.0-20100601 – Martyn Currey

If the AT command doesn't respond, what does that mean?

It probably means that you have failed to get it into AT mode, or the command is illegitimate, or the HC05 is a fake. This last need not necessarily be a problem. Some fake HC-05 are fine but have limited AT commands.

It probably means that you have failed to get it into AT mode, or the command is illegitimate, or the HC05 is a fake. This last need not necessarily be a problem. Some fake HC-05 are fine but have limited AT commands.

I've tested The AT command that way , there was no problems

  1. Connect EN,5V of Bluetooth module pin together at arduino 5v pin and ground pin to arduino ground pin.

  2. Upload empty sketch.

  3. connect RX and TX pin from Bluetooth module to arduino RX and Tx pin.

  4. Remove arduino usb cable from laptop and you will notice one push button at Bluetooth module.

  5. Press that Bluetooth module and don't let go, at that same time connect usb cable to laptop. Let go the push button and you will notice led at Bluetooth module will blink slowly which mean at AT-COMMAND.

  6. Open IDE and click Serial Monitor. Change from no-line ending to Both NL & CR.

  7. Set Baud Rate to 38400 baud.

  8. Enter AT command.

But when I use that way:

http://www.martyncurrey.com/hc-05-with-firmware-2-0-20100601/#HC-05
after I see "Enter AT commands:" in serial monitor I type AT, send it and nothing happens.

So this

lania-12:
2. Upload empty sketch.

  1. connect RX and TX pin from Bluetooth module to arduino RX and Tx pin.

  2. Remove arduino usb cable from laptop and you will notice one push button at Bluetooth module.

  3. Press that Bluetooth module and don't let go, at that same time connect usb cable to laptop. Let go the push button and you will notice led at Bluetooth module will blink slowly which mean at AT-COMMAND.

works OK, and this

lania-12:
HC-05 with firmware 2.0-20100601 – Martyn Currey
after I see "Enter AT commands:" in serial monitor I type AT, send it and nothing happens.

doesn't. Is that correct?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.