Components · 6 min read

HC-05 Bluetooth Module: Control Your Arduino from Your Phone

How do you wire the HC-05 Bluetooth module? Pins and voltage divider, pairing with a phone, LED and relay control, AT commands, HC-05 vs HC-06 vs HM-10, iPhone compatibility, ESP32 and Pico.

The HC-05 is a cheap and very common Bluetooth module that adds wireless serial communication to Arduino projects. With it you can turn on an LED from your phone, switch a lamp on and off with a relay, drive a remote-controlled car or send sensor data to your phone. In this article you'll see step by step how to wire the HC-05 correctly and safely, pair it with your phone, write your first code and use the AT commands that change the module's settings.

HC-05 Bluetooth module and jumper wires
HC-05 Bluetooth module: the zigzag track at the top is the antenna, and on the left are 6 pins: EN, VCC, GND, TXD, RXD and STATE.

How does the HC-05 work?

The HC-05 uses classic Bluetooth's SPP (Serial Port Profile) and behaves like a "wireless serial cable". Once the phone is paired and connected, every character sent from the phone reaches the Arduino through the module's TXD pin, and everything the Arduino writes to the RXD pin goes to the phone. On the Arduino side you don't need to know anything about Bluetooth: you use Serial.print() and read() just as if you were talking to the Serial Monitor.

FeatureValue
Bluetooth version2.0 + EDR (classic, SPP)
Range~10 m in open space
Supply voltage3.6–6 V (the module board has a regulator)
Logic level3.3 V
Default baud rate9600 baud (38400 in AT mode)
Default PIN1234 or 0000
RoleMaster and slave

HC-05 vs HC-06 vs HM-10

ModuleBluetoothRolePinsiPhone
HC-052.0 classicMaster and slave6Doesn't work
HC-062.0 classicSlave only4Doesn't work
HM-104.0 BLEMaster and slave6Works
HC-06 Bluetooth module
HC-06 Bluetooth module: very similar to the HC-05 but with 4 pins, and it works as a slave only; that's enough for talking to a phone.
The HC-05 and HC-06 don't work with iPhones: iOS doesn't let ordinary apps open a classic Bluetooth serial connection. If you want to talk to an iPhone, use a BLE (Bluetooth Low Energy) module such as the HM-10, or an ESP32 with BLE. Android phones and computers connect to the HC-05 without any problems.

HC-05 pins and wiring

The module can be powered from 5V because there's a regulator on the board, but its data pins work at 3.3 V. The Arduino reads the 3.3 V signal from the HC-05's TXD pin without any trouble. In the other direction, instead of connecting the Arduino's 5 V TX signal straight to the module's RXD pin, use a voltage divider: Arduino TX → 1 kΩ → RXD, RXD → 2 kΩ → GND. That way about 3.3 V reaches RXD.

HC-05 pinFunctionArduino Uno
EN (KEY)Enter AT modeNot connected (3.3 V for AT mode)
VCCPower5V
GNDGroundGND
TXDModule's data outputD10 (SoftwareSerial RX)
RXDModule's data input (3.3 V)D11, through a 1 kΩ / 2 kΩ divider
STATEHIGH when connectedNot connected, or an input pin if you want
You can also connect the HC-05 to the Uno's pins 0 and 1, but those pins are also used for uploading code over USB, so uploading fails while the module is connected. Using pins 10 and 11 with SoftwareSerial keeps both uploading and the Serial Monitor free.

LED states and pairing with your phone

