Instructables

Modify The HC-05 Bluetooth Module Defaults Using AT Commands

Picture of Modify The HC-05 Bluetooth Module Defaults Using AT Commands
UPDATES
September 4, 2013: Featured on Hackaday.com http://goo.gl/qxvWkd
September 1, 2013: Featured on DangerousPrototypes.com http://goo.gl/K4kH9g

INTRODUCTION

In this guide, I will explain how to use Arduino to change the settings of the ubiquitous HC-05 Bluetooth module using the AT command set. The HC-05 comes with a rich set of AT commands to perform various tasks such as changing the module's default settings including changing the pass code, the device name, and the baud rate. But the process of switching the HC-05 into AT command mode for first time users of the module is not straight forward and the docs takes short cuts. There are a couple of ways to do this. I have picked the one I think is the easiest  I will do my best to illustrate the process in simple to follow steps. You can find the full set of AT commands in the attached datasheet.


BACKGROUND

The HC-05 Bluetooth module and its siblings are by far the most popular and inexpensive Bluetooth modules used for RF communications by microcontroller hackers. It costs less than $10 on ebay and it's easy to implement. I have published two guides based on the HC-05 Bluetooth module.  The first guide explains how to use the HC-05 with the Arduino. The second is an Android app that simplifies controlling Arduino from your smart phone over Bluetooth using the HC-05. In both cases, the default settings for the HC-05 were fine. 

In the process of using the HC-05 for a project, I ran into a situation where I needed to change the defaults for the module. For example, the default baud rate on the HC-05 is 9600. That's slow for high-speed transmission. The HC-05 can go as high as 1382400 baud rate according to the HC-05 reference. Also, the HC-05 has a default device name of HC-05. Having two or more of those devices in the same area can be confusing. You can use an AT command to change the device name. Also, the pin code default is 1234. You may wish to change that for some projects to ensure basic security.

After spending some time searching the web I realized many people are having a hard time changing the default settings for the HC-05. Switching the HC-05 from data transmission mode to configuration mode, to send AT commands to the HC-05, involves a few wiring and software acrobatics.  Add to the mix all the variations of the HC Bluetooth module family and the various vendor settings and you get the picture. 

This guide only covers the HC-05 module with the breakout board. 

WARNING

The HC-05 is a 3.3V system but the breakout board offers current limiting resistors for some protection. While it's not advisable to keep the HC-05 connected to the 5V Arduino Uno pins, for this short exercise I decided to skip the voltage dividers which I use to drop 5V to 3.3V. I advise you to use voltage dividers whenever you connect the HC-05 pins to  5V pins such as the Arduino Uno. If you skip the voltage divider, do so at your own risk.
 
Remove these adsRemove these ads by Signing Up
1-40 of 95Next »

Very useful set of instructions.

I have the same module but found that you could enter AT mode by disconnecting power to the HC-05, pressing the reset button on the module and reapplying power.

When initially connected the red LED would flash quickly. When in AT mode, the LED flashes much more slowly.

brianmoreau made it!1 month ago

If like me you had trouble switching to AT command mode even after soldering a wire direct to pin 34 and connecting this to a digital HIGH output.

The unit requires a HIGH on this pin during power UP so running a sketch to make an output HIGH as per most examples wont always work.

I simply connect PIN 34 to 5V and then command mode or AT mode is established.

I got a Master and Slave and think its crazy the Master comes pre configured as Slave and the AT Command mode pin is not even connected to anything!

The unit I had is below.

Bluetooth-HC-05.jpg
flagtrax1 month ago

Just a note that after wiring and setting up I had to set baud for 9600 and change from "no line ending" to both lf and cr. This is similar to the old at commands on the old dialup modems. I am doing this on a CZ HC-05. Just an FYI for anyone having issues.

UFODesk1 month ago

HC-05 is not replyin... when it send AT it sends back nothin... please help

sühab2 months ago

Dear Hazim, thank you for this very useful application. I have an EN pin instead of KEY pin on my HC05 and it does not seem to be connected to PIO11 (Pin34) (I have checked it with an AVO. Do you think short circuiting the EN pin with Pin34 will solve the problem?

My second question is, how can I pair the HC05 connected to an Arduino uno with an HC06 connected to an ATTiny 85?

Cheers.

Having same problem. Did u get any solution..?
I am using a hc-05 model with en pin in place of key pin. They step given above are not working. It is not getting into the AT command mode as it is blinking rapidly. Please Help... Reply me
bahmed41 month ago

are you sure about connecting 5 volt directly to module, because as far as i know it operates at 3.3 volt???

KemalB12 months ago

hi guys,

I fallow this page and read all messages but my project didn't work. my android phone can communicate with HC-05 via arduino adk mega. Now I want to connect two HC-05 each other via one arduino mega. I arrange my HC-05's roles, one of AT+Role=0 other one AT+ROLE=1 and both of them CMODE=0.

I use hardware tx/rx (for master HC-05), tx1/rx1 (for slave HC-05) and tx/rx(serial monitor) when I push the button(Mled=ON) master HC-05 send '1' message and Slave HC-05 read this and Sled=ON

this is the code:

#include <SoftwareSerial.h>

SoftwareSerial master(10, 11); // RX | TX

byte data =0;

int Mpin = 7; // button for Master

int Spin = 2; // Led for Slave

void setup()

{

Serial.begin(9600);

master.begin(9600); // for Master HC-05

Serial1.begin(9600); // for Slave HC-05

Serial.println("start"); // I want to see if it is start.

pinMode(Mpin,INPUT); // button for Master

pinMode(Spin,OUTPUT); // Led for Slave

}

void loop()

{

if (digitalRead(Mpin)==HIGH) // if I push the button, send message

{

if (master.available())

{

master.write('1');

Serial.println("Master_High");

}

}

else

{

master.write('0');

Serial.println("Master_Low");

}

data=Serial1.read();

if (Serial1.available())

{

if (data=='1')

{

digitalWrite(Spin,HIGH);

Serial.println("SpinHigh");

}

else if (data=='0')

{

digitalWrite(Spin,LOW);

Serial.println("SpinLow");

}

}

}

11.JPG
JayKai KemalB12 months ago

I have not tried communicating the two blue tooth devices by using one Arduino yet. I was able to connect mine by using two separate Arduino Uno's.

First thing I would check is if they are actually connected to each other at all. You will be able to see this by checking the blinking of the LED. When the bluetooth device is active (not in AT command mode), it will blink fast. Once the device is connected, the LED will behave differently. So if you are connecting two blue tooth's to each other, they will blink differently after a small duration of time. If that's not happening:

- Use the AT+BAUD? command to check your baud rate and make sure they are both adjusted to 9600.

- I see you left CMOD as 0, however, you didn't mention if you put the address of the master blue tooth in the slave bluetooth, and the address of the slave blue tooth, in the master blue tooth. This will guarantee that they will only look for each other rather than search for other blue tooth devices.

- Try this button without using a button, just have them constantly sending data.

JayKai JayKai2 months ago

*Try this without using a button.

VivekP2 months ago

How do we successfully connect two Bluetooth modules with each other (till the level of data transmission and reception)?

I have been able to link the two Bluetooth modules and connect them. But having pulled out the config pin (making the devices in the working mode), data transmission is not happening.

Some expert, Please help.

JayKai VivekP2 months ago

1. On both blue tooth devices, put the in AT mode, and type this command in the serial monitor: "AT+BAUD?". This should give you the current baud rate of the devices. The default for mine said it was 38400, but it was actually set to 9600. If it's not set to 9600, do so. Make this change in the code as well "BTSerial.begin(9600)". If you ever need to go back to the AT command, just do "BTSerial.begin(9600).

2. Make sure one of the Bluetooth is a master, and the other is a slave via the AT commands.

3. If you want to tell the Bluetooth device to only find each other. Find the address of both devices (write them down). Make sure that AT+CMOD is set to 0 for both devices. Finally use the AT+BIND command to apply eachother's addresses.

4. To send data from master to slave, use:

BTSerial.write(number or character);

To receive the data on your slave, use:

If (BTSerial.available())

{

Serial.println( BTSerial.read() );

}

Hope this helps and somewhat answers your question.

JayKai JayKai2 months ago

I also made a typo. I say "If you ever need to go back to the AT command, just do "BTSerial.begin(9600)". That number should say 38400.

KemalB1 JayKai2 months ago

you are right about baudrate. normally hc-05 is baudrate 9600 but in this code wrote 38400 then I change to 9600 but program wasn't work. I was try to work along 3 hours as a 9600 baudrate but I didn't. then I didn't touch any code, just copy/past from original code, it was work. now I can use AT Commands with 38400.

kapilk12 months ago

Hi,I am new in working with bluetooth modules.I bought JY MCU v1.06 HC05 module.I need to configure the baud rate,i tried the wiring done by you in video.but there is no response from module.where as i am able to pair it with PC and also my android phone.but not able to get in AT mode.I am using ATmega32..is it mandatory to connect TXD and RXD of module?..also can you pls tell me how AT commands are responded by BT module

JayKai kapilk12 months ago

I was successfully able to send AT commands with the Arduino Uno. For some reason it did not want to work with the Arduino Pro Mini. Assuming you followed the steps exactly, troubleshoot the following:

1. Make sure you're using the SoftwareSerial library and whatever pins you put inside will be your RX and TX.

2. If you've done step 1, try switching your TX and RX pins, it may be that you have TX and RX in the wrong slot.

3. On your serial monitor, check to see that on the bottom, there should be an option that will give "Both NL & CR".

4. Check that your Serial Baud rate matches the baud rate on the Serial Monitor.

5. Do more research on your micro-controller, there may be a possibility other people have had trouble with it as well.

I try this tutorial with btbee pro hc-05,with my arduino leonardo,but when i sent AT, the monitor didn't show nothing,;i m so certain that my wiring is correct.I changed another new btbee pro hc-05,but dindn't work.Help me please.thanks.

http://arduino.cc/en/Reference/softwareSerial

This link explains that the Leonardo has limitations, you may want to check that out and apply the changes.

JayKai2 months ago

I got this working for the Arduino Uno as instructed here. Has anyone got it working successfully for the Arduino Mini Pro? I pretty much get the same issue as everyone else where there is no response after sending the "AT" command. I have the same setup as the Arduino Uno.

WhizzWr9 months ago

One IMPORTANT thing, Newline feed (\n) and Carriage return (\r) are needed on every AT command entered. So if you're using Arduino's serial monitor make sure you select "Both NL and CR" on the dropdown.

JeffW3 WhizzWr2 months ago

Thanks for this!

shanX WhizzWr8 months ago

THANKS!! THAT WAS NEEDED :) :)

