Introduction: Modify the HC-05 Bluetooth Module Defaults Using AT Commands

Picture of Modify the HC-05 Bluetooth Module Defaults Using AT Commands
September 4, 2013: Featured on
September 1, 2013: Featured on


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.


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. 


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.

Step 1: Components & Wiring

Picture of Components & Wiring
I have tested this guide with the following:

  • HC-05 GND --- Arduino GND Pin
  • HC-05 VCC (5V) --- Arduino 5V
  • HC-05 TX --- Arduino Pin 10 (soft RX)
  • HC-05 RX --- Arduino Pin11 (soft TX)
  • HC-05 Key (PIN 34) --- Arduino Pin 9

Step 2: The Arduino Code for HC-05 Command Mode

Picture of The Arduino Code for HC-05 Command Mode

This Arduino program (HC_05.ino) does two things. It takes the AT commands you enter from the Arduino IDE Serial Monitor and sends those commands to the HC-05. The program then reads the output of the HC-05 and displays it on the Arduino IDE Serial Monitor. You can also use a terminal emulator such as Tera Term instead of the Arduino Serial Monitor. 

The Arduino communicates with the HC-05 using the SoftwareSerial ports while the Arduino communicates with the user via the Serial Monitor.


AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (


#include <SoftwareSerial.h>

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

void setup()
  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more

void loop()

  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())

Step 3: Steps to Switch the HC-05 Into Command Mode

Picture of Steps to Switch the HC-05 Into Command Mode
For the HC-05 module to switch to AT command mode, the HC-05 pin 34 (often referred to as the Key pin) needs to pulled HIGH but in a certain order of events explained below. When the HC-05 enters the AT command mode, it will communicate at 38400 baud rate. Follow these steps in the stated order to switch to the HC-05 to AT command mode. 

  1. Wire the HC-05 and Arduino Uno per instructions.
  2. BEFORE YOU CONNECT THE ARDUINO TO THE USB remove the VCC (power) red wire from the HC-05 so it's not getting any power from the Arduino. All other wires are still connected.
  3. Now connect the Arduino Uno to the USB cable extended from your PC.
  4. Make sure the HC-05 module is NOT PAIRED with any other Bluetooth device.
  5. Re-connect the Arduino Uno 5V wire to the HC-05's VCC (5V power) pin.
  6. The HC-05 LED will blink on and off at about 2 second intervals. Now the HC-05 is in AT command mode ready to accept commands to change configuration and settings.
  7. To test if everything is wired correctly,  open the Serial Monitor from the Arduino IDE and type "AT" and click SEND. You should see an "OK"
  8. If you don't see an "OK" check your wiring.

Step 4: Example HC-05 AT Commands

You can send  AT Commands to the HC-05 from the Arduino IDE Serial Monitor while the Arduino is running the attached Arduino program.

I have listed a few popular AT commands that will change the HC-05 device name, pass code, and speed. You will find a full set of AT commands from the attached HC-05 reference PDF file.

(remove double quotes from AT command)
  • To return HC-05 to mfg. default settings: "AT+ORGL"
  • To get version of your HC-05 enter: "AT+VERSION?"
  • To change device name from the default HC-05 to let's say MYBLUE enter: "AT+NAME=MYBLUE"
  • To change default security code from 1234 to 2987 enter: "AT+PSWD=2987"
  • To change HC-05 baud rate from default 9600 to 115200, 1 stop bit, 0 parity enter: "AT+UART=115200,1,0"


jugal patel (author)2017-11-30


I want to programming of HC05 for home automation system.

My project is DOMESTIC APPLIENCES CONTROLLING WITH USE OF BLUETOOTH. so i want to know everything about HC05 programming and its work in master or slave.. i also know it.

i hope u understand everything..

so please send me your reply as fast as you can..


coopertn (author)2017-11-02

How do you take the module out of ATCommand Mode without unplugging the whole Arduino? Thanks for making tutorial... It helped me a lot.

FlyingDrMike (author)2016-12-22

One more pitfall - my board had an EN pin in place of KEY. This is different (- and means you can disable the board to save current when not in use). Instead there a button. Pressing this pulls the KEY input to the internal 3v3 line. I found that it could be released after a few seconds and I could rename and change baud rate. Mike

elghazouly (author)FlyingDrMike2017-02-23

Can you explain more, because i have the same module (EN pin instead of KEY) but no response when i send AT commands

FlyingDrMike (author)elghazouly2017-02-24

As with the KEY input the button on this board has to be pressed during power on. I believe that for some AT commands the button must be kept pressed. However for the ones like changing name and changing baud rate is seems that holding it for a few seconds after power on is enough. Also the LED flashes slowly when you are successfully in AT mode. Please ask if this does not get you working. Mike

