HC-06 Bluetooth Module – Getting this sucker into AT Command Mode

hc-06After spending nearly 3 hours scouring the Web trying to find a way to configure my JY-MCU HC-06 Bluetooth module.  There are a lot of great tutorials out there.  Many of them refer to setting the key pin HIGH, or a combination of LOW then HIGH while powering on the module.  However, none of these approaches worked for the unit I have.  Read on to see how it can be done.  Oddly, I found the answer in the DX discussion forums related to this module.  Here’s the thread.  Read on for how I managed to get it working.


The fluff & Warning:

Before we start, I’ll throw this warning out there…   Nearly all samples I’ve found, suggest that the connection (Arduino TX to BT RX) must be 3v3 as I’ve shown here.  Although I now use this approach with BT Bot Control, it did not work for me when trying to set AT Commands.  As such, I decided to gamble on connecting the pin directly to D10 (5V when high) and it worked.  Also note that I’ve run this particular module for months with no 3v3 level shifting, and it has worked without issue.  If you “try and fry” your module and let out the black smoke, you’ve been warned.

 

Update:

Based on some of the user comments, it might be wise to try the following:

  • Use 3v3 level shifting to provide the correct voltage to the BT module.
  • Pull the KEY PIN up as one user suggested to get AT/comand function.


Wiring
:

Arduino to BT Module

GND <> GND

5V to VCC (5V)

D10 to TXD

D11 to RXD

Nano / Uno Wiring for Command Mode

 

The Sketch:

The void Setup() section carries a number of sample AT commands.  Un-comment the ones you need.  You can also find an AT Command reference here (but note it’s for the HC-05, but most should work).  Note:  If you change the baud, be sure to set the new baud for mySerial in the sketch for communicating to the unit.  The Serial baud should remain the same as it is used to display the responses in the Serial window.

Here’s a excerpt from the sketch:

delay(1000);
mySerial.print(“AT”);
delay(1000);
mySerial.print(“AT+VERSION”);
delay(1000);
//mySerial.print(“AT+PIN1234″); // Set pin to 1234
//delay(1000);
mySerial.print(“AT+NAMEJY-MCU-HC06″); // Set the name to JY-MCU-HC06
delay(1000);
mySerial.print(“AT+BAUD8″); // Set baudrate to 115200
//mySerial.print(“AT+BAUD4″); // Set baudrate to 9600
delay(1000);

Demo Sketch:  JY-MCU HC-06 Command Mode – Arduino Sketch

Reference Info  More reference (specific to the HC-05)

9 Responses to “HC-06 Bluetooth Module – Getting this sucker into AT Command Mode”

  1. Michael says:

    Hi, I tried your sketch, but it doesnt work. The wiring is correct, so is the Baudrate (tried it with different ones). The SoftwareSerial example works. The data I am sending through my phone shows up in the Serial Monitor. Then I disconnect my phone (BT Module blinking), and upload the sketch to change the baudrate. Nothing happens. Baudrate isnt changing. I also tried many other sketches like SoftwareSerial Example and manually send the AT commands, but I do not get any response from the HC-06. Not even an “OK” when i ping it with “AT”. Everthing else is working exept the AT settings. Any Ideas? Thanks

    • Dave says:

      I recall having some challenges like this as well. I did this a while ago and don’t recall how I solved it. I recall that the BT module I have could not be set to 115200 but lower value could work.

  2. Gem says:

    It’s weird here too … I also have an HC-06 (MASTER only) v1.05 (same as yours above) … I was able to program mine but only the ONCE … the LED stopped blinking, like it should then went full on and done it’s thing and then finished … but now I can’t write back to it … it just sits there blinking …

    I “did” use it for my GigaPan setup (using PapyWizard on my Android) … it pairs to my Samsung S3 ok and accepts the Password (1234) but it just sits there in a loop trying to connect to my Merlin Mount … so now I cannot control anything, which I could before the flashing … and it worked well … why did I have to play with it … lol? …

    Anyhow I’m stumped …maybe these MASTER Units are program once only? … or the fact I DID NOT level out the Tx pin fried the little thing … or could it be that fact that it was programmed with 57000Baud and now my Merlin Mount cannot communicate at that speed? …

    As a NOTE:
    I have also hard-wired the KEY pin to the smaller piggybacked BT board, as the free solder pad (for KEY connection) is not connected directly to KEY …still nothing …

    I used a similar Arduino (Nano) sketch I got from OpenPilot Telemetary page …
    http://wiki.openpilot.org/display/Doc/Serial+Bluetooth+Telemetry

    I’ve now ordered an HC-05 MASTER/SLAVE 6pin module …

    Gem

  3. sebol says:

    You have to pull up KEY PIN then u get AT/comand function.

  4. tim says:

    Dave, tnx for the solution. AT commands were unavailable directly through arduinos UART port (I was AT-ing arduino, not the JY-MCU HC-06) , KEY PIN up just didn’t change anything. Using SoftwareSerial solved it, as it communicated a AT commands from arduino throuth the D10 and D11 ports to JY-MCU HC-06. There’s some logic to it afterall :)

  5. rafe says:

    Hi guys, I’m new with this stuff and I have the same problem with hc-06, so what do you mean with pull up key pin??
    the hc-06’s key pin has a hole so, do i need to connect this pin with the arduino?

  6. Ibrahim says:

    Hi Rafe,

    “Pull up” means connect to 5V as far as I know. I don’t think the key pin does anything on the HC-06 (on the HC-05 it’s needed to put it into AT Command mode, whereas the HC-06 is always in AT Command mode…supposedly).

    I’m still also trying to get this to work. I can connect to the HC-06 from my phone and multiple computers, but AT Commands don’t work. I’ll let you know if I get a solution.

    Thanks

  7. Ibrahim says:

    Hey Rafe/all,

    This worked for me.

    SoftwareSerial mySerial(10,11); // Pin 10 connected to TX on HC-06

    void setup() {
    mySerial.begin(9600);
    mySerial.print(“AT+NAMEICHI”);
    delay(2000);
    }

    Hope this helps :)

  8. Isak says:

    Hi
    Make sure you did not pair the hc-06 with another device, the light on hc-06 will flicker.
    Use a sketch that will pass your keystrokes from serial monitor through your arduino to the hc-06.
    Change the line end stings to “Both NL and CR”
    Now you should be able to send AT command to hc-06.
    The hc-06 firmware makes the board slave only and when not paired it is in AT command mode.
    Hope this help.

Leave a Reply

Follow

Get every new post delivered to your Inbox

Join other followers: