[SOLVED] HC-06 Bluetooth module and AT commands

So I have this HC-05 module that I am using...

In AT mode (LED flashing on module), if I send "AT". I get "OK" back. so all good so far!

However none of the other standard AT commands seem to be working!

I tried sending:

AT+PSWD=XXXX
AT+PSWDXXXX
AT+NAME=YYYYY
AT+NAMEYYYYY

If I send them, I get no response and neither has anything changed on the module. :confused:

Anyone experienced similar issue with HC-06 modules?

Thanks.

Try AT+HELP for a list of commands. Also, make sure you have the correct role selected. Some commands only work for role 0, others only work for role 1

mmdk95:
Try AT+HELP for a list of commands.

same outcome… no reply
I only get an “OK” reply when I send only “AT”

Hmm strange indeed.

My other guesses would be that it may be sleeping (although I don't think you'd get a response back for AT either) or that your connection is not great and the data gets corrupted. You are not forgetting your carriage return and line feed right?

mmdk95:
You are not forgetting your carriage return and line feed right?

actually if I add those I do not get any response then even to the "AT" command

So what are you asking about? HC-06 or HC-05?

Nick_Pyner:
So what are you asking about? HC-06 or HC-05?

as the title stipulates... I'm asking about HC-06

For starters, AT+PSWD is not a valid command for HC-06, it is AT+PIN. Since you are getting a response to AT, you might try sending AT+VERSION, to see if anything comes back for that. If it says anything other than LINVOR1.5, it could be suss.

HC-06 uses no cr/lf but relies on timeout, and that can be a problem. I believe it is most reliable to send the commands from an Arduino programme as a one-shot in setup.

Nick_Pyner:
For starters, AT+PSWD is not a valid command for HC-06, it is AT+PIN. Since you are getting a response to AT, you might try sending AT+VERSION, to see if anything comes back for that. If it says anything other than LINVOR1.5, it could be suss.

HC-06 uses no cr/lf but relies on timeout, and that can be a problem. I believe it is most reliable to send the commands from an Arduino programme as a one-shot in setup.

You nailed it!
I followed your advice and did a ‘one-shot’ programme and the HC06 module responded! ++ Karma!
Now I can change my device name and PIN.
Please see below the programme I used. this link helped me identify which commands were valid for the HC06:
http://www.martyncurrey.com/hc-06-hc01-comv2-0/

#include <SoftwareSerial.h>

//HC06 Bluetooth Module Command List

const char COMM_CHK[] = "AT";           //Check if the command terminal work normally
const char VERSION[] = "AT+VERSION";    //Get firmware, bluetooth, HCI and LMP version
const char NAME[] = "AT+NAME";          //Set device name. To set device name add name string (20 char max) at end of this string
const char PIN[] = "AT+PINyyyy";        //Set pin code for pairing. Replace 'yyyy' with desired pin
const char SET_BAUDRATE[] = "AT+BAUDx"; //Replace 'x' with character corresponding to desired speed from list below to set device baudrate:
                                        /*
                                          1 ——— 1200
                                          2 ——— 2400
                                          3 ——— 4800
                                          4 ——— 9600
                                          5 ——— 19200
                                          6 ——— 38400
                                          7 ——— 57600
                                          8 ——— 115200
                                          9 ——— 230400
                                          A ——— 460800
                                          B ——— 921600
                                          C ——— 1382400
                                        */
const char NOPARITY[] = "AT+PN";        //No parity check
const char EVENPARITY[] = "AT+PE";      //Even parity check is set
const char ODDPARITY[] = "AT+PO";       //Odd parity is set
const char LEDON[] = "AT+LED1";         //turns (blue) board LED ON
const char LEDOFF[] = "AT+LED0";        //turns (blue) board LED OFF
const char SLAVEMODE[] = "AT+ROLE=S";   //set module into SLAVE mode
const char MASTERMODE[] = "AT+ROLE=M";  //set module into SLAVE mode

SoftwareSerial mySerial(4, 3); // RX, TX

void send_AT_cmd(char *str) {
  Serial.println(str);
  mySerial.write(str);
  delay(1000);
  if (mySerial.available()) {
    while (mySerial.available())Serial.write(mySerial.read());
  }
  Serial.println("");
}

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Native USB only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  delay(500);

  Serial.println("<<<<HC-06 AT commad setup>>>>!");

  //comm check
  send_AT_cmd(COMM_CHK);

  //rename device module
  char newNAME[30];
  strcpy(newNAME, NAME);
  strcat(newNAME, "WALL-e");
  send_AT_cmd(newNAME);

  //set new device pin
  send_AT_cmd(PIN);

}

void loop() {
  // put your main code here, to run repeatedly:

}

I'm really pleased to hear it worked so well. I thought I was a bit of a voice in the wilderness on this, and didn't know Martyn had the same approach.

This can be simpler, like

void setup() {            // put your setup code here, to run once:
  Serial.begin(9600);      //bluetooth 
  Serial.print("AT+NAMEFosters");        //CHANGE NAME
  delay(1000);
  Serial.print("AT+PIN1234");            //CHANGE PASSWORD
  delay(1000);   
  Serial.print("AT+BAUD8");              //CHANGE SPEED TO 115K
 
void loop(){
}   //one-shot - nothing here

with HC-06 on hardware serial, and no feedback. It just takes a bit of faith...

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