HC-05 Bluetooth Module

HC-05 is the best Bluetooth device that uses a UART communication protocol. The HC-05 Bluetooth is much different in features from all other Bluetooth devices because of its multiple pins and their functions. It has multiple pins for the different method which makes it unique as compare to others. The module normally operates at UART serial communication with TX and RX pins at 9600 baud rates. It offers a two-way communication method and the HC-05 can act as either slave and master. The Bluetooth module offers only short distance communications due to its limitation but still, most of the devices come with it due to its speed and security. The limitation of this device is that it doesn’t allow to transfer any kind of media.

HC-05 Bluetooth Module

HC-05 Pin Configuration

The HC-05 comes with multiple pins and indicators, which helps to control different operations and view their states through indicators. This pinout diagram provides indications of all pins. This also illustrates the functionality of each pin.

HC-05 Bluetooth Module Pin Configuration

Pinout Diagram Description

VCC Pin

Therefore, like every device, HC05 Modules also depend on the power to operate and the VCC pin helps to interface with the external power source.

GND Pin

To interface with microcontroller common ground is necessary for every device. The ground pin of the module will solve the requirement.

TX Pin

The HC-05 Bluetooth module interface with the microcontroller through UART communication. The TX will be the data transfer pin of the module in UART.

RX Pin

This pin will be the data receiving the pin in UART communication.

State Pin

The state will be to show the current state of the Bluetooth. It gives feedback to the controller about the connectivity of Bluetooth with another device.

Enable/Key Pin

Enable/Key pin is the only pin that makes the HC-05 unique than the others. It helps to change the device between data mode and command mode using an external signal. The HIGH logic state will transfer the device in command mode and the LOW logic state will transfer in data mode. The default device state without any signal will be data mode.

Button Pin

The command and data mode states are changeable through a button present on the module.

LED Pin

LED will help to visualize the different states of the HC-05 Module.

HC-05 Bluetooth Module Features

  • HC-05 Bluetooth module offers two ways of communication for shorter distances with fast speed.
  • It has an enable pin which allows toggling between command and data mode.
  • The device uses UART (serial communication) which is easy to interface with any microcontroller or system.
  • Its range is up to 8 – 10 meters but it signals lower down with any obstacle in its way.
  • The device uses 5V to power up.
  • The module can act as both, master or slave.
  • The following baud rates are usable for the module:
    • 9600
    • 19200
    • 38400
    • 57600
    • 115200
    • 230400
    • 460800

HC-05 Applications

  • Most of the remote-control cars for kids comes with HC 06 Bluetooth.
  • In wireless headphones and mouse, HC05 is available for wireless communication due to its fast speed.
  • In IoT instead of WiFi some devices also have Bluetooth for their communication to avoid the flooding on the internet.

How to use this HC-05 Bluetooth Board

The use of the HC-05 Bluetooth module is simple for every microcontroller, even for every system which has a serial communication interface. The module has two serial input pins, both will interface for data communication. TX will interface with RX of the controller and RX will interface with TX of the microcontroller. The data will be transfer with the baud rate. The baud rate will define within the microcontroller. The data will be transfer to 9600 which is the default one but it is changeable too.

HC-05 Bluetooth Module circuit

There is a third pin (Key) that connects with the external GPIO pin or button but it is controllable through a button. The basic purpose of the key pin is to toggle between the modes. The default mode, when there won’t be any input on the Key input the device will act as data mode. In data mode, there will be only data transfer from the device. After applying the HIGH input signal at the key pin, the device is going to enter the Command mode.

Command Mode

In command mode, there are some rules. The command mode only communicates at 38400 baud rates. After entering in to command mode the default setting of the module is changeable. Then following commands will help to change the settings of the HC-05.

  • AT – To check the communication
  • AT+NAME= ****** – To set/change the device name
  • AT+UART= *****, *, * – To set the baud rate, stop and parity bit
  • AT+VERSION? – It will show the version of the Bluetooth module of Responder.
  • AT+ORGL – This will set the save command to the module that the setting has been done.

Master/Slave Mode

Both modes help the module to act as a Master and a Slave. At default mode, the HC-05 BT will act as a slave. By using a default password, the device will connect.

  • Default Password: 1234 or 0000

To use the module as a master, it should be in command mode. The master mode is not common in every Bluetooth module. HC05 is one of its kind.

The key pin may help toggle the modes which are controllable through a digital signal but the module offers a button on itself which is useable to toggle the modes.

Indicator Function 

The states of the HC-05 BT have a vital role here. A state pin and an LED can do it. LED is for the users and the state pin is for the microcontrollers. The state pin will just go high in case of connectivity which is to inform the microcontroller to perform further instructions. The LED will have different functions and all of them are:

  • If it keeps blinking then it is waiting for the connection.
  • Blink one time for 2 sec will indicate that the module has gone in Command Mode.
  • Blinking twice in one sec will indicate module has gone in Data Mode.

HC-05 Bluetooth Module Example with Arduino

There are multiple types of devices with the HC05 module but the most common nowadays is with Arduino. In Arduino, there isn’t any special library to perform the interfacing with Arduino. To interface it with Arduino the follow the given image:

HC-05 Bluetooth Module example interfacing with Arduino Uno

Arduino Interfacing Program

Then upload the following code in the Arduino board.

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(2, INPUT);
}
void loop() {
if (Serial.available() > 0 ) {
int data = Serial.read();
Serial.println("INCOMING DATA:");
Serial.print(data);
}
// put your main code here, to run repeatedly:
}

Code Working

The code will simply check the incoming data from serial print and will print it to the Arduino COM screen.

After HC-05 board interfacing, the module will need to power up, then connect it with another Bluetooth module on your mobile or laptop. During connecting use, the password 1234 or 0000. Then send any text data through your mobile. To send the data there are a bunch of mobile applications. In the case of sending the media file, there could be an error because HC05 doesn’t support it. This way the module will act as a slave but by using the following code it can be converted to the Master. The only thing we will need to change is the baud rate, which can be changeable from the following statement.

void setup() {
// put your setup code here, to run once:
Serial.begin(38400); // just change the baud rate from 9600 to 38400
pinMode(2, INPUT);
}

In the case of the device as a master, the other end should have the same baud rate to communicate with each other. The HC-05 is most common in most of the devices nowadays. It can only connect with a single device at a time and without the device’s permission, it doesn’t change its master. The device is much efficient in short distance communication still after the inventions of the new methods. It is much secure and fast; it also allows invisibility for other devices which makes it much secure.

HC-05 tutorials and Projects

You can check these HC-05 Bluetooth modules based projects:

2D Diagram

Bluetooth Module 2D diagram

Alternative Modules:

Leave a Comment

4 × two =