Getting HC-06 back into AT-command mode?

I've read a lot of forums the past month to solve a problem with my HC-06 BT module.

The module paires with my phone and tablet just fine, but i havn't been able to send any data because the baud is of.
Now I need to get it back into AT-mode to do the changes. How do I accomplish this?
I successfully configured it the first time I used it (before pairing with a device).

The HC-05 has a pin to pull high to escape the data-transmission mode. But the HC-06 has not.
I have looped through all the possible baudrates with a Python script but it refuses to send me an OK.

I have also tried pulling pins high/low as any documentation guides me to do.

Have anyone else had this problem and got it to work?

Thanks in advance!

There is no "getting back" involved, tThe HC-06 is in AT mode by default, and stays that way until a device connects with it.

wiseby:
The module paires with my phone and tablet just fine, but i havn't been able to send any data because the baud is of.

You could always change the baud rate in your Arduino code.

wiseby:
I have also tried pulling pins high/low as any documentation guides me to do.

No, it doesn't. No HC-06 documentation would guide you to pull a pin low. If you are referring to the command

pinMode(0, INPUT_PULLUP);

it is no more than a precaution to prevent Bluetooth powering Arduino, it can usually be ignored, and it has nothing to do with AT commands anyway.

There is only one baud rate to use in order to send AT commands - 9600.

So you are saying that even if i reconfigured the BT device to baud 115200 it still only accepts AT-commands at 9600 bauds?

I have already tried connecting and configure it with baudrate 9600 without success.

I also by accident configured it with a different parity mode than default, could this cause the problem?

wiseby:
So you are saying that even if i reconfigured the BT device to baud 115200 it still only accepts AT-commands at 9600 bauds?

That is correct, thereby allowing you the luxury of not needing to write down the baud rate on a piece of paper you will probably loose.

I have already tried connecting and configure it with baudrate 9600 without success

No comment - other than that 9600 is the correct rate, and your lack of success is due to something else.

I also by accident configured it with a different parity mode than default, could this cause the problem?

I assume you didn't "by accident configured it", you attempted to configure it, and failed. The different parity mode could be a problem, but I'm pretty sure you didn't do any lasting damage.

The only thing I can say is different from the first time I configure it is that I have paired it and the LED is flashing 2 times/sec (first time I fired it up it flashed slower, perhaps 1 blink/sec).

The powerdraw of the module indicates that it's searching for pairable device.

I think this is all nonsense. If you are seeing a slow flash, about 1 flash/ 2sec, it is probably because you are using an HC-05, which explains quite a lot, and you just think you have an HC-06 problem. Similarly, you can measure what power draw you like, but HC-06 is a slave device and doesn't search for anything.

The 2Hz flash applies to both HC-05 and HC-06, and, with HC-05, means no more than "power on, ready to connect", while for HC-06 it also means AT mode.

I don't believe there is any LED signal signifying anything to do with AT commands on the HC-06. This is because it is in AT mode by default.

Similarly, the LED keeps flashing when you pair with the phone, and the only indication of a successful pair is on the phone.

You only see a change in LED when a connection is made.

I brought a new HC-06 module last week and it has the same symptoms as you described in this post. I am just wondering whether you find a way to get back AT command mode? Any help would be very much appreciated

wmudalige:
I brought a new HC-06 module last week and it has the same symptoms as you described in this post.

In that case it might be time to read replies #5 and #1, again, and in that order. The deafening silence from the OP of this thread is probably quite easy to explain.

Hi Nick,
My HC-06 module is very latest and it behaves very differently from its predecessors. For example, in AT command mode (when not connected) it buffers all AT commands I send, instead of processing them and getting back to me with correct replies like "OK". As a result, once I connected (open the respective COM Port from Tera Term PC side) I am immediately getting all those buffered AT commands in PC side Tera Term window.
Next, when I close the COM port (i.e disconnect) the module sends a Message "+DISC:SUCCESS" which means successfully disconnected. But module should not send such message unless I specifically ask such status with respective AT command.

Finally my module flashes the Red LED twice every 2 seconds or so while it is connected. This is very strange as early HC-06 modules have there Red LEDs remains solid on as long as connected. So something is not right this latest HC-06 modules. Any idea what goes wrong here?

wmudalige:
Any idea what goes wrong here?

Apart from the above, the short answer is no, and the something that is not right is that it isn't an HC-06.

As far as I know, and from the manufacturer's datasheet posted 2017, the latest version of HC-06 is v2.2 of 2011/04/06, so I would be interested to see what version you have, and how you identified it. Until then, "very latest" is just loose talk.

