The Bluetooth HC-05 Arduino combination is one of the easiest ways to add wireless control to your projects. With this tiny module costing under ₹200, you can control an Arduino-powered robot from your Android smartphone, send sensor data wirelessly to a laptop, or build a Bluetooth-based home automation system. This guide covers HC-05 interfacing, AT command configuration, master-slave pairing, and building a complete mobile-controlled project.
Table of Contents
- HC-05 Module Overview
- HC-05 vs HC-06: Which to Buy
- Wiring HC-05 to Arduino
- AT Command Mode Configuration
- Sending Data: Arduino to Phone
- Receiving Commands: Phone to Arduino
- Project: Bluetooth Robot Control
- Frequently Asked Questions
HC-05 Module Overview
The HC-05 is a Bluetooth 2.0 Serial Port Profile (SPP) module based on the BC417 chip. It creates a wireless serial link, effectively replacing a physical wire between your Arduino and another Bluetooth device. Key specifications:
- Bluetooth Version: 2.0 + EDR (Enhanced Data Rate)
- Range: Up to 10 metres (Class 2)
- Baud Rate: Default 9600 bps, configurable up to 1382400 bps
- Operating Voltage: 3.3V (module), 3.6-6V (breakout board with regulator)
- Mode: Master or Slave (configurable via AT commands)
- Default PIN: 1234 or 0000
- Profiles: Serial Port Profile (SPP)
HC-05 vs HC-06: Which to Buy
| Feature | HC-05 | HC-06 |
|---|---|---|
| Modes | Master + Slave | Slave only |
| AT Commands | Full set (name, PIN, role, baud) | Limited (name, PIN, baud) |
| Auto-connect | Yes (master mode) | No |
| LED Indicator | Fast blink (searching), slow blink (connected) | Fast blink (searching), solid ON (connected) |
| Price (approx) | ₹150-250 | ₹100-180 |
Our recommendation: Always buy the HC-05. It can do everything the HC-06 does and more. The master mode capability lets you connect two Arduinos wirelessly without a phone in the middle — useful for remote sensor networks.
Wiring HC-05 to Arduino
| HC-05 Pin | Arduino Uno | Notes |
|---|---|---|
| VCC | 5V | Breakout board has regulator |
| GND | GND | Common ground |
| TXD | D10 (SoftwareSerial RX) | HC-05 TX to Arduino RX |
| RXD | D11 (SoftwareSerial TX) | Use voltage divider for 3.3V |
Voltage divider for RXD: The HC-05 RX pin operates at 3.3V. Connect a 1K resistor between Arduino TX (pin 11) and HC-05 RX, and a 2K resistor from HC-05 RX to GND. This creates a safe 3.3V signal level.
AT Command Mode Configuration
To configure the HC-05, you need to enter AT command mode. There are two ways:
Method 1: Press-and-Hold KEY Button
- Disconnect HC-05 power
- Press and hold the KEY/EN button on the module
- Reconnect power while holding the button
- The LED will blink slowly (every 2 seconds) indicating AT mode
- Release the button
In AT mode, the default baud rate is 38400 (not 9600!).
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10, 11); // RX, TX
void setup() {
Serial.begin(9600);
btSerial.begin(38400); // AT mode uses 38400
Serial.println("HC-05 AT Command Mode");
Serial.println("Type AT commands:");
}
void loop() {
if (btSerial.available()) Serial.write(btSerial.read());
if (Serial.available()) btSerial.write(Serial.read());
}
Useful AT Commands
AT → Test (returns OK)
AT+NAME=MyBot → Set Bluetooth name to "MyBot"
AT+PSWD="4321" → Change PIN to 4321
AT+UART=115200,0,0 → Set baud rate to 115200
AT+ROLE=0 → Set as Slave (default)
AT+ROLE=1 → Set as Master
AT+ADDR? → Show module's Bluetooth address
AT+RESET → Reset module
Sending Data: Arduino to Phone
Once the HC-05 is paired with your phone, data sent over Serial goes straight to the Bluetooth connection:
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10, 11);
float temperature = 0;
int lightLevel = 0;
void setup() {
Serial.begin(9600);
btSerial.begin(9600);
Serial.println("Bluetooth Sensor Monitor");
}
void loop() {
// Read sensors
temperature = analogRead(A0) * 0.48828; // LM35 sensor
lightLevel = analogRead(A1);
// Send to phone via Bluetooth
btSerial.print("TEMP:");
btSerial.print(temperature, 1);
btSerial.print(",LIGHT:");
btSerial.println(lightLevel);
// Also print to Serial Monitor
Serial.print("Temp: ");
Serial.print(temperature);
Serial.print("C, Light: ");
Serial.println(lightLevel);
delay(1000);
}
On Android, use the “Serial Bluetooth Terminal” app (free on Play Store) to view the incoming data. For a graphical dashboard, try “Bluetooth Electronics” or “RemoteXY”.
Receiving Commands: Phone to Arduino
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10, 11);
int ledPin = 13;
int relayPin = 7;
void setup() {
Serial.begin(9600);
btSerial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(relayPin, OUTPUT);
Serial.println("Bluetooth Home Control Ready");
}
void loop() {
if (btSerial.available()) {
char command = btSerial.read();
switch (command) {
case '1': // LED ON
digitalWrite(ledPin, HIGH);
btSerial.println("LED ON");
break;
case '0': // LED OFF
digitalWrite(ledPin, LOW);
btSerial.println("LED OFF");
break;
case 'A': // Relay ON (e.g., fan or light)
digitalWrite(relayPin, HIGH);
btSerial.println("Relay ON");
break;
case 'B': // Relay OFF
digitalWrite(relayPin, LOW);
btSerial.println("Relay OFF");
break;
default:
btSerial.print("Unknown: ");
btSerial.println(command);
}
}
}
Project: Bluetooth Robot Control
Here is a complete example for controlling a 2-wheel robot using an Android app:
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10, 11);
// Motor A (Left)
int enA = 5;
int in1 = 8;
int in2 = 9;
// Motor B (Right)
int enB = 6;
int in3 = 12;
int in4 = 4;
int speed = 200; // 0-255
void setup() {
btSerial.begin(9600);
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
analogWrite(enA, speed);
analogWrite(enB, speed);
}
void loop() {
if (btSerial.available()) {
char cmd = btSerial.read();
switch (cmd) {
case 'F': forward(); break;
case 'B': backward(); break;
case 'L': turnLeft(); break;
case 'R': turnRight(); break;
case 'S': stopMotors(); break;
case '1': speed = 100; updateSpeed(); break;
case '2': speed = 170; updateSpeed(); break;
case '3': speed = 255; updateSpeed(); break;
}
}
}
void forward() {
digitalWrite(in1, HIGH); digitalWrite(in2, LOW);
digitalWrite(in3, HIGH); digitalWrite(in4, LOW);
}
void backward() {
digitalWrite(in1, LOW); digitalWrite(in2, HIGH);
digitalWrite(in3, LOW); digitalWrite(in4, HIGH);
}
void turnLeft() {
digitalWrite(in1, LOW); digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH); digitalWrite(in4, LOW);
}
void turnRight() {
digitalWrite(in1, HIGH); digitalWrite(in2, LOW);
digitalWrite(in3, LOW); digitalWrite(in4, HIGH);
}
void stopMotors() {
digitalWrite(in1, LOW); digitalWrite(in2, LOW);
digitalWrite(in3, LOW); digitalWrite(in4, LOW);
}
void updateSpeed() {
analogWrite(enA, speed);
analogWrite(enB, speed);
}
Pair this with the “Arduino Bluetooth Controller” app on Android. Configure buttons to send F (forward), B (backward), L (left), R (right), and S (stop).
Frequently Asked Questions
Can I use HC-05 with iPhone?
No. The HC-05 uses Bluetooth Classic (SPP profile) which iOS does not support for third-party apps. For iPhone compatibility, use a BLE (Bluetooth Low Energy) module like the HM-10 or the ESP32’s built-in BLE.
What is the range of HC-05?
The HC-05 is a Class 2 Bluetooth device with a typical range of 10 metres. In open spaces without obstacles, you may get up to 20 metres. Walls and interference reduce this to 5-8 metres.
Can two HC-05 modules communicate without a phone?
Yes. Configure one HC-05 as Master (AT+ROLE=1) and bind it to the address of the second HC-05 (AT+BIND=address). They will auto-connect on power-up, creating a wireless serial bridge between two Arduinos.
Why does my HC-05 show as “paired” but not “connected”?
Pairing and connecting are different steps. After pairing (entering PIN 1234), you need to explicitly connect from your app. If the app cannot connect, check that the HC-05 is not in AT command mode (LED should blink fast, not slow).
How to change the default PIN from 1234?
Enter AT command mode and send: AT+PSWD="your_new_pin". The PIN must be exactly 4 digits. After changing, use AT+RESET to apply.
Conclusion
The HC-05 Bluetooth module is the simplest way to add wireless control to your Arduino projects. With a ₹200 module and a free Android app, you can build everything from Bluetooth-controlled robots to home automation systems. The master-slave capability of the HC-05 also enables Arduino-to-Arduino wireless communication without any phone involved.
Explore our full range of Bluetooth and wireless modules at Zbotic.in. We stock HC-05, HC-06, HM-10 BLE, and ESP32 boards with built-in Bluetooth for every project need.
Add comment