Go Down

Topic: Getting HC-06 back into AT-command mode? (Read 950 times) previous topic - next topic

wiseby

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!

Nick_Pyner

#1
Feb 22, 2018, 01:05 am Last Edit: Feb 22, 2018, 05:35 am by Nick_Pyner
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.
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.
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
Code: [Select]
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.

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?

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?

Nick_Pyner

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.
Quote
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.
Quote
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.

wiseby

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.


Nick_Pyner

#5
Feb 23, 2018, 08:22 am Last Edit: Oct 14, 2018, 04:56 pm by Nick_Pyner
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.

wmudalige

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

Nick_Pyner

#7
Oct 14, 2018, 09:48 am Last Edit: Oct 14, 2018, 09:48 am by Nick_Pyner
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.

wmudalige

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? 

Nick_Pyner

#9
Oct 14, 2018, 05:04 pm Last Edit: Oct 15, 2018, 02:23 am by Nick_Pyner
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
 


wmudalige

#10
Oct 15, 2018, 03:58 am Last Edit: Oct 15, 2018, 03:59 am by wmudalige
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.

Nick_Pyner

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..

wmudalige

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.

Nick_Pyner

#13
Oct 15, 2018, 09:34 am Last Edit: Oct 15, 2018, 09:34 am by Nick_Pyner
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.

NJM

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<etc>".
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...

Code: [Select]

#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);
 }
}

Go Up