Adding wireless control to your Arduino projects is easier than ever with Arduino Bluetooth modules like the HC-05 and HC-06. These affordable serial Bluetooth modules let you send data between your Arduino and a smartphone over a range of up to 10 metres, opening up projects like wireless sensor dashboards, Bluetooth-controlled robots, and DIY smart home remotes. In this complete setup guide, we cover the differences between HC-05 and HC-06, full wiring instructions, AT command configuration, and step-by-step code for controlling LEDs and building a Bluetooth-controlled robot.
Table of Contents
HC-05 vs HC-06: Key Differences
Both HC-05 and HC-06 are UART (serial) Bluetooth 2.0 Classic modules that look similar from the outside. They use the same wiring and very similar code. However, there are important functional differences that affect which one you should choose for your project.
| Feature | HC-05 | HC-06 |
|---|---|---|
| Role | Master, Slave, or both (configurable) | Slave only |
| AT command mode | Dedicated EN/KEY pin required | AT mode when no device is connected |
| Pins | 6 pins (VCC, GND, TX, RX, STATE, EN/KEY) | 4 or 6 pins (VCC, GND, TX, RX + optional) |
| Default baud rate | 38400 (AT mode), 9600 (data mode) | 9600 in all modes |
| Default PIN | 1234 | 1234 |
| Price | Slightly higher | Slightly lower |
| Best for | Arduino-to-Arduino wireless, complex setups | Phone-to-Arduino control (most projects) |
| Complexity | More complex AT configuration | Simpler for beginners |
For most beginner and intermediate projects — controlling a robot, sending sensor data to a phone, or building a Bluetooth dashboard — the HC-06 is the easier choice. It pairs as a slave device to your phone without extra configuration steps. The HC-05 is the better choice when you need two Arduinos to communicate wirelessly (one as master, one as slave) or when you need to change settings while a device is connected.
Wiring to Arduino
The HC-05/HC-06 communicates via UART serial. The critical thing to remember is that the TX pin of the module connects to the RX pin of the Arduino, and vice versa (TX-to-RX, RX-to-TX). This is called cross-connecting and it trips up many beginners.
Voltage note: The HC-05/HC-06 VCC pin accepts 3.6-6V. The logic pins (TX/RX) are 3.3V — but the module’s RX pin can usually tolerate 5V from the Arduino TX. However, the module’s TX outputs 3.3V, which Arduino reads correctly as HIGH. The standard practice is to add a voltage divider (1kΩ and 2kΩ resistors) on the Arduino-TX-to-module-RX line, though many modules work at 5V directly. For maximum reliability, use the voltage divider.
Basic 4-wire connection (HC-06 or HC-05 data mode):
- Module VCC to Arduino 5V
- Module GND to Arduino GND
- Module TX to Arduino Pin 10 (SoftwareSerial RX)
- Module RX to Arduino Pin 11 (SoftwareSerial TX) — via 1kΩ/2kΩ voltage divider for safety
We use SoftwareSerial (pins 10 and 11) instead of the hardware UART (pins 0 and 1) so that the USB connection for programming and the Bluetooth module do not interfere with each other. If you use hardware serial pins (0 and 1), you must disconnect the Bluetooth module every time you upload code.
Voltage divider for Arduino TX to module RX:
- Arduino Pin 11 (TX) to 1kΩ resistor
- Other end of 1kΩ to module RX pin and to 2kΩ resistor
- Other end of 2kΩ to GND
- This divides 5V to ~3.3V at the module RX pin
AT Commands for Configuration
AT commands let you change the module name (what appears on your phone’s Bluetooth scan), the pairing PIN, and the baud rate. You send AT commands through the Arduino’s serial monitor while the module is in command mode, not connected to any device.
Entering AT Mode
HC-06: AT mode is automatic when no device is paired. Just power up the module without any phone connected. The red LED blinks rapidly. Connect it to Arduino via SoftwareSerial and send AT commands at 9600 baud. No special pin manipulation needed.
HC-05: Hold the button (EN/KEY pin HIGH) while powering on. The LED blinks slowly (about once per 2 seconds), indicating AT mode. AT command baud rate is 38400 for HC-05, not 9600.
Use this sketch to send AT commands from Serial Monitor:
#include <SoftwareSerial.h>
// RX=10 (from module TX), TX=11 (to module RX)
SoftwareSerial btSerial(10, 11);
void setup() {
Serial.begin(9600); // USB Serial Monitor
btSerial.begin(9600); // HC-06 AT mode baud = 9600
// For HC-05 AT mode, use btSerial.begin(38400);
Serial.println("AT Command Mode - type commands below:");
}
void loop() {
// Relay from Serial Monitor to Bluetooth module
if (Serial.available()) {
btSerial.write(Serial.read());
}
// Relay responses from module to Serial Monitor
if (btSerial.available()) {
Serial.write(btSerial.read());
}
}
Open Serial Monitor at 9600 baud. Set line ending to “Both NL & CR”. Then type these commands:
| Command | Response | Purpose |
|---|---|---|
AT |
OK | Test communication (always try this first) |
AT+NAME=ZboticBT |
OKsetname | Set device name to ZboticBT |
AT+PIN=0000 |
OKsetPIN | Change pairing PIN to 0000 |
AT+BAUD4 |
OK9600 | Set baud rate to 9600 (HC-06 uses BAUD1-8) |
AT+VERSION |
OKlinvorV1.8 | Check firmware version |
For HC-05, the commands are slightly different: AT+NAME? queries the name, AT+NAME=ZboticBT sets it. HC-05 AT commands end with CR+LF.
Pairing with Your Phone
Once configured, pairing is straightforward:
- Power on the Arduino with the Bluetooth module connected
- Open your phone’s Bluetooth settings
- Scan for devices — you should see your module name (default: HC-06 or linvor, or whatever you set with AT+NAME)
- Tap to pair — enter PIN 1234 (default) or whatever you set with AT+PIN
- The LED on the module changes from rapid blinking to slow double-blink, confirming a successful connection
On Android phones, HC-05/HC-06 pair as serial port profile (SPP) devices. You use a Bluetooth terminal app to send and receive text data to/from your Arduino sketch. On iPhones, standard Bluetooth Classic (HC-05/HC-06) is NOT supported – these modules do not work with iPhones. iPhone users need BLE (Bluetooth Low Energy) modules like the HM-10 or CC2541 instead.
Controlling LED via Bluetooth
The classic first Bluetooth project is controlling an LED from your phone. Wire an LED with 220 ohm resistor to Pin 13. Upload this sketch, pair your phone, open a Bluetooth terminal app, and send ‘1’ to turn on or ‘0’ to turn off.
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10, 11); // RX=10, TX=11
const int LED_PIN = 13;
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
btSerial.begin(9600);
Serial.println("Bluetooth LED Control Ready");
Serial.println("Send '1' to turn LED ON, '0' to turn OFF");
}
void loop() {
if (btSerial.available()) {
char received = btSerial.read();
Serial.print("Received: ");
Serial.println(received);
if (received == '1') {
digitalWrite(LED_PIN, HIGH);
btSerial.println("LED ON");
} else if (received == '0') {
digitalWrite(LED_PIN, LOW);
btSerial.println("LED OFF");
} else if (received == 't') {
// Toggle
bool state = digitalRead(LED_PIN);
digitalWrite(LED_PIN, !state);
btSerial.println(state ? "LED OFF" : "LED ON");
}
}
}
Extend this to control multiple LEDs or a relay module by adding more channels:
// Multi-device Bluetooth control
// '1'/'q' = LED 1 on/off, '2'/'w' = LED 2 on/off
// '3'/'e' = relay on/off, 'x' = all off
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10, 11);
const int devices[] = {6, 7, 8}; // LED1, LED2, Relay
void setup() {
for (int pin : devices) {
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
}
btSerial.begin(9600);
}
void loop() {
if (btSerial.available()) {
char c = btSerial.read();
switch (c) {
case '1': digitalWrite(devices[0], HIGH); break;
case 'q': digitalWrite(devices[0], LOW); break;
case '2': digitalWrite(devices[1], HIGH); break;
case 'w': digitalWrite(devices[1], LOW); break;
case '3': digitalWrite(devices[2], HIGH); break;
case 'e': digitalWrite(devices[2], LOW); break;
case 'x':
for (int pin : devices) digitalWrite(pin, LOW);
btSerial.println("All OFF");
break;
}
}
}
Bluetooth Robot Control
Combining an HC-06 with an L298N motor driver and a 2WD or 4WD robot chassis is one of the most popular Arduino projects in India. Here is the motor control logic using directional commands sent from a phone app:
// Bluetooth Robot - receives F/B/L/R/S commands
// Motor driver: L298N (or L293D)
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10, 11);
// L298N Motor A
const int ENA = 5; // PWM speed
const int IN1 = 4;
const int IN2 = 3;
// L298N Motor B
const int ENB = 6; // PWM speed
const int IN3 = 7;
const int IN4 = 8;
int motorSpeed = 180; // 0-255 PWM value
void setup() {
int pins[] = {ENA, IN1, IN2, ENB, IN3, IN4};
for (int p : pins) pinMode(p, OUTPUT);
btSerial.begin(9600);
stopMotors();
}
void moveForward() {
analogWrite(ENA, motorSpeed); analogWrite(ENB, motorSpeed);
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
}
void moveBackward() {
analogWrite(ENA, motorSpeed); analogWrite(ENB, motorSpeed);
digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
}
void turnLeft() {
analogWrite(ENA, motorSpeed); analogWrite(ENB, motorSpeed);
digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
}
void turnRight() {
analogWrite(ENA, motorSpeed); analogWrite(ENB, motorSpeed);
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
}
void stopMotors() {
analogWrite(ENA, 0); analogWrite(ENB, 0);
}
void loop() {
if (btSerial.available()) {
char cmd = btSerial.read();
switch (cmd) {
case 'F': case 'f': moveForward(); break;
case 'B': case 'b': moveBackward(); break;
case 'L': case 'l': turnLeft(); break;
case 'R': case 'r': turnRight(); break;
case 'S': case 's': stopMotors(); break;
}
}
}
Recommended Apps for Bluetooth Control
Several free Android apps work well with HC-05/HC-06 for Arduino projects. Here are the best options available in India:
| App Name | Best For | Notes |
|---|---|---|
| Serial Bluetooth Terminal | Text data, debugging, initial testing | Best for raw serial communication and testing |
| Bluetooth RC Controller | Robot car control | Sends F/B/L/R/S commands, designed for robot projects |
| Arduino Bluetooth Controller | Button-based device control | Configurable button labels and sent characters |
| MIT App Inventor (custom) | Custom UI with sliders and buttons | Free drag-and-drop app builder, very popular in Indian colleges |
| Bluetooth Terminal HC-05 | General purpose terminal | Good for AT command testing and data logging |
For educational projects and college assignments, MIT App Inventor is particularly popular because it lets students create fully custom Android apps with a visual programming interface, without writing Java or Kotlin code. You can create a professional-looking control panel for your Bluetooth Arduino project in under an hour.
Frequently Asked Questions
Q: Does HC-05 or HC-06 work with iPhone?
No. HC-05 and HC-06 use Bluetooth Classic (SPP profile) which Apple restricts to licensed MFi accessories. iPhones only support BLE (Bluetooth Low Energy) for third-party apps. If you need iOS compatibility, use a BLE module like the HM-10 (CC2541 chip) instead, which works with iOS apps through the BLE UART profile.
Q: My Arduino does not receive anything from the phone. What should I check?
Check in this order: (1) confirm the TX/RX are crossed correctly (module TX to Arduino RX pin, module RX to Arduino TX pin), (2) verify baud rates match in both the module and your SoftwareSerial.begin() call, (3) ensure the LED on the module shows connected status (steady or slow blink), (4) try sending from a different app like Serial Bluetooth Terminal which shows exactly what is being sent and received.
Q: Can I use HC-05/HC-06 with an ESP32 or NodeMCU?
Yes, but ESP32 has built-in Bluetooth Classic and BLE, so adding HC-05/HC-06 is redundant. Use the ESP32’s native Bluetooth via the BluetoothSerial library instead – it is simpler, cheaper (no extra module), and supports more features. If you already have HC-05/HC-06 modules, they work fine with ESP32’s hardware serial or SoftwareSerial on 3.3V I/O pins.
Q: How far can HC-05/HC-06 transmit?
In open air with no obstructions, the range is typically 10-15 metres. Inside rooms with walls, expect 5-10 metres. The Class 2 power level of these modules is the limiting factor. For longer range indoor Bluetooth, look at HC-10 or similar modules with Class 1 power ratings. For distances beyond 50 metres, Wi-Fi (ESP8266/ESP32) or LoRa is more appropriate.
Ready to Build Your Next Arduino Project?
Shop sensors, modules, and components at Zbotic.in – India’s trusted electronics store with fast shipping across India.
Add comment