What you are describing is an HC-05. You are correct in that HC-06 has solid LED on connection. I have never heard of this being different, and the LED is not programmable, while that on an HC-05 is. Your antics with Teraterm are meaningless, and may not have anything to do with Bluetooth. The fact that they are unique rather confirms this, but I don't actually know anything about configuring HC-0x with a terminal, only Arduino.

I believe you are not the first with this problem, which doesn't help much, but rather suggests this is not pilot error. If your module is on a GW-040 breakout board, you may find further depressing reading here:-

https://forum.arduino.cc/index.php?topic=569839.msg3884383#msg3884383
https://forum.arduino.cc/index.php?topic=569217.msg3881751#msg3881751

I have good reason to believe that it's a HC-06 because it has NO push button and it shows its name as "HC-06" under "Find Bluetooth devices" on PC side. I can't check the FW version as AT commands doesn't work. I have attached a picture of the module.

You indeed have good reason to believe it is an HC-06, but its behaviour suggests it isn't. If you have a logic or multimeter, check the links in the previous. I note the conspicuous absence of any confirmation of "very latest" version so, in the meantime, your picture goes into my gallery of hardware to avoid - guilty until proven innocent..

I rather like to blacklist this hardware rather than proving it innocent. It gives me enough trouble and waste so much of my time. But I still like to hear other victims.

While HC-05 is available on several different breakout boards, about 99% of HC-06s come on the JY-MCU board, and it would be best to stick with one of them. If you have no real need to reconfigure it, the device in your hand will probably be fine. If you really need another, it might be better to get an HC-05, as there is no longer a price advantage with the HC-06.

I've been trying to get my HC-06 module to respond OK to an AT command for hours and hours and I finally managed it.

Some facts about my module

  1. With default factory settings I managed to pair and connect to it and it works fine when using SoftwareSerial at baudrate 38400
  2. My HC-06 module's default SSID is "HC-06" (not Linvor, as I've heard elsewhere)
  3. The module has a fast blinking led when it is powered up and before it connects. I guesstimate about 4 or 5 blinks a second. The blinking stops when it connects, so I figure this fast blink means it is in command mode.
  4. Using SoftwareSerial to send just "AT" to the module during command mode does not work. I've tried all the baudrates.

I hypothesized that the SoftwareSerial was not flushing its write buffer with every call to btSerial.print("AT"). So when it eventually sends, it would be sending "ATATATATATATAT".
I wrote a program to cycle through the following 5 commands, in the hope that some kind of linefeed would flush the buffer and be understood by the HC-06

char* commands[5] = { "AT", "AT\n", "AT\r", "AT\n\r", "AT\r\n" };

I ran the program at different baudrates and found that "AT\n\r" at 9600 worked! It sent the OK back! Actually, it sends "OK" then a linefeed. I don't know whether the linefeed comes from the bluetooth module or is added by the SoftwareSerial library.

So here's a program that works for me, that sends an AT command and receives an OK back...

#include <SoftwareSerial.h>

#define PIN_02_RX       2
#define PIN_03_TX       3

SoftwareSerial btSerial(PIN_02_RX, PIN_03_TX); // RX, TX

long int ms = 0;
char* command = "AT\n\r";

void setup() 
{
 Serial.begin(9600);
 
 //long int baudRate = 1200;
 //long int baudRate = 2400;
 //long int baudRate = 4800;
 long int baudRate = 9600; // NJM - This baudrate worked for my two HC-06 modules
 //long int baudRate = 19200;
 //long int baudRate = 38400;
 //long int baudRate = 57600;
 btSerial.begin(baudRate);
 Serial.print("SoftwareSerial baudrate=");
 Serial.println(baudRate);

 ms = millis()+1000;
}

void loop()
{
 if(btSerial.available()>0)
 {
   Serial.print("response: '");
   while(btSerial.available()>0)
   {
     Serial.write(btSerial.read());
   }
   Serial.println("'");
 }
 else if (millis()>ms)
 {
   ms = millis()+1000;
   Serial.print("sending: '");
   Serial.print(command);
   Serial.print("' when ms=");
   Serial.println(ms);
   btSerial.print(command);
 }
}

I submit that the summary of your facts is that now is good time to abandon the HC-06 and get HC-05, which is more versatile and usually at the same price. There is clearly something weird going on with HC-06, and all you have done is made a bad situation worse. To your points.

  1. The default baud rate for both HC-05 and HC-06 is 9600. If somebody has fiddled with it and you are OK with 38400, that's fine.

  2. The way things are, that is evidence that the default has been changed, but not evidence that it is really an HC-06.

  3. The LED activity is normal for both but does not signify it is in AT for HC-05

  4. AT is a legitimate command for both.

