What the HC-05 is
The HC-05 is a Bluetooth Classic module with the Serial Port Profile (SPP): whatever it receives over the air comes out of its TX pin as plain serial data, and the other way round. For the Arduino it is just a serial port.
- The HC-06 works the same way for this use, but it can only wait for connections.
- Modules such as the HM-10 use Bluetooth Low Energy: they work differently and are not covered here.
- Range is about 10 m indoors.
Pins and voltages
The HC-05 is usually sold on a small board with six pins: EN (or KEY), VCC, GND, TXD, RXD and STATE. The board has its own regulator, so VCC goes to the Arduino's 5V.
The data pins, however, work at 3.3 V. The HC-05's TXD can go straight to the Arduino, which reads 3.3 V as HIGH. For the HC-05's RXD, it's recommended not to send the Arduino's 5 V directly: many tutorials connect it straight to the pin and it usually works, but it's outside the chip's specifications and in the long run the module can heat up or get damaged. A voltage divider with two resistors is enough.
5 V × 2 kΩ / (1 kΩ + 2 kΩ) ≈ 3.3 V
Wiring
Avoid D0 and D1: they are the USB serial port, and the HC-05 there would get in the way of uploads. Use two other pins with SoftwareSerial, for example D2 and D3, the same pins used by the Quasar web console. The library recreates a serial port in software: it switches the pin on and off with the exact timing of each bit and measures the incoming ones, so for the HC-05 nothing changes.
| HC-05 | Arduino Uno / Quasar Basic | Notes |
|---|---|---|
| VCC | 5V | The module has its own regulator |
| GND | GND | |
| TXD | D2 | The board's RX for Bluetooth |
| RXD | D3 through the divider | 1 kΩ from D3 to RXD, 2 kΩ from RXD to GND |
On a breadboard: put the 1 kΩ resistor between D3 and a free row, run the wire to RXD from that same row, and connect the 2 kΩ resistor from that row to GND. No 2 kΩ? Two 1 kΩ in series or a 2.2 kΩ work too.
The sketch
This sketch receives commands from Bluetooth and turns the LED on pin 13 on and off. It also passes everything to the USB serial monitor, which helps when testing.
#include <SoftwareSerial.h>
SoftwareSerial bt(2, 3); // RX on D2, TX on D3
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
bt.begin(9600); // HC-05 default speed
bt.println("Ready");
}
void loop() {
if (bt.available()) {
String cmd = bt.readStringUntil('\n');
cmd.trim();
Serial.println("Received: " + cmd);
if (cmd == "ON") { digitalWrite(13, HIGH); bt.println("LED ON"); }
if (cmd == "OFF") { digitalWrite(13, LOW); bt.println("LED OFF"); }
}
}
SoftwareSerial is reliable at 9600 baud. It cannot receive while it is sending, so keep messages short and don't flood the board with commands.
Pairing
- Power the board: the HC-05's LED blinks quickly while it waits for a connection.
- On the phone or computer, search for Bluetooth devices: the module usually appears as HC-05.
- Pair it with the PIN 1234 (on some modules 0000).
- Open a connection from an app or from the browser: when connected, the LED usually changes to slow double blinks.
Control it from a phone or the browser
- Android: any Bluetooth serial terminal app can send
ONandOFF. - Browser: Chrome and Edge can open Bluetooth serial ports with Web Serial (Chrome 117+ on computers, Chrome 137+ on Android). The Quasar web console uses exactly this: pins, PWM, servos and voice commands over the HC-05, with nothing to install.
- iPhone: iOS doesn't allow apps or browsers to use Bluetooth Classic serial modules, so the HC-05 can't be used from an iPhone.
Common problems
- Garbled characters: the speed doesn't match. The HC-05 uses 9600 baud by default.
- The board doesn't receive anything: TX and RX are swapped. The module's TXD goes to the board's RX pin (D2 in the sketch).
- Uploads fail: the HC-05 is on D0/D1. Move it to D2/D3.
- It connects but doesn't answer: check that the sketch uses the same pins as the wiring and that GND is shared.
- Changing name, PIN or speed: use AT commands. Hold the module's button while powering it on to enter AT mode (38400 baud), then send for example
AT+NAME=Quasar. The exact commands depend on the firmware version.
