Bluetooth
Interfacing HC-05 Bluetooth Module with ESP32
What is the HC-05 Bluetooth Module?
HC-05 Bluetooth Module practical reference
What is the HC-05 Bluetooth module?
The HC-05 adds Bluetooth Classic serial communication to a microcontroller project. It exposes a UART interface on one side and a wireless Serial Port Profile (SPP) connection on the other, so bytes sent by a paired phone or computer can be read by your Arduino or ESP32 firmware. That makes it useful for robot commands, configuration tools, simple telemetry, and wireless serial debugging.
What you can—and cannot—do with it
Use an HC-05 when your project needs a transparent serial link to a compatible Bluetooth Classic SPP client, commonly an Android phone or a PC with a serial terminal. It does not provide Wi-Fi, and it is not a BLE module. iPhones and iPads generally cannot use the HC-05 through ordinary BLE apps because SPP is a Bluetooth Classic profile. If you need iOS support or a modern BLE app, choose a BLE-capable module or use the ESP32's built-in Bluetooth capability where suitable.
HC-05 pinout explained
- VCC: power input on the breakout. Many breakout boards accept about 5 V because they include a regulator; the bare radio module itself is a 3.3 V device. Verify the board you own.
- GND: common ground with the microcontroller.
- TXD: data transmitted by the HC-05; connect it to the host UART's RX pin.
- RXD: data received by the HC-05; connect it to the host UART's TX pin, but protect this 3.3 V input from a 5 V signal.
- KEY/EN: used to enter AT command mode on supported boards; the exact method depends on breakout and firmware.
- STATE: optional status output on some boards; it is not required for basic serial communication.
Electrical safety: the detail that matters most
The HC-05 breakout's VCC regulator does not mean its UART pins are 5 V tolerant. On a 5 V Arduino Uno, place a resistor divider or logic-level shifter between Uno TX and HC-05 RXD. A common divider uses 1 kΩ from the Uno TX signal to HC-05 RXD and 2 kΩ from HC-05 RXD to GND, reducing the 5 V signal to roughly 3.3 V. HC-05 TXD's 3.3 V output is normally read as HIGH by the Uno. With an ESP32, both sides use 3.3 V logic, so direct UART connections are usually appropriate.
Wiring overview
UART crosses over: module TXD → microcontroller RX, and microcontroller TX → module RXD. Connect GND to GND, and power the breakout according to its documentation. For the Arduino Uno example, use SoftwareSerial on pins 10 (RX) and 11 (TX); for ESP32, use UART2 on GPIO16 (RX2) and GPIO17 (TX2). These are example pin choices, not mandatory pins.
First connection: pair and test
- Upload the matching board example below.
- Power the HC-05 and wait for its status LED to indicate it is discoverable; blink patterns vary by firmware.
- On a compatible phone or PC, open Bluetooth settings and pair with the module. Many units ship with a default PIN such as 1234 or 0000, but this can vary and should be changed where the firmware supports it.
- Open a Bluetooth SPP serial-terminal app and connect to the paired device.
- Send a short line of text. The sample firmware forwards received Bluetooth bytes to the USB Serial Monitor and forwards USB serial input back to Bluetooth.
UART settings and AT command mode
Many HC-05 units use 9600 baud in data mode, but do not assume every board has the same configuration. AT command mode can use a different baud rate and may require holding KEY/EN high or pressing a breakout button while powering up. Commands and responses differ between firmware versions. Enter AT mode only using the procedure for your specific board, and verify the baud rate before troubleshooting normal data mode.
Common problems and fixes
- Pairs but sends no data: confirm the Bluetooth terminal is connected using SPP, check TX/RX crossover, and match the configured baud rate.
- No device appears: check power, wait for discoverability, and inspect the status LED; some units may already be connected to another host.
- Garbled characters: make sure the HC-05 UART baud rate matches the firmware's begin() setting.
- Uno resets or behaves unpredictably: check the power supply and avoid wiring the HC-05 RXD directly to a 5 V TX signal.
- AT commands fail: the module may not be in AT mode, or the firmware expects a different command-mode baud rate.
- Cannot connect from an iPhone: this is usually a Bluetooth Classic SPP compatibility limitation, not a wiring fault.
HC-05 vs HC-06 vs BLE modules
The HC-05 is commonly configurable as master or slave, depending on firmware; HC-06 modules are generally slave-only. Both are Bluetooth Classic serial modules. BLE modules such as HM-10-style devices use a different Bluetooth mode and application protocol, so code and phone-app compatibility are not interchangeable. Check the exact module revision before relying on master-mode support or a particular AT command.
Can the HC-05 be simulated?
A circuit simulator can help you practise the wiring and inspect the microcontroller-side UART code, but a normal Arduino circuit simulation does not reproduce real Bluetooth discovery, pairing, or an external phone's SPP connection unless it explicitly implements those behaviors. Treat a wiring-only simulation as a learning aid, not proof that wireless communication works. Validate pairing and two-way serial data with the physical module.
Project ideas
- Bluetooth-controlled robot with command characters such as F, B, L, R, and S.
- Wireless configuration menu for a standalone Arduino.
- Telemetry stream that sends sensor readings to an Android serial terminal.
- A PC-to-microcontroller serial bridge for short-range testing.
For motor projects, use a motor driver and a suitable external motor supply; do not power motors from the HC-05 or a microcontroller GPIO.
Quick checklist before powering up
- Confirm whether your breakout accepts 5 V at VCC.
- Protect HC-05 RXD from 5 V Uno TX logic.
- Cross TX and RX, and connect grounds together.
- Use the same UART baud rate at both ends.
- Pair using a Bluetooth Classic SPP-compatible client.
- Test real wireless behavior on hardware; wiring simulation alone cannot verify pairing.
Key specifications
- Bluetooth type: Bluetooth Classic with Serial Port Profile (SPP), not Bluetooth Low Energy.
- Host interface: UART serial; TX/RX must be crossed between module and controller.
- UART logic: The bare radio module uses 3.3 V logic; protect RXD from 5 V Arduino TX signals.
- Breakout power: Many breakout boards accept 5 V at VCC via onboard regulation, but the exact board must be checked.
- Common data baud: 9600 baud is common in data mode; configuration varies by firmware and module.
- Client compatibility: Use a Bluetooth Classic SPP-compatible client; ordinary BLE-only apps and iOS SPP support are not interchangeable.
Pinout and connection notes
The HC-05 is Bluetooth Classic SPP, not BLE. Many breakout boards accept 5 V at VCC, but UART RXD remains a 3.3 V logic input unless the board explicitly includes level shifting. Verify your exact board and use a compatible client.
- Power: Breakout input voltage is board-dependent; follow the exact module documentation.
- Ground: Common ground with the host controller.
- UART transmit: Connect to the controller UART RX input.
- UART receive: Connect to the controller UART TX output through suitable level shifting if the host is 5 V logic.
- Mode control: Optional; AT-command-mode entry depends on breakout and firmware revision.
- Connection status: Optional status output on some breakout variants.
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up HC-05 Bluetooth Module with ESP32
Library
HardwareSerial by Espressif (built-in)
Built into the ESP32 Arduino core — no install needed
Wiring
| Component pin | ESP32 pin | Note |
|---|---|---|
| VCC | 3.3V | Confirm your HC-05 breakout accepts 3.3V — most do, but a few need 5V via a separate regulator |
| GND | GND | |
| TXD | GPIO16 (RX2) | HC-05 TXD → ESP32 RX2 |
| RXD | GPIO17 (TX2) | ESP32 GPIO is 3.3V logic, so this pairs directly with HC-05 RXD — no divider needed |
Swipe sideways to see every column →
ESP32 already has WiFi + BLE onboard, so HC-05 (classic Bluetooth SPP) is mainly useful here if you specifically need Serial Bluetooth compatibility with an existing phone app. For new projects, the ESP32's built-in BLE is usually a better fit and needs no extra module.
Related Components
CC2530
Mesh-networking Zigbee radio module for home-automation sensors.
ESP 01
Minimal ESP8266 breakout for adding Wi-Fi to any microcontroller.
ESP8266 Module
General-purpose ESP8266 breakout with more accessible GPIO.
HC 06
Slave-only Bluetooth serial module — simpler and cheaper than HC-05 for one-way connections.
Related Guides & Projects
MicroPython vs Arduino on ESP32: Which Should You Learn First?
An honest comparison for beginners: where MicroPython is easier, where Arduino C++ is faster, how libraries and memory differ, and how to choose based on your project instead of hype.
MicroPython ESP32 Web Server: Control an LED or Relay from Your Browser
Create a working web server with the socket module, parse requests, serve a responsive control page for an LED or a relay, keep the displayed state truthful, choose a safe relay startup state and make the server survive bad or repeated requests.
MicroPython on ESP32 and Raspberry Pi Pico W: The Complete Guide
A structured MicroPython learning path for ESP32 and Pico W. Set up your tools, control GPIO, read sensors, connect to WiFi, build web servers, publish MQTT data and make projects reliable. Start here, then follow the links by level.
boot.py vs main.py in MicroPython: What Runs, When and Why
Understand the difference between boot.py and main.py in MicroPython, startup order, Wi-Fi setup, project structure, and recovery from boot errors.