Bluetooth Module HC-05 with Arduino: A Complete Guide

Introduction

In this guide, we’ll learn everything about using the HC-05 with Arduino. HC-05 is one of the most popular Bluetooth modules used in Arduino projects, especially when you want to add wireless communication to your project.

Whether you want to control a robot from your phone or send sensor data wirelessly, the HC-05 module is a simple and affordable solution. In this complete guide, I’ll show you how to connect HC-05 with Arduino UNO, write code to send and receive data, and even enter AT command mode to change settings like device name and password.


What is HC-05 Bluetooth Module?

HC-05 is a classic Bluetooth module that supports both Master and Slave modes. This makes it more flexible than some other modules, like HC-06 (which only works in Slave mode). It communicates with Arduino using Serial Communication (UART), making it easy to connect with Arduino’s TX and RX pins.

Key Features of HC-05:

  • Operating Voltage: 3.6V – 6V (Logic level 3.3V)
  • Communication: UART (9600 baud default)
  • Range: ~10 meters
  • Master/Slave mode support
  • Built-in LED for status indication
  • Default password: 1234 or 0000
bluetooth_HC-05
HC-05 Module

HC-05 Pinout and Explanation

PinDescription
EN (KEY)Used to enter AT Command Mode
VCCPower supply (3.6V to 6V)
GNDGround
TXTransmit Data
RXReceive Data
STATEStatus indicator
BT_HC-05_Pinout
HC-05 Pinout

How to Connect HC-05 with Arduino UNO

Connecting HC-05 with Arduino is straightforward, but there’s one important detail — HC-05’s RX pin works at 3.3V logic level, while Arduino works at 5V. To avoid damaging the module, we add a voltage divider between Arduino TX and HC-05 RX.

Wiring Table

HC-05 PinArduino Pin
VCC5V
GNDGND
TXPin 2 (Arduino RX)
RXPin 3 (Arduino TX via voltage divider)

For the voltage divider, use:

  • 2K or 2.2K ohm resistor to GND
  • 1K ohm resistor between Arduino TX and HC-05 RX
HC-05 with Arduino Wiring
HC-05 with Arduino Wiring

Basic Communication (Send/Receive Data)

To communicate between HC-05 and Arduino, we use SoftwareSerial because Arduino UNO’s hardware serial (pins 0 & 1) is used for uploading code and Serial Monitor.

Code:

// HC-05 with Arduino bu ArduinoYard
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(2, 3); // RX, TX

void setup() {
    Serial.begin(9600);      // Serial Monitor
    BTSerial.begin(9600);    // HC-05 Baud Rate
    Serial.println("HC-05 with Arduino - Ready");
}

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

Hardware:

HC-05 with Arduino Hardware

How to Test:

  1. Upload this code to Arduino.
  2. Open Serial Monitor (9600 baud, Both NL & CR selected).
  3. Pair HC-05 with your phone (default password: 1234).
  4. Use a free app like Serial Bluetooth Terminal on your phone to connect.
  5. Send messages from the app and see them appear on Serial Monitor!

App Output:

Serial Output:


Entering AT Command Mode (Configuration Mode)

Sometimes you need to change the HC-05 name, password, or baud rate. For that, we use AT commands. We will use the same code as above.

Steps to Enter AT Command Mode:

  1. Disconnect power from HC-05.
  2. Hold the KEY/EN button.
  3. Power the module back on while holding the button.
  4. The LED will blink slowly (2 seconds gap) — this confirms AT Mode is active.

AT Command Examples:

CommandDescription
ATCheck connection
AT+NAME=ArduinoYard_BTSet Bluetooth name
AT+PSWD=4321Set new password
AT+UART=9600,0,0Set baud rate
  • Send these from Serial Monitor (9600 baud, Both NL & CR).
  • Each command should return OK if successful.

Seril Monitor:

Verifying the New Bluetooth Name:

After successfully changing the name, password, and baud rate through AT commands, it’s time to check if the changes actually took effect. To do this, we can scan for Bluetooth devices using a smartphone.

Once the HC-05 is back in normal mode (by disconnecting and reconnecting power without the WAKEUP pin connected), it will advertise itself with the new name we just set.

Here’s how the module should now appear in your phone’s Bluetooth device list:

Troubleshooting Tip: Baud Rate Issues in AT Mode

If you enter AT mode but don’t get any response after sending commands like AT, the issue might be the baud rate. Most HC-05 modules expect 38400 in AT mode, but some versions (especially clones) might use 9600 instead. If you face this problem, try changing the Serial Monitor baud rate to 9600 or 38400 and test again. This simple step can save a lot of frustration when working with different module variants.


Control LED with HC-05 and Arduino (Mini Project)

Let’s make a simple project using HC-05 with Arduino — controlling an LED from your phone via Bluetooth.

Wiring

ComponentPin
LEDPin 7
HC-05Same as previous wiring

Code

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(2, 3);
const int ledPin = 7;

void setup() {
    pinMode(ledPin, OUTPUT);
    BTSerial.begin(9600);
}

void loop() {
    if (BTSerial.available()) {
        String command = BTSerial.readString();
        command.trim();

        if (command == "ON") {
            digitalWrite(ledPin, HIGH);
        } else if (command == "OFF") {
            digitalWrite(ledPin, LOW);
        }
    }
}

How to Test

  • Use Bluetooth Terminal app.
  • Connect to HC-05.
  • Send ON to turn LED on, and OFF to turn it off.

Common Issues and Troubleshooting

IssuePossible Cause
No response to AT commandsWrong baud rate, wiring issue, not in AT mode
Garbage data in Serial MonitorBaud rate mismatch
Can’t pair with phoneWrong password, faulty module
HC-05 RX not receiving dataVoltage divider missing or incorrect

Conclusion

That’s everything you need to know to use HC-05 with Arduino! From basic communication to configuring the module and controlling devices via Bluetooth — you’re now ready to use this powerful little module in your own projects.

Let me know in the comments if you face any issues while working with HC-05 with Arduino.


Useful Resources

Guides/Projects

Documentation

Leave a Comment