Bluetooth is everywhere nowadays. It’s a word we hear all the time and is in millions of products we use everyday, including headsets, cellphones, laptops, game controllers, activity trackers, and so on.
In our world of embedded electronics, Bluetooth serves as an excellent way to transmit small amounts of data wirelessly over short distances (less than 100 meters). It can be used for real-time data logging, or controlling a project using a smartphone.
One of the most affordable and widely used Bluetooth modules is the HC-05. You can easily find it for around $5 online, making it a budget-friendly option to add Bluetooth connectivity to your project. No more tangled cables and messy wires!
In this tutorial, we’ll help you get started with the HC-05. But we don’t want to overwhelm you with too much information at once, so we’ll split it into three easy-to-follow tutorials. This first tutorial will show you how to send and receive data between the HC-05 and your smartphone. In the next tutorial, we’ll teach you how to configure the HC-05 using AT commands. And in the final tutorial, you’ll learn how to make two Arduino boards communicate wirelessly using HC-05 Bluetooth modules.
By the end of these tutorials, you’ll have a good understanding of using the HC-05 Bluetooth module in your projects. So, let’s get started!
HC-05 Hardware Overview
The HC-05 is a Bluetooth-to-Serial-Bridge module that allows wireless communications between two microcontrollers or between a microcontroller and a smartphone, laptop, or desktop PC with Bluetooth capability. It’s perfect for directly replacing a wired asynchronous serial interface!
Each of these modules contains a Bluetooth transceiver, meaning they’re capable of both sending and receiving data.

As a Class 2 Bluetooth device, the HC-05 has a nominal range of 10 m. Of course, that is out in the open. Its range gets a little weaker inside the house, especially because of the walls.
To top it all off, these modules are very easy to use. There’s no need to mess with Bluetooth protocols or the stack. Just send data over a serial interface, and it’s piped through to whatever Bluetooth device it’s connected to.
Modes of Operation
Controlling the HC-05 module and sending data through it are two different operations, but they are both accomplished through the serial interface. To distinguish between these two types of data, the HC-05 employs two distinct communication modes: AT mode and Data mode.
In AT Mode, you can configure various settings of the HC-05 module, such as its name, baud rate, PIN code, and data rate.
In Data Mode, the HC-05 module acts as a transparent data gateway. When the HC-05 receives data, it removes the Bluetooth headers and trailers and sends it to the UART port. When data is written to the UART port, the HC-05 constructs a Bluetooth packet and sends it over the Bluetooth wireless connection.
Connection Roles
The HC-05 Bluetooth module can function in two main roles: Master and Slave.
In Slave Role, the HC-05 module waits for other devices to initiate a connection. This is the module’s default role and is commonly used in projects where you want to control things using a smartphone.
In Master Role, the HC-05 actively searches for other Bluetooth devices and tries to initiate a connection. This mode is used in projects where two microcontrollers need to communicate wirelessly.
To switch between roles, you need to configure the HC-05 module by putting it into AT mode and sending AT commands over the UART port.
Power
The maximum operating voltage of the bare HC-05 chip is 3.3V. Therefore, the module includes a linear 3.3V regulator, which allows a voltage from 3.6V to 6V to be used to supply power to the module.

It is important to note that the HC-05 module has a 3.3V logic level, so we cannot connect the HC-05 module’s Rx pin directly to a digital pin on a 5V microcontroller like an Arduino UNO. In other words, the Rx pin on the HC-05 module is not 5V-tolerant. Therefore, before connecting to the HC-05 module, the microcontroller’s Tx signal must be stepped down to 3.3V.
The current consumption of the HC-05 module depends on what state it is in. This table from the datasheet provides some good estimates:
Mode | Current Consumption |
Connected with data transfer | 45 mA |
Connected Idle | 8 mA |
Status LED
Many HC-05 modules come with an onboard LED.

It blinks at various rates to indicate the status:
- When powered up, the module enters Bluetooth pairing mode, with the LED flashing rapidly at about 2 Hz.
- When the module is paired with a device, the LED flash pattern changes to two quick flashes, followed by a pause, and then repeats.
- When the module is put into AT mode, the LED blinks at a slow and steady rate.
AT Mode
AT Mode is the configuration mode where you can send Hayes AT-style commands to the HC-05 module to change its settings like name, baud rate, password, etc.
Normally, the HC-05 module is in data mode. To put it into AT mode, you need to press-and-hold the onboard button while powering up the module. The LED will then start blinking at a slow and steady rate, indicating that the module is in AT mode.