TEDC32 (author)FlyingDrMike2017-06-30

Hi Dr Mike:

My bluetooth module has EN pin justlike yours, but my board does not have a button(as the pic below). So what should I do to enter AT mode? Thank you.

FlyingDrMike (author)TEDC322017-09-01

Sorry for slow reply. I just realised that you might have an equivalent to the HC-06 module that does not need any action to put it into AT mode, except that it must not be paired at the time. However these will operate at whatever baud setting has been set for the normal coms. This will be 9600 probably when new but could be 38400 or any other of the standard rates. Also worth just powering up to see what name it broadcasts. See my recent instructable at Mike

FlyingDrMike (author)TEDC322017-07-01

The bluetooth daughter board on your unit looks different to mine. Hence it may not be a HC-05 unit - but may be a compatible with different operating instructions. My first port of call would be the supplier. If this failed I would try to identify the board or even the bluetooth chip and see if I could get a spec sheet. In the latter case you may need to trace the EN connector to the chip. Sorry not to be of more help. Mike

rovercoder made it! (author)FlyingDrMike2017-02-27

Got this to work with my TTL-USB converter

>>>>> WIRING <<<<<
TTL ~~~ HC05
5V <=> VCC
3.3V <=> EN

>>>>> INSTR <<<<<
1. Attach wires
2. Plug in USB-TTL whilst holding the button on the HC05 (4 sec)
3. Open up Serial Monitor with baud 38400 (mine was advertised as 9600) and "Both NL & CR".

MayankG10 (author)rovercoder2017-03-29

this is correct

FlyingDrMike (author)rovercoder2017-02-28

Note: There is no need to connect the EN pin as there is an internal pullup to 3v3.

AT mode uses 38400 baud regardless of the operating mode. The operating mode can be set a wide range of speeds. Most will be supplied set to 9600.

The RX input should be ranged to 3v3. I used 3k3 and 6k8 resistors to drop. Search on "Make-Bluetooth-HC-05-Module-5v-Compatable".

DanielS978 (author)FlyingDrMike2017-03-04

I have the same module with EN instead of key. Is there a similar way to force data mode instead of AT mode?

No matter how I connect it (even tried only VCC to 5v and GND to GND) the module seems to enter AT mode. Also when i leave the little button completely alone.

Gabriel AntonioV (author)2017-06-20

Tks a lot for your help and your tutorials, are amazing.

I've only change the setup line:

BTSerial.begin(9600); // MY HC-05 default speed in AT command mode

It seems that was my default HC05 baud rate. After that, all AT commands were recognized.

Good night,

illumation_ made it! (author)2017-04-11

I made/done it without an Arduino but with a programmer, so much easier! Because in the Arduino sketch file PIN 9 will be set to HIGH (this is something like +5V when using 5V) so I connect the KEY pin (with a special made iron clip) of the HC-05 to the +5V pin and insert the programmer in the computer, et viola!

You must follow the example of this article to set the Arduino IDE Serial Monitor to the right settings. Best way is to close the Serial Monitor, re-insert the USB programmer and reopen the Serial Monitor again with the right settings.

I changed the name of the HC-05 to easy identify the right module. When done, remove the programmer and remove the clip.

One question, any idea why the module is not detected by Windows anyway?

Thanks for the excellent guide!

DavidB552 (author)2017-04-04

so once I follow all these steps I now just have two arduinos hooked up to master and slave Hc-05s

then when I power both they should auto hook up and one will serial write to the other ?

WillieM28 (author)2017-01-23

this is what i get in serial monitor on an UNO

cant seem t get any AT response from any app or program. also tried ftdi unit.

it connect via BT but does accept any commands from terminal.. tried a few different sketches and techniques..


Daantje70 (author)WillieM282017-02-07

I had the same problem. You have to set 'Newline' to 'Both NL & CR', if that doesn't solves your problem try to set '38400 baud' to '9600 baud' (That worked for me)...

EbraheemF (author)Daantje702017-02-16

I made all thatand still not working

EbraheemF (author)WillieM282017-02-16

I have the same problem .. What didi you do so that it works ?

rdlockrey (author)2017-01-09

thank you! worked for me so far Im getting responses atleast, havent tried an actual bluetooth connection yet but thanks for your article.

just a note... I have the HC-05 with the EN Key & the method DrMike suggested worked for mine module

FlyingDrMike (author)2016-12-22

Didn't work at first. I then realised (after using a ftdi cable and Realterm) that I needed to have 'Both NL & CR' selected in the serial monitor for sending the serial data. Hope this helps others avoid this pitfall. Mike

diy_bloke (author)2016-12-13

I guess it is different for every module. My HC-05 was on 9600 in both modes.

My sequence was fairly simple. I used an ftdi module

Connect the necessary pins:


plug ftdi module in usb,

open serial monitor, set to 9600 baud

Press the little 'state' button on the module some 4-5 sec

enter AT in the serial monitor. if it comes back with 'OK' you are good to go

mcapurso made it! (author)2016-12-09

It works also with Arduino Nano. It is important to remember that HC-05 modules tagged ZS-040 work with power between 3.6 and 6 V and RX and TX at 5V. When I tried to drive RX at 3.3 V , I had no response. Finally, RX and TX work at 9600 b/s , and at 38400 in AT mode.

Raw12345678 (author)2016-01-31

I connected hc05 module with arduino uno board with connections as-
HC-05 GND --- Arduino GND Pin
HC-05 VCC (5V) --- Arduino 5V
HC-05 TX --- Arduino Pin 10 (soft RX)
HC-05 RX --- Arduino Pin11 (soft TX)
HC-05 Key (PIN 34) --- Arduino Pin 9
After connecting i m getting rapid blinking of led on hc 05 module but unable to connect with any app on ios neither AT command is getting any response on serial port.
Suggest how to connect hc05 with arduino uno and how to use it on ios mobile app

If it has a small button above the EN/KEY/WAKE UP pin, disconnected Vcc, press and hold that button, connect Vcc and it the LED in the module should blink slowly and allow you to enter AT codes.


GreenMoon (author)carloszoom30002016-08-22

This worked for me too. Also, after getting the LED to blink slowly, press the Reset button on the Arduino. Exact steps that seem to always work:

1. Unplug power from HC-05

2. Upload sketch from this Instructable

3. Hold in HC-05 button

4. Reconnect power to HC-05 (wait until LED blinks slowly)

5. Press Arduino reset button

6. Open Serial Monitor

7. Make sure "Both NL & CR" is selected

8. Type AT commands

We had 3 people in a workshop this evening and when everyone followed this procedure it always worked.

Sapankotak (author)GreenMoon2016-12-02


RohanP27 (author)GreenMoon2016-09-12

i followed your procedure but still i get weird output in for of some other language. but when i put the baud rate to 9600 it shows english and then an error message comes up......plz help

GreenMoon (author)RohanP272016-09-12

I had steps 3 & 4 reversed above -- my apologies. They should be:

3. Reconnect power to HC-05

4. Hold in HC-05 button (wait until
LED blinks slowly)

(9600 baud is correct for the serial monitor)

YukselV (author)carloszoom30002016-03-11

that worked perfectly


YukselV (author)Raw123456782016-03-11

pin 34 cannot be connected directly to Arduino PIN 9, use level converter from 5 volts to 3.3 and vice versa or simply use two 1 K ohm resistors between PIN 9 and VSS and connect pin 34 inbetween

Sapankotak (author)2016-12-02

i have done whole connection and program but still not work serial comm. is not done and led of HC 05 is blink continuously.

MarcusL33 (author)2016-11-30

Just what I was looking for, thank you very much.

JoelB88 (author)2016-10-28

It work

Thank you

kb3cxe (author)2016-10-19

Great tutorial,

Thank for the help,


RutvikM (author)2016-10-14

I can transmit data from PIC controller ->hc-05-> mobile terminal but can't receive back data into PIC controller from mobile terminal.

Can any body help me with solution?

JakeH60 (author)2016-09-11

hey dudes

I've got a cz hc 05 bluetooth module

when i connected this to my arduino mega 2560, it worked fine, with the LED's blinking indicating it was working. I even managed to pair it with my android device. However, soon after i paired it, the module stopped blinking and i cant seem to get it working again..

Does anybody know what the problem is? Or did is the module broken?

raddevus made it! (author)2016-09-10

I know have 5 hc-05s here at home and trying to connect to them each with the same generic name was terrible. I have been trying to get my hc-05s into command mode and successfully connect to them for weeks -- as an off and on project. Finally, with this instructable and an Arduino Nano I got it all to work because of connecting to D10, D11 instead of the Tx and Rx on the Nano. Thanks for writing this great instructable. Also, since my hc-05s all have the button, I can just hold that while powering them on and the device enters into AT mode. No need for the additional wire on pin 9 or the associated code.

jakubK27 (author)2016-08-01

Hi, instead of your pinout I have:

state, rxd, txd, gnd, vcc, en

Is the "en" pin seme as "key" pin? The "state" and "en" pins haven't got pins to connect to breadboard (there are only 4 pins, but other 2 are marked amd seem like they're ready to be soldered to pins, they have holes).
Sorry for my english and thanks for answer!

SaiG16 (author)jakubK272016-08-17

u got output using that bluetooth module ?