davis.nunez.93 months ago

Hello Everyone Eh Created a program to Set all parameters of a Hc-05 Bluetooth Module, arduino By,

Is Very Intuitive and shows the potential of these modules,

download:

https://mega.co.nz/#!IlgEhL7D!49AyfrlgPI2pjhWUyRTM...

Various Tools As has:

Slave Name

The Error Manager

The Finder Device

Configure All in one

etc

Since the program is written in Basic, the Deputy Pograma compiled and Soft for uploading to the Arduino

It is compatible with Arduino Uno, Duemilanove, Nano, MiniPro, Etc

Requirements,

Micro: ATmega328P

Clock: 16Mhz

Baud: 4800

Send the CR at the end of any order.

regards

BluLoader.png
davis.nunez.93 months ago

Hello Everyone Eh Created a program to Set all parameters of a Hc-05 Bluetooth Module, arduino By,

Is Very Intuitive and shows the potential of these modules,

download:

https://mega.co.nz/#!IlgEhL7D!49AyfrlgPI2pjhWUyRTM...

Various Tools As has:

Slave Name

The Error Manager

The Finder Device

Configure All in one

etc

Since the program is written in Basic, the Deputy Pograma compiled and Soft for uploading to the Arduino

It is compatible with Arduino Uno, Duemilanove, Nano, MiniPro, Etc

