Table of contents
1.
Introduction
2.
What is Bluetooth Module HC-05?
3.
When Do We Use It?
4.
Basics of Bluetooth Module HC-05
4.1.
Description of Pins
4.2.
Modes of Operation
4.2.1.
Command Mode
4.2.2.
Data Mode
4.3.
Programming HC-05 with Microcontroller
4.3.1.
Connect HC-05 to Microcontroller:
5.
Android App Interfacing with HC-05
5.1.
1. Getting all the Bluetooth Devices in ListView
5.2.
2. Getting the Name and MAC Address of Device
5.3.
3. Establishing a Connection
5.4.
4. Finally Commanding the HC-05 Module
6.
Advantages of HC-05 Bluetooth Module
7.
Disadvantages of HC-05 Bluetooth Module
8.
Frequently Asked Questions
8.1.
Can HC-05 be used for both sending and receiving data?
8.2.
Is it possible to pair HC-05 with multiple devices simultaneously?
8.3.
How secure is the data transmission with HC-05?
9.
Conclusion 
Last Updated: Aug 13, 2025
Medium

Bluetooth Module HC-05

Author Pallavi singh
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Bluetooth technology has revolutionized wireless communication, allowing for seamless transfer of data over short distances. Among the various Bluetooth modules available, the HC-05 stands out due to its versatility and ease of use. Commonly used in robotics, embedded systems, and IoT (Internet of Things) applications, the HC-05 module facilitates wireless communication between devices, such as between a microcontroller and a smartphone.

 In this comprehensive guide, we will explore the HC-05 Bluetooth module, its functionality, modes of operation, and how to interface it with microcontrollers and Android applications.

Also read about, procedural programming

What is Bluetooth Module HC-05?

The HC-05 is a widely used Bluetooth module that enables serial communication (UART) wirelessly. It's a compact module that can easily be integrated into various electronic projects, allowing devices to communicate without the need for a wired connection. The module operates on Bluetooth 2.0 technology with Enhanced Data Rate (EDR) support, offering a range of approximately 10 meters (33 feet) under ideal conditions.

The HC-05 can function both as a master and a slave device, making it versatile for different types of Bluetooth applications. As a master, it can initiate a connection to other Bluetooth devices, while as a slave, it waits for connection requests.

When Do We Use It?

The HC-05 module is used in scenarios where wireless data transmission is required. Common use cases include:

  • Robotics: For remote controlling robots or receiving sensor data wirelessly.
     
  • Home Automation: Controlling lights, fans, and other home appliances remotely.
     
  • Data Logging: Sending sensor data from various sensors to a computer or smartphone for monitoring and analysis.
     
  • IoT Applications: Enabling smart devices to communicate with each other or with a central controller.

Also see,  Traceability Matrix

Basics of Bluetooth Module HC-05

The HC-05 module features several key components:

  • Bluetooth Transceiver: Handles all Bluetooth communication.
     
  • Baseband Processor: Controls the module's operations and interfaces with external devices through serial communication.
     
  • Antenna: Integrated on the module for sending and receiving radio waves.
     
  • LED Indicator: Shows the module's status (pairing, connected, etc.).

Description of Pins

The HC-05 module typically comes with six pins:

  • VCC: Power supply (3.3V - 5V).
     
  • GND: Ground connection.
     
  • TXD: Transmit data (sends data to the connected device).
     
  • RXD: Receive data (receives data from the connected device).
     
  • STATE: Indicates the connection status.
     
  • EN/KEY: Enables the AT command mode when set high.

Modes of Operation

Command Mode

In command mode, the HC-05 can receive AT commands, which are instructions used to change the settings of the Bluetooth module (like baud rate, name, pairing password, etc.). The module enters this mode when the EN/KEY pin is set high.

Data Mode

Data mode is the normal operation mode of the HC-05 where it transmits and receives data. In this mode, the module can send and receive data to and from the paired Bluetooth device.

Programming HC-05 with Microcontroller

To program the HC-05 with a microcontroller (like Arduino), you need to establish serial communication between them. Here’s a basic setup:

Connect HC-05 to Microcontroller:

VCC to 5V.

GND to Ground.

TXD to RX (of Microcontroller).

RXD to TX (of Microcontroller).

Sample Arduino Code:

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup() {
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400); // HC-05 default speed in AT command mode
}

void loop() {
  if (BTSerial.available())
    Serial.write(BTSerial.read());
  if (Serial.available())
    BTSerial.write(Serial.read());
}

This code sets up a basic serial communication between Arduino and HC-05, allowing you to send and receive data through the Arduino's serial monitor.

Android App Interfacing with HC-05

Interfacing an Android app with the HC-05 module involves several steps, from scanning for available Bluetooth devices to establishing a connection and communicating with the HC-05. We’ll break down these steps and provide a basic implementation guide.

1. Getting all the Bluetooth Devices in ListView

