HC-05 Module not responding. Could someone help me?

Hi everyone,
I have an issue while trying to recive information send from my phone to my bluetooth hc-05 module, I think that every thing is conected properly to the arduino uno board, and I can find no problems on my code, if any of you can spot the problem, it would help me a lot.
It also does not print the recieved information on the console.

This are the conections to the board:

  • RX -> 9
  • TX -> 10
  • LED -> 6

The HC-05 module is powered with 3.3 volts.
And this is the code I use for this project.

#include <SoftwareSerial.h>
SoftwareSerial ModuloBT (9, 10); // (TXD,RXD);
const int Led = 12;
String infoInicio;
int info = 0;
void setup() {
    pinMode(Led, OUTPUT);
    Serial.begin(9600); 
    ModuloBT.begin (9600);
    Serial.println ("Preparing");

    ModuloBT.print("AT");
    delay(1000);
    ModuloBT.print("AT+NAME");
    ModuloBT.print("LED_CONTROL");
    delay (1000);

    ModuloBT.print("AT+BAUD");
    ModuloBT.print("4");
    delay (1000);

    ModuloBT.print("AT+PSWD");
    ModuloBT.print("1234");
    delay (1000);

    Serial.println("End setting up everything");
}
void loop() {
    if (ModuloBT.available()){
      infoInicio = ModuloBT.read();
      info = infoInicio.toInt();
      Serial.println(infoInicio);
      if (info == 1){
        digitalWrite(Led, HIGH);
      }else if (info == 0){
        digitalWrite(Led, LOW);
      }
    }
  }

If there ia someone out there that can help me with this problem I will thank him a lot.

If you mean that Rx on the HC-05 is connected to pin 9 on the Arduino then that is wrong.

SoftwareSerial ModuloBT (9, 10); // (TXD,RXD);

The order of the pins in the SoftwareSerial object constructor os Rx, Tx and not as in your comment

How are you getting in and out of AT mode.

You will need to be in Communication mode for your info commands.

Ok, I have symplified the code and now I can recieve information, but I am suposed to receive imformation as numbers from -250 to 165 and It is only printed on the console numbers between 56 and 45, does someone know where is the problem.
This is the new code:

#include <SoftwareSerial.h>
String Data ="";

SoftwareSerial ModuloBT(10, 9);
void setup() {
  Serial.begin(9600);
  Serial.println("Listo");
  ModuloBT.begin(9600);
}

void loop() {
  if(ModuloBT.available()){
    Data = ModuloBT.read();
    Serial.println(Data);
  }

  if(Serial.available()){
    ModuloBT.write(ModuloBT.read());
  }
}

The conections to the board are:

Blutooth VCC -3.3V
Bluetooth RX - 9
Bluetooth TX - 10
Bluetooth gnd - gnd

        Data = ModuloBT.read();

This line of code will read a single character. If you want to read a whole String you would be better to use

        Data = ModuloBT.readString();

See Serial.readString() - Arduino Reference

If the incoming String has a termination character such as a Carriage Return then you could also use the readStringUntil() function

See Serial.readStringUntil() - Arduino Reference

Thanks every one for your help but now I have another doubt how can I check if the bluetooth is conected. I ask this is because I want to make a blue led blink while the bluetooth is not conected.

how can I check if the bluetooth is conected.

It may be possible to use the state pin of the module to monitor the connected status. Not all modules support the use of this pin and there is a good discussion here

https://forum.arduino.cc/t/hc-05-state-pin/573388

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