When you power the module, its LED blinks rapidly: that means it's waiting for a connection. In your Android phone's Bluetooth settings, find the device called "HC-05" and pair it using 1234 (or 0000 if that doesn't work) as the PIN. Pairing alone doesn't open a connection; a Bluetooth serial terminal app does that. Once connected, the LED gives two short blinks every 2 seconds. If the LED is on for 2 seconds and off for 2 seconds, the module is in AT command mode.

First communication with your phone

The code below turns the Arduino into a bridge between your phone and your computer: every character from the phone goes to the Serial Monitor, and everything you type in the Serial Monitor goes to the phone. It's the best starting point for testing the connection:

Arduino (C++)
1#include <SoftwareSerial.h>
2
3SoftwareSerial bt(10, 11);   // RX, TX → HC-05 TXD, RXD
4
5void setup() {
6  Serial.begin(9600);
7  bt.begin(9600);            // veri modu hızı / data mode baud rate
8}
9
10void loop() {
11  if (bt.available()) {
12    Serial.write(bt.read());   // telefondan bilgisayara / phone to PC
13  }
14  if (Serial.available()) {
15    bt.write(Serial.read());   // bilgisayardan telefona / PC to phone
16  }
17}

Upload the code and open the Serial Monitor at 9600 baud. On your phone, connect to the HC-05 with an app from Google Play such as Serial Bluetooth Terminal and type something: what you type will appear in the Serial Monitor. Text you type in the Serial Monitor also shows up on the phone. If this works, your connection, wiring and baud rate are all correct.

Controlling an LED and a relay from your phone

Now let's act on the characters coming from the phone: when 1 arrives the LED turns on, and when 0 arrives it turns off. The Arduino also sends a reply to the phone after each command:

Arduino (C++)
1#include <SoftwareSerial.h>
2
3SoftwareSerial bt(10, 11);   // RX, TX
4const int LED = 13;
5
6void setup() {
7  pinMode(LED, OUTPUT);
8  bt.begin(9600);
9  bt.println("Ready");
10}
11
12void loop() {
13  if (bt.available()) {
14    char c = bt.read();
15    if (c == '1') {
16      digitalWrite(LED, HIGH);   // LED'i yak / turn the LED on
17      bt.println("LED ON");
18    } else if (c == '0') {
19      digitalWrite(LED, LOW);    // LED'i söndür / turn the LED off
20      bt.println("LED OFF");
21    }
22  }
23}

Many Bluetooth apps let you assign any character you like to a button, so you can build a small remote with "On" and "Off" buttons on your phone. If you connect a relay module instead of the LED, the same code controls a lamp or a fan from your phone. Routing the characters F, B, L and R for forward, back, left and right to an L298N motor driver is also the basis of a Bluetooth-controlled car.

Changing the module's settings with AT commands

You can change the HC-05's name, PIN and baud rate with AT commands. To enter AT mode, power the module while holding down the small button on it (or with the EN pin connected to 3.3 V); the LED starts blinking slowly, once every 2 seconds. In the bridge code, write bt.begin(38400), set the line ending in the Serial Monitor to Both NL & CR and send the commands:

CommandFunction
ATConnection test, replies OK
AT+NAME=BlueGraysChanges the module's visible name
AT+PSWD="4321"Changes the PIN (without quotes on older versions)
AT+UART=9600,0,0Sets the baud rate in data mode
AT+ROLE=0Makes it a slave (1 makes it a master)
AT+VERSION?Shows the firmware version
AT+ORGLRestores the factory settings
On some HC-05 versions, a few AT commands (AT+NAME, for example) only reply if you hold the button down while sending the command. If you get OK for AT but no reply to some commands, try again while holding the button.

Bluetooth with the ESP32 and Raspberry Pi Pico

The classic ESP32 has both classic Bluetooth and BLE built in; with the BluetoothSerial library you can connect to your phone without an HC-05. The ESP32-S3 and ESP32-C3, however, only support BLE. The Raspberry Pi Pico W also has built-in Bluetooth. On the standard Raspberry Pi Pico without Bluetooth, you connect the HC-05 to the UART pins; because the Pico runs at 3.3 V, no voltage divider is needed this time. Power the module from the VBUS (5V) pin:

MicroPython
1from machine import UART, Pin
2
3bt = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))   # GP0 → RXD, GP1 ← TXD
4led = Pin("LED", Pin.OUT)                           # kart üstü LED / onboard LED
5
6while True:
7    if bt.any():
8        c = bt.read(1)
9        if c == b'1':
10            led.on()
11            bt.write(b'LED ON\n')
12        elif c == b'0':
13            led.off()
14            bt.write(b'LED OFF\n')

HC-05 project ideas

  • Bluetooth-controlled car: a robot driven from your phone with an L298N motor driver and two DC motors.
  • Smart home switch: turn lamps and sockets on and off from your phone with a relay module.
  • Colour picker lamp: set the colour of an RGB LED with values sent from your phone.
  • Wireless sensor display: send the temperature and humidity read from a DHT11 to the terminal on your phone.
  • Robot arm: control servo motors with sliders on your phone.
  • Communication between two Arduinos: make one HC-05 the master and the other the slave to send data wirelessly.

Common mistakes and how to fix them

  • The phone can't find the module: you're using an iPhone, the module is connected to another device, or it's stuck in AT mode.
  • Garbled characters arrive: the baud rates don't match; data mode usually uses 9600 and AT mode 38400.
  • No reply to AT commands: the module isn't in AT mode, the baud rate isn't 38400, or Both NL & CR isn't selected as the line ending.
  • The code won't upload: the module is connected to pins 0 and 1; unplug it while uploading or use SoftwareSerial.
  • The connection drops when the motors start: the motors disturb the power supply; power them from a separate source and add a capacitor to the module's supply.
  • The module failed after a while: 5 V may have been fed to the RXD pin without a divider; always use a 1 kΩ / 2 kΩ divider.

The HC-05 is the easiest way to take your wired projects wireless; combine it with motor control and you're ready to build your first remote-controlled robot. In the BlueGrays app you'll find a Bluetooth-controlled car with the L298N and an obstacle-avoiding robot, with circuit diagrams and code.

Frequently asked questions

Does the HC-05 work with an iPhone?

No. iOS doesn't let ordinary apps open the classic Bluetooth serial connection used by the HC-05 and HC-06. For an iPhone you should use a BLE module such as the HM-10, or an ESP32 with BLE.

What's the range of the HC-05?

About 10 metres in open space. Walls, metal surfaces and other wireless devices shorten that distance. Indoors it works reliably within the same room or the next room.

What's the difference between the HC-05 and the HC-06?

Both use classic Bluetooth. The HC-05 can be a master or a slave and has 6 pins; the HC-06 is slave only and usually has 4 pins. Either is enough for talking to a phone; to link two Arduinos you need at least one HC-05.

What's the HC-05's default PIN?

It's 1234 on most modules and 0000 on some. You can change it in AT mode with the AT+PSWD command; if you don't want others controlling your project, changing the default PIN is a good idea.

Can I make two Arduinos talk to each other with HC-05s?

Yes. Make one HC-05 the master with AT+ROLE=1 and give it the other module's address with the AT+BIND command; the second module stays a slave. On power-up the master connects to the slave automatically and the two Arduinos talk over the serial port.

Is a voltage divider on the RXD pin really necessary?

It's recommended. The HC-05's data pins work at 3.3 V; many modules survive 5 V for a while, but they can fail over time. A simple divider made of 1 kΩ and 2 kΩ resistors removes that risk. The TXD pin doesn't need a divider.

See all projects

Learn step by step how to connect the HC-05 Bluetooth module to Arduino safely, pair it with your phone, control an LED and a relay from your phone, and change its name and PIN with AT commands.