Requirements,

Micro: ATmega328P

Clock: 16Mhz

Baud: 4800

Send the CR at the end of any order.

regards

BluLoader.png
davis.nunez.93 months ago

Hello Everyone Eh Created a program to Set all parameters of a Hc-05 Bluetooth Module, arduino By,

Is Very Intuitive and shows the potential of these modules,

download:

https://mega.co.nz/#!IlgEhL7D!49AyfrlgPI2pjhWUyRTM...

Various Tools As has:

Slave Name

The Error Manager

The Finder Device

Configure All in one

etc

Since the program is written in Basic, the Deputy Pograma compiled and Soft for uploading to the Arduino

It is compatible with Arduino Uno, Duemilanove, Nano, MiniPro, Etc

Requirements,

Micro: ATmega328P

Clock: 16Mhz

Baud: 4800

Send the CR at the end of any order.

regards

BluLoader.png
davis.nunez.93 months ago

Hello Everyone Eh Created a program to Set all parameters of a Hc-05 Bluetooth Module, arduino By,

Is Very Intuitive and shows the potential of these modules,

download:

https://mega.co.nz/#!IlgEhL7D!49AyfrlgPI2pjhWUyRTM...

Various Tools As has:

Slave Name

The Error Manager

The Finder Device

Configure All in one

etc

Since the program is written in Basic, the Deputy Pograma compiled and Soft for uploading to the Arduino

It is compatible with Arduino Uno, Duemilanove, Nano, MiniPro, Etc

Requirements,

Micro: ATmega328P

Clock: 16Mhz

Baud: 4800

Send the CR at the end of any order.

regards

BluLoader.png

I have tried your method of putting the HC-05 module AT command mode with no luck. However, I have discovered that there are some models with a small button that you can hold down while it is powering up that will put it into AT command mode.

can u tell me what is the procedure for it.,

i have that small button type HC-05

can u tell me what is the procedure for it.,

i have that small button type HC-05

can u tell me what is the procedure for it.,

i have that small button type HC-05

stsoky6 months ago

Hi,

I try everything, but still does not work.

1. problem

I have not blinking led, I do not how, but nothing blinkig when I connect arduino and HC-05. I checked few times conneciton.

2. problem

After some time i get this silly result when I try AT command in Serial Port:
Try to solve this with different baudrate (try on Win8 and Linux Mint)


2.1 ( BTSerial.begin(9600) ) whatever i send to arduino on serial I get same command,

Tx = AT; Rx=AT ..

2.2 (BTSerial.begin(38400) ) if I send command "AT" I get "xxø", for different command different simbols.

2.3 (BTSerial.begin(1382400)) for "AT" got nothing.


3. Also I try case with 3.3V on Key, but unfortunetly that also did not work.

Some idea or solution?


JDEAN73 stsoky4 months ago

Exact same problem! Any luck with solving this stsoky? Or anyone else?

abhi9nav1 JDEAN733 months ago

me also exact same problem, any one rectified it?

abhi9nav4 months ago

how to change password

AT+HELP will list your command set

abhi9nav4 months ago

how to change password

abhi9nav4 months ago

how to change password

abhi9nav4 months ago

how to change password

abhi9nav4 months ago

hi

i am using hc-05 for my project,

how to change its password ;

please tell me in simple way,

1-40 of 95Next »