Master HC-05 Bluetooth AT Commands: Set Baud Rate, Name, and Password

Introduction: Why You Should Master HC-05 Bluetooth AT Commands

Master HC-05 Bluetooth AT Commands: Set Baud Rate, Name, and Password Like a Pro :- The HC-05 Bluetooth module is one of the most popular and versatile modules used in DIY projects, IoT devices, and wireless communication setups. At the core of its functionality lies the AT commands, which enable you to control, customize, and configure the module to meet your specific needs.

In this comprehensive guide, we’ll teach you everything about HC-05 Bluetooth AT commands, including how to set the baud rate, change the name, and create a secure password. With step-by-step instructions, troubleshooting tips, and real-world applications, this guide is all you need to get started with the HC-05 module.

What Is the HC-05 Bluetooth Module?

The HC-05 Bluetooth module is a popular wireless communication device that supports both master and slave modes. It uses Bluetooth 2.0 technology to establish a wireless connection between devices like microcontrollers, smartphones, and computers. Its easy setup and flexibility make it ideal for DIY electronics projects.

Key Features of HC-05 Bluetooth Module:

  • Operates at a standard frequency of 2.4GHz.
  • Supports a default baud rate of 9600.
  • Configurable through AT commands.
  • Works in both Master and Slave modes.
  • Provides wireless range up to 10 meters.

Why Learn AT Commands for HC-05 Bluetooth Modules?

AT commands are essential for controlling and configuring your HC-05 module. Here’s why mastering these commands is beneficial:

  • Customization: Easily change the name of the device for better identification.
  • Security: Set a unique password to prevent unauthorized access.
  • Speed Optimization: Adjust the baud rate for faster or more stable communication.
  • Troubleshooting: Use commands to check the module’s status or reset it to factory settings.

By mastering HC-05 Bluetooth AT commands, you can unlock the full potential of this powerful module.

How to Configure HC-05 Bluetooth AT Commands with Arduino

The HC-05 Bluetooth module is a versatile tool for adding wireless connectivity to your Arduino projects. To fully unlock its potential, you need to configure it using AT commands. In this guide, we’ll walk you through how to connect the HC-05 module to an Arduino, enable AT mode, and send AT commands to configure settings like baud rate, name, and password.

Required Components

  • Arduino Uno/Nano/Any Arduino Board
  • HC-05 Bluetooth Module
  • Connecting Wires
  • Breadboard (optional)
  • USB Cable (to connect Arduino to your computer)
  • PC with Arduino IDE Installed

Circuit Diagram: Connecting HC-05 to Arduino

Make the following connections between the HC-05 module and the Arduino board:

HC-05 PinArduino Pin
VCC5V
GNDGND
TXDD10
RXDD11 (via a voltage divider)
EN (or KEY)3.3V (Enable AT mode)
Master HC-05 Bluetooth AT Commands Configure baud rate, customize the name, set passwords, and unlock advanced features effortlessly.

Important Notes:

  1. Voltage Divider for RXD: The HC-05 RXD pin operates at 3.3V. Use a voltage divider with two resistors (e.g., 2kΩ and 1kΩ) to step down the Arduino’s 5V signal to 3.3V.
  2. EN Pin: Connect the EN pin to 3.3V to enable AT mode. Without this, the module won’t accept AT commands.

Arduino Code for HC 05 AT Command Mode

Upload the following code to your Arduino to communicate with the HC-05 in AT mode. This code establishes a SoftwareSerial connection to send and receive AT commands.

#include <SoftwareSerial.h>

// Define software serial pins for HC-05
SoftwareSerial Bluetooth(10, 11); // RX (pin 10), TX (pin 11)

void setup() {
  Serial.begin(9600);         // Serial monitor baud rate
  Bluetooth.begin(38400);     // Default HC-05 baud rate in AT mode
  Serial.println("Enter AT commands:");
}

void loop() {
  // Forward data from Serial Monitor to HC-05
  if (Serial.available()) {
    Bluetooth.write(Serial.read());
  }
  
  // Forward data from HC-05 to Serial Monitor
  if (Bluetooth.available()) {
    Serial.write(Bluetooth.read());
  }
}

Step-by-Step Instructions

1. Upload the Code to Arduino

  • Open the Arduino IDE.
  • Copy and paste the code above.
  • Select the correct COM port and board type (e.g., Arduino Uno).
  • Click Upload to upload the code to your Arduino.