First, you need to list all available Bluetooth devices. This requires using the BluetoothAdapter class to start discovery and populate a ListView with discovered devices.
 

Algorithm:

  • Get the default BluetoothAdapter.
     
  • Check if Bluetooth is enabled; if not, request the user to enable it.
     
  • Discover devices and add them to an ArrayAdapter.
     
  • Display this ArrayAdapter in a ListView.

Example:

BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
ArrayList<String> deviceList = new ArrayList<>();
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, deviceList);
listView.setAdapter(arrayAdapter);

IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(receiver, filter); // receiver is a BroadcastReceiver to handle found devices

if (bluetoothAdapter.isDiscovering()) {
    bluetoothAdapter.cancelDiscovery();
}
bluetoothAdapter.startDiscovery();

2. Getting the Name and MAC Address of Device

Each Bluetooth device has a name and a MAC address. When a device is found, you can retrieve these details.

Example in BroadcastReceiver:

BroadcastReceiver receiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            String deviceName = device.getName();
            String deviceMAC = device.getAddress();
            deviceList.add(deviceName + "\n" + deviceMAC);
            arrayAdapter.notifyDataSetChanged();
        }
    }
};

3. Establishing a Connection

Once a device is selected from the ListView, establish a connection using BluetoothSocket.

Algorithm:

  • Get a BluetoothDevice object from its MAC address.
     
  • Create a BluetoothSocket for the device.
     
  • Connect to the device through the socket.

Example:

BluetoothDevice device = bluetoothAdapter.getRemoteDevice(macAddress);
BluetoothSocket bluetoothSocket = device.createRfcommSocketToServiceRecord(MY_UUID); // MY_UUID is a UUID you define
bluetoothSocket.connect();

4. Finally Commanding the HC-05 Module

With the connection established, you can send commands to the HC-05 module.

Example:

OutputStream outputStream = bluetoothSocket.getOutputStream();
outputStream.write("Your Command".getBytes());


This setup allows for basic communication between an Android app and the HC-05 module. For a complete app, you would include error handling, UI improvements, and possibly more complex communication protocols.

Advantages of HC-05 Bluetooth Module

  • Ease of Use: The HC-05 is relatively simple to interface with a wide range of microcontrollers, making it accessible even to beginners in electronics and robotics.
     
  • Cost-Effective: It is an affordable solution for wireless communication, making it suitable for hobbyists and educational purposes.
     
  • Dual Role Functionality: The ability to function both as a master and a slave device provides flexibility in various applications.
     
  • Range: With a range of up to 10 meters, it is suitable for many indoor applications like home automation and remote control.
     
  • Customizable Settings: Parameters like baud rate, device name, and pairing password can be customized using AT commands.
     
  • Serial Communication (UART): The module supports UART, which is a widely used communication protocol in microcontrollers and computers.

Disadvantages of HC-05 Bluetooth Module

  • Limited Range: While sufficient for many applications, its range of 10 meters can be limiting for larger-scale projects.
     
  • Speed Limitation: With Bluetooth 2.0 technology, data transfer rates are limited compared to newer Bluetooth versions.
     
  • Single Connection: The HC-05 can only connect to one device at a time, which might be restrictive for some applications.
     
  • Power Consumption: It consumes more power compared to some other wireless modules, which might be a concern for battery-powered projects.
     
  • Security Concerns: The security features are basic, making it less suitable for transmitting sensitive or private data.
     
  • Complexity in Android Interfacing: For beginners, interfacing with Android apps can be complex and requires a good understanding of Android development and Bluetooth protocols.

Also read , Difference between procedural and object oriented programming

See more, Application of frequent itemset mining 

Frequently Asked Questions

Can HC-05 be used for both sending and receiving data?

Yes, the HC-05 module can both send and receive data. It can be used in full-duplex mode, allowing for two-way communication between devices.

Is it possible to pair HC-05 with multiple devices simultaneously?

The HC-05 module can remember multiple paired devices, but it can only maintain an active connection with one device at a time.

How secure is the data transmission with HC-05?

While Bluetooth technology includes security features like pairing and encryption, the HC-05 module's security largely depends on how it's implemented in the project. It's advisable to implement additional security measures for sensitive data

Conclusion 

In summary, the HC-05 Bluetooth module is a versatile and widely used component in wireless communication projects. Its ability to operate in both master and slave modes, along with its ease of interfacing with microcontrollers and Android devices, makes it a popular choice for a wide range of applications from IoT to home automation and robotics.

You can refer to our guided paths on the Coding Ninjas. You can check our course to learn more about DSADBMSCompetitive ProgrammingPythonJavaJavaScript, etc. 

Also, check out some of the Guided Paths on topics such as Data Structure and AlgorithmsCompetitive ProgrammingOperating SystemsComputer Networks, DBMSSystem Design, etc., as well as some Contests, Test Series, and Interview Experiences curated by top Industry Experts.

Live masterclass