I don't know anything about flushing, and I don't think it is relevant.

9600 baud is the required rate for config an HC-06. Your surprise implies you are using two different baud rates for configuration, which is most likely untrue and strongly suggests you aren't configuring it at the other speed at all. This will go quite some way to explain the absence of OK after your otherwise legitimate AT command

Other than the name, your description seems to be of an HC-06, and the fact the you have succeeded in configuring it at 9600 means it is an HC-06. It may have been fiddled with and it may even be by another party, but that is irrelevant. Indeed, I don't think this fiddle is such a bad idea - just confusing. I think this is a caution worth adding to my childs' guide to HC-0x, so thanks.

What I believe other people have been describing is an HC-05. This to the point where some guy got the state signal on a pin that is the state pin on an HC-05 but not connected on an HC-06.

It appears that there are three types of HC-06 around

  1. The real McCaughey, most likely on a JY-MCU board
  2. Yours, called HC-06 and set to run at 38400, but otherwise apparently kosher. Backboard unknown.
  3. Logically identifiable HC-05s masquerading as HC-06, sometimes using GW-040 backboards

It could be that types 2 and 3 are from the same source.

Hi all, I ran into the same problem with my first HC-06 given by a friend. It worked beautifully sending and receiving data on the project. However, not so lucky when I wanted to get into the AT command mode. I tried everything mentioned here as well as other places, including the Martyn Currey website that someone kept bringing up, I couldn't get that OK to show up in my serial monitor.

I then bought two brand new ones off Amazon. With the same code and wiring, I literally just pulled the old one out and plugged the new one into the breadboard. These identical ones from Amazon worked right out of the sealed bag. I ran the code before connecting to any device, so I thought maybe it was that. I paired the new HC-06 that worked with my phone, sent a few things over with an app, disconnected it, it went right back into the AT command mode by itself!!

I didn't have luck with any of those on the first one at all. Hope this helps someone out there who are frustrated with getting into the AT command mode on a bad/cheap HC-06. It may not be your fault.

cheers,

1 Like

ghettokon:
it went right back into the AT command mode by itself!!

HC-06 is in AT mode by default, stays that way until a Bluetooth connection is made, and reverts to AT mode when the connection is broken.

Running the code before making a connection would have no bearing on the matter. I bet most HC-06s are never configured, they are just run out of the box.

It would appear that you are confirming that there are indeed some dud HC-06s around.

I know I'm a bit late coming to this post but I've had exactly the same problems with my HC-06. I bought it through ebay and could not get it to repond to AT commands in the standard method when not BT paired. It would send through characters to my phone when it was paired.
I've found that when sending AT commands have the Both NL & CR commands set in the Arduino window. If you want to change a value instert a colon ie AT+NAME:Newname
Although sold as an HC-06 my board clearly isnt

I just spent many hours trying to setup a 'pseudo' HC06 and found this thread useful, especially comments from NJM and gardenstreamer - thanks!

I will add my findings in the hopes it helps somebody else. My HC06 unit seems to be a hybrid of an HC05 and an HC06 in terms of AT commands. Its certainly NOT an HC05, as I cannot make it a "master", but I can read its role, and its set to slave.

Here are the commands that I found work - Good Luck!

• Need to send BOTH NL and CR with each AT command (ie. \n\r)
• AT - check connection and responds with OK
• AT+NAME - checks the name, adding ":" allows you to change eg. AT+NAME:New-Name
• AT+UART - checks the baud, adding ":" allows you to change eg. AT+UART:9600,0,0 <BAUD, STOP BIT, PARITY>
(which is the same command an HC-05 uses)
• AT+PSWD - checks PIN, adding ":" allows you to change eg. AT+PSWD:"1234"
(NOTE that you have to use "" to surround the PIN number - this is also the same command an HC-05 uses)
• AT+CMODE - checks connection mode (can change with "=" sign: AT+CMODE=num
0 - connect fixed address
1 - connect any address
2 - slave-Loop

• AT+ROLE - check role, but cannot set it (stuck in 0-Slave)
0 - Slave
1 - Master
2 - Slave-Loop

• AT+ADDR - checks the address of the device (cannot change)
• AT+ORGL - restores factory defaults:
BAUD = 9600,0,0
PIN = 1234
NAME = H-C-2010-06-01 (I'm guessing this will change depending on device used)