Once in AT mode, you can send AT commands to the module over the UART port. The module will respond to the commands, either by acknowledging the command, providing the requested data, or signaling an error. The commands usually start with “AT+” followed by the specific command, e.g., “AT+NAME?” queries the name of the module or “AT+NAME=MyHC05” changes the name to “MyHC05”.
AT commands should be sent at the baud rate specified for the AT mode, which is often different from the baud rate used for data transmission. The default baud rate for AT mode is 38400 bps, but it can be changed if necessary.
HC-05 Pinout
The HC-05 module breaks out six pins. Let’s look at the pinout.

STATE pin can be used to determine the current status of the HC-05 module. The State pin is LOW when the module is not paired and HIGH when it is.
RXD pin receives serial data from the microcontroller. It should be connected to the TX of the microcontroller. Please note that this pin is not 5V-tolerant. Therefore, before connecting the module to a 5V microcontroller, the microcontroller’s Tx signal must be stepped down to 3.3V.
TXD pin sends serial data to the microcontroller. It should be connected to the RX of the microcontroller.
GND is the ground pin, common to any other device connected to the module.
VCC is where you connect the positive supply voltage. This voltage supply signal is routed to the HC-05 chip via a 3.3V regulator. It should range from 3.6V to 6V.
EN is connected to the on-board regulator enable pin and is pulled high by a 220k resistor. Pulling this pin low disables the regulator, which consequently turns off the HC-05.
Controlling the HC-05 Module
A serial interface is all that is required to control the HC-05 Bluetooth module and send data through it. It acts, essentially, like a data pipeline: serial data that goes into the module (from the RXD pin), is passed out the Bluetooth connection. Data coming in from the Bluetooth side is passed out the serial side (out the TXD pin).
To set up this data pipeline, we follow a two-step process:
- Connect the HC-05 module to a device capable of sending and receiving serial data, like an Arduino or any microcontroller with UART.
- On the Bluetooth side, we establish a wireless connection between the HC-05 module and another Bluetooth-enabled device, such as an Android phone. This connection involves a pairing process similar to connecting any other Bluetooth devices together. You will also need a terminal program installed on your phone that can communicate via Bluetooth. For this purpose, we recommend using the “Serial Bluetooth Terminal,” which is available in the Play Store. However, there are also many other free options that you can explore.
In summary, we just need to set up the serial interface between the HC-05 and our microcontroller and then pair the HC-05 with the other Bluetooth device, and we’re good to go!
Wiring a HC-05 Module to an Arduino
Connecting the HC-05 Module to an Arduino is as easy as applying power and wiring up the serial RX and TX pins.
Instead of connecting the HC-05 Module to the Arduino’s hardware UART, we’ll use SoftwareSerial and connect the HC-05’s RX and TX pins to any of the Arduino’s free digital pins. This will help to avoid bus contention and ensure that the HC-05 doesn’t receive any unintended data during a sketch upload.
Therefore, the TXD of the HC-05 module is connected to the Arduino’s D3, the RXD to D2, GND to GND, and VCC to 5V. The TXD and RXD pins can actually be connected to any digital pin (except 0 and 1). So, if pins 2 and 3 are needed for other purposes, feel free to switch them.
However, if you remember, the Rx pin on the HC-05 module is not 5V-tolerant. Thus, you can’t connect the HC-05’s Rx pin directly to the Arduino’s (5V MCU) digital pin. The Tx signal from the Arduino must be stepped down to 3.3 V. There are numerous ways to accomplish this, but the simplest is to use a resistor divider. A 1K resistor between HC-05’s Rx and Arduino’s D2, and a 2K resistor between HC-05’s Rx and GND, will work just fine.
To summarize, the following are the connections we’ll make for the example code later in this tutorial:
HC-05 Module | Arduino | Notes | |
VCC | 5V | – | |
GND | GND | – | |
TXD | D3 | – | |
RXD | D2 | Use level shifter if using 5V MCU |
The image below shows how to connect the HC-05 module to the Arduino Uno.

Bluetooth Serial Passthrough Sketch
With a little ingenuity, we can use the Arduino as a medium between us and the HC-05 module. Below is a simple sketch that relays data between the Arduino Serial Monitor and the HC-05 module.
#include <SoftwareSerial.h>
//Create software serial object to communicate with HC-05
SoftwareSerial mySerial(3, 2); //HC-05 Tx & Rx is connected to Arduino #3 & #2
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Arduino and HC-05
mySerial.begin(9600);
Serial.println("Initializing...");
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop()
{
if(Serial.available())
{
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
if(mySerial.available())
{
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
delay(20);
}
Once you have uploaded the sketch, open the serial monitor at baud rate 9600. You should see a message saying: “The device started, now you can pair it with bluetooth!”.

Connecting to the Android Phone
Let’s set up a wireless connection between the HC-05 module and an Android phone. The process may vary depending on the device, but the general steps are quite similar.
1. Make sure the HC-05 module is powered up and ready to establish a connection. The onboard LED should be blinking rapidly at about 2 Hz, indicating that it is discoverable.
2. Now, swipe down from the top of your Android phone’s screen and make sure Bluetooth is turned on.

3. Touch and hold the Bluetooth icon, then tap “Pair new device” and wait a few seconds.

4. Tap the name of the Bluetooth device you want to pair with your device (in our case, HC-05). Follow any on-screen instructions.

5. When asked, enter 1234 as the PIN code. This is the default PIN for every HC-05 module.

6. For the next steps in this tutorial, you need a Bluetooth Terminal application installed on your smartphone. We recommend using the Android app “Serial Bluetooth Terminal,” available in the Play Store.

7. After installing, launch the “Serial Bluetooth Terminal” app. Click on the icon in the top left corner and choose “Devices”.

8. You should see a list of devices you’ve previously paired with. Select “HC-05” from this list.

9. You should get a “Connected” message. The flash pattern on your HC-05’s onboard LED should now change to two quick flashes followed by a pause. That’s it! Your smartphone is now successfully paired with the HC-05 Bluetooth module and ready to communicate.

10. Now, type something in the input box located at the bottom of the app, for example, “Hi!”

11. You should instantly receive that message in the Arduino IDE Serial Monitor.

12. You can also exchange data between your Serial Monitor and your smartphone. Type something in the Serial Monitor’s top input box and press the “Send” button.

13. You should instantly receive that message in the Serial Bluetooth Terminal App.

Arduino Project: Bluetooth-Controlled Relay
Let’s create a simple project that lets you control relays wirelessly using Bluetooth. This can be useful for home automation, smart lighting, security systems, and other similar applications.
In this project, we will be using a two-channel relay module. If you’re not familiar with it, consider reading the tutorial below.
Wiring
We’ll use the same Arduino setup as in the previous example, but this time we’ll add a two-channel relay module to operate a lamp.
The image below shows how to build the circuit.

Arduino Code
Once you are done with the wiring, try the below sketch.
#include <SoftwareSerial.h>
// GPIO where relay is connected to
const int relayPin = 6;
// Handle received messages
String message = "";
// Create software serial object to communicate with HC-05
SoftwareSerial mySerial(3, 2); //HC-05 Tx & Rx is connected to Arduino #3 & #2
void setup() {
// Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
// Initialize relayPin as an output
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH);
//Begin serial communication with Arduino and HC-05
mySerial.begin(9600);
Serial.println("Initializing...");
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
if (mySerial.available()){
char incomingChar = mySerial.read();
if (incomingChar != '\n'){
message += String(incomingChar);
}
else{
message = "";
}
Serial.write(incomingChar);
}
// Check received message and control output accordingly
if (message == "on"){
digitalWrite(relayPin, LOW);
}
else if (message == "off"){
digitalWrite(relayPin, HIGH);
}
delay(20);
}
Testing the Code
Once you have uploaded the sketch, open the serial monitor at baud rate 9600. You should see a message saying: “The device started, now you can pair it with bluetooth!”.

Launch the Serial Bluetooth Terminal app and connect to your HC-05 module.
Now, as you type “on” in the input box at the bottom of the app, the relay should activate instantly. Likewise, typing “off” will deactivate the relay immediately.

Additionally, you will receive these messages in the Arduino IDE Serial Monitor for monitoring purposes.

The app offers several macros that you can customize to save default messages. For instance, you can associate M1 with the “on” message and M2 with the “off” message. This way, you can easily control the relay using the predefined buttons, adding an extra layer of convenience to your project.


Going Further
Hopefully, this tutorial has prepared you for an exciting foray into the world of Bluetooth. Now that you have a good idea of how to send and receive data between the HC-05 and your smartphone, it’s time to explore further by learning how to configure the HC-05 using AT commands.
And how to make two Arduino boards communicate wirelessly using HC-05 Bluetooth modules, unlocking even more possibilities for your wireless projects.