2. Connect HC-05 to AT Mode

  • Disconnect power to the HC-05 module.
  • Press and hold the EN/Key pin button.
  • While holding the button, reconnect the power (plug in your Arduino).
  • The HC-05’s LED will blink slowly, indicating it’s in AT mode.

3. Open the Serial Monitor

  • Go to Tools > Serial Monitor in the Arduino IDE.
  • Set the baud rate to 9600 and select “Both NL & CR” at the bottom.

4. Send AT Commands

You can now type AT commands into the Serial Monitor and see the responses from the HC-05 module.

Try AT Commands

1. Set the Baud Rate

The baud rate controls the speed of communication between your module and the connected device. By default, the HC-05 operates at 9600. Use the following command to change it:

AT+UART=115200,0,0  
  • 115200 is the new baud rate. You can replace this with other values such as 4800, 38400, or 57600.
  • The 0,0 specifies stop bits and parity.

To verify the current baud rate, use:

AT+UART?  

The module will respond with the current baud rate settings.

2. Change the Bluetooth Device Name

Customizing the name of your HC-05 module makes it easier to identify during pairing. The default name is often “HC-05,” but you can personalize it as follows:

AT+NAME=MyBluetoothDevice  

Replace “MyBluetoothDevice” with your preferred name. Confirm the change with:

AT+NAME?  

3. Set a Password for Security

For secure communication, set a password using this command:

AT+PSWD=1234  

Replace 1234 with your desired password. To verify the password, send:

AT+PSWD?  

4. Switch Between Master and Slave Mode

The HC-05 can operate in both Master and Slave modes. To change the mode:

  • Set to Master mode:
AT+ROLE=1  
  • Set to Slave mode:
AT+ROLE=0  

Check the current mode with:

AT+ROLE?  

5. Query Device Information

To check the module’s firmware version or Bluetooth address, use these commands:

  • Firmware version:
AT+VERSION  
  • Bluetooth address:
AT+ADDR?  

Troubleshooting Common Issues with HC-05 Bluetooth AT Commands

Even with the correct setup, you may encounter issues. Here are some common problems and their solutions:

  1. HC-05 Doesn’t Respond to AT Commands:
    • Ensure the module is in AT mode (slow blinking LED).
    • Check the wiring, especially the voltage divider on RXD.
  2. Wrong Characters in Serial Monitor:
    • Verify that the baud rate in the Serial Monitor matches the module’s baud rate.
  3. Cannot Change Settings:
    • Some settings require a module reset after configuration. Disconnect and reconnect the power.

Real-World Applications of HC-05 Bluetooth Modules

The HC-05 module has countless applications, including:

  1. Wireless Robot Control: Use the module to send commands to your robot wirelessly.
  2. IoT Projects: Pair with microcontrollers to create smart home devices.
  3. Data Transmission: Send and receive data between devices without physical cables.
  4. LED Control: Turn LEDs on and off using Bluetooth commands.
  5. Sensor Integration: Transmit sensor data wirelessly to a smartphone or computer.

Advanced HC-05 Bluetooth AT Commands for Power Users

Once you’ve mastered the basics, explore advanced commands to further enhance your HC-05 module:

  • Set Auto-Connection Parameters:
AT+CMODE=0  
  • Enable Encryption:
AT+SENM=3,1  
  • Restore Factory Settings:
AT+ORGL  

Conclusion: Master Your HC-05 Bluetooth Module Today

The HC-05 Bluetooth module is a game-changer for wireless communication, and mastering AT commands unlocks its full potential. By learning to set the baud rate, customize the name, and secure the connection with a password, you can create robust and efficient Bluetooth-enabled projects.

With this guide, you’re now equipped to confidently configure your HC-05 module. Start exploring its features and take your projects to the next level!

FAQs

  1. What is the default password for HC-05?
    The default password is usually 1234 or 0000.
  2. How do I reset my HC-05 module?
    Use the command AT+ORGL to restore factory settings.
  3. Can I change the baud rate while in AT mode?
    Yes, you can change it using the AT+UART command.

Conclusion

Master HC-05 Bluetooth AT Commands: Set Baud Rate, Name, and Password Like a Pro: By following this guide, you’ve learned how to connect and configure an HC-05 Bluetooth module with Arduino using AT commands. From changing the device name to setting a secure password, you now have the tools to customize your module for any project.

Experiment with the settings and take your projects to the next level with the power of wireless communication!

How to Download the BlueBot Controller App

To get started, download the BlueBot Controller App from the official source:

Make sure you have a Bluetooth-enabled smartphone to pair with your project.

Read More : Blog