HC-05 Working solution

After many trials and failures I have my HC-05 working on arduino.
I am using a MEGA board so serial2 is used but SoftwareSerial can also be used.
VCC-5 >> VCC
GND >> GND
TX >> RX
RX >> TX

char c = "";

void setup() {
  Serial.begin(9600);
  Serial.println("Enter AT command.");
  Serial2.begin(9600); // What ever you like

}
void loop() {
  if (Serial2.available()) {
    c = Serial2.read();
    Serial.print(c);
  }

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

In your serial monitor set speed to 9600 baud and both NL and CR.
Be sure your HC-05 is in AT mode (led flashing every few seconds)
Seems like every BT module is different during AT but this one worked for me

Not that different, and there is nothing to suggest it really is working for you - and quite a lot to suggest it isn't. For starters, if you really want to work in AT mode, Bluetooth needs to run at 38400 baud, and there is nothing "//what ever you like" about it. What you are doing rather suggests you are using an HC-06.

Nick, I stand corrected. I tried a different module and had to adjust Serial2.begin(38400); The new one I am using has 6 pins and a button. When first attached led was flashing fast. To put it into AT mode, I removed power, held the button down and reapplied VCC. At that point I saw a SLOW flash of LED (AT mode). Question.. AT+HELP on module #1 gave me a list of all AT commands. AT+HELP on module #2 returned ERROR:(0). A few other AT commands ie. AT+BAUD also return ERROR:(0).. AT+UART returns: 9600,0,0. thoughts?

Adequate evidence of it being an HC-05.....
I can only assume that different results are because modules #1, #2 are different versions. There are two levels of programmability and the commands returning an error may require 3.3v on pin34. The Martyn Currey website might have something on this.
I assume the 9600 response is in fact kosher as that is the setting for comms mode, and you haven't altered it.

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