Close

March 23, 2018

Learn: Renaming the HC-05 Bluetooth Module Using AT Command

Last Update: 20 March 2018
Author: Louis Yong

 


OVERVIEW

This white paper describes the procedure to change the device name of the HC-05 Bluetooth module (HC-05) using the AT command set. The default settings in the HC-05 is standardised as follows:

Bluetooth name: HC-05
Security code: 1234 or 0000

However, the conditions in a classroom environment with multiple HC-05 result in students having difficulty in identifying which HC-05 to pair to their mobile phones or computers.

The solution is to change Bluetooth name of the HC-05 to a unique name using the AT command set.

 


PART 1: UNDERSTANDING THE ISSUE

Conducting a class with multiple Arduino and HC-05 results in confusion because students cannot determine which Bluetooth name to select to pair. All HC-05 use the same default settings:

Bluetooth name: HC-05
Security code: 1234 or 0000

One workaround is to have everyone power off their HC-05, and then one student at a time power on her HC-05 and pair it to her mobile phone or PC. Once paired, she powers off her HC-05 and then it’s the next student’s turn. This is time consuming and a distraction to the learning process.

Fortunately, we can change the default settings of the HC-05 using the AT command set.

 


PART 2: CONNECTING THE CIRCUIT

  1. You will need the following components:
    •  Arduino UNO (with Arduino IDE installed on a PC)
    •  HC-05
    •  Breadboard
    •  Jumper wires
  2. Assemble the following circuit.

 

 


Follow the labels on the HC-05. If the KEY pin is not available, see If Key Pin Is Not Present below.

 

WARNING:
The HC-05 is a 3.3V system. This circuit doesn’t use voltage dividers to drop 5V to 3.3V for this short procedure. It is not advisable to leave the HC-05 connected to the 5V Arduino pins for a long time.

If Key Pin Is Not Present

Some HC-05 do not have the KEY pin on the breakout board. Instead they have an EN or WAKE pin. In this case, connect a jumper cable to the KEY pin (inside the plastic sleeve) on the IC.

 


PART 3: PROGRAMMING THE ARDUINO

Upload the following program into the Arduino.


For more information on how to upload a program to the Arduino, visit https://www.arduino.cc/en/Guide/ArduinoUno

/*
AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (techbitar.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.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT 
                          // command mode
}

void loop()
{
  // Keep reading from HC-05 and send to Arduino 
  // Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

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

 


PART 4: RENAMING THE HC-05

Perform the following procedure to rename the HC-05:

  1. Disconnect the 5V power connection to the HC-05.
  2. Connect the Arduino to the PC with a USB cable.
  3. Reconnect the 5V power connection to the HC-05.

    The LED on the HC-05 should blink at 2-second intervals. This shows that the HC-05 is in AT mode.

    If the LED blinks rapidly, try the following:
    a.  Disconnect and reconnect the 5V power connection to the HC-05.
    b.  Check the connection to the KEY pin, and toggle the power connection.

  4. Open the Serial Monitor from the Arduino IDE, and then select Both NL & CR and 9600 baud. 
  5. Type AT and click Send. You should see OK. Otherwise, recheck your wiring.
  6. Type AT+NAME=<your custom Bluetooth name> and click Send.

    For example, to change the default name to MY-HC-05, enter
    AT+NAME=MY-HC-05.

More AT Commands

AT+ORGL
Return the default settings

AT+VERSION?
Show firmware version

AT+PSWD=4567
Change default security code to 4567

 

Leave a Reply

Your email address will not be published. Required fields are marked *