jakubK27 (author)SaiG162016-08-28

when connected tx-rx,rx-tx,gnd-gnd,vcc-5v, starts blinking. when trying to connect, ligts without blinking. But phone says something like couldn´t connect and bluetooth starts blinking again.

Gljames24 (author)2016-08-23

Hi, I'm working with the arduino Due and SoftwareSerial doesn't work. I'm not that great with the coding, so could you help me out?

kjohari21 (author)2016-04-01

Instead of getting an OK after typing AT in the serial monitor, I am getting the following output. Please someone tell me the reason

nithinvenny (author)kjohari212016-07-30

that my be due to mismatch of buad rate

TahsinA2 (author)kjohari212016-05-07

//Correction :


SoftwareSerial BTSerial(10,11);

String HC05_Responce="";

void setup(){




Serial.println("Enter AT command:");



void loop(){






PatelA1 (author)kjohari212016-04-10


Instead of no line ending drop the menu down and select "Both NL & CR"

and try again.

cheers ;)

Dagui (author)kjohari212016-04-05

HiKjohari21, il think you have to select "both line feed and carriage return" in the serial monitor and it will work.


Riftliger (author)2016-07-02

If there is anyone still struggling out there, I made another instructable detailing how to use this modules in master, and slave mode. It is meant to explain how to get each model into AT mode, and then, to get them working with code.

dimitrakis1992 (author)2016-06-17

Hello to everyone.I have make a bleutooth robot which i can control it via android(tablet) and i have a problem with the code.I want from the robot to stop when connection lost or bluetooth disconnected.Now when the connection lost the robot go ahead and falls on the objects.How to add this line on the code?Can you help me please?The STATE pin of HC-05 when is HIGH is connected and when is LOW is disconnected.I put this on my code but it doesn't stop.Thank you for your time

The bluetooth that i use is HC-05

My code:

#include <Servo.h>

Servo SERVO_1; // Initialize Servo1

// Motor Control Variables
int PWM1 = 9;
int ENABLE1 = 8;
int PWM2 = 5;
int ENABLE2 = 7;
int PWM3 = 3;
int ENABLE3 = 4;
int PWM4 = 6;
int ENABLE4 = 12;
int STATE=2;

void setup() {
pinMode(ENABLE1, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE2, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE3, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE4, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(STATE, INPUT);

void loop() {

if(digitalRead(STATE)== HIGH)

// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
int incomingByte =;
// action depending on the instruction
// as well as sending a confirmation back to the app
switch (incomingByte) {
case 'F':
Serial.println("Going forward");
case 'L' : // Case 'L' is received,
SERVO_1.write (180); // Στρίψε Αριστερά.
case 'N':
Serial.println("Turning right");
case 'M':
Serial.println("Turning left");
case 'O' : // Case 'L' is received,
SERVO_1.write (0); // Στρίψε Αριστερά.
case 'B':
Serial.println("Going forward");
case 'P':
SERVO_1.write(90); // Στρίψε Αριστερά.
case 'S':
// if nothing matches, do nothing

void moveForward() {
// turn the driving motor on to go forwards at set speed
digitalWrite(ENABLE1, HIGH);
digitalWrite(ENABLE2, HIGH);
digitalWrite(ENABLE3, HIGH);
digitalWrite(ENABLE4, HIGH);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);


void moveBackward() {
// turn the driving motor on to go backwards at set speed
digitalWrite(ENABLE1, LOW);
digitalWrite(ENABLE2, LOW);
digitalWrite(ENABLE3, LOW);
digitalWrite(ENABLE4, LOW);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
void turnright() {
digitalWrite(ENABLE1, HIGH);
digitalWrite(ENABLE2, HIGH);
digitalWrite(ENABLE3, LOW);
digitalWrite(ENABLE4, LOW);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);

void turnleft() {
digitalWrite(ENABLE1, LOW);
digitalWrite(ENABLE2, LOW);
digitalWrite(ENABLE3, HIGH);
digitalWrite(ENABLE4, HIGH);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
void moveNone() {
// turn the driving motor off
digitalWrite(ENABLE1, 0);
digitalWrite(ENABLE2, 0);
digitalWrite(ENABLE3, 0);
digitalWrite(ENABLE4, 0);
analogWrite(PWM1, 0);
analogWrite(PWM2, 0);
analogWrite(PWM3, 0);
analogWrite(PWM4, 0);

About This Instructable




Bio: Did I unplug the solder iron?
More by techbitar:IR Remote Control Station for Android - TURN THE TV DOWNSensoDuino: Turn Your Android Phone into a Wireless Sensors Hub for ArduinoModify The HC-05 Bluetooth Module Defaults Using AT Commands
Add instructable to: