Introduction
The HC-05 Bluetooth module is a widely used wireless communication component that enables seamless data transmission between microcontrollers and other Bluetooth-enabled devices. It operates using the Bluetooth 2.0+EDR (Enhanced Data Rate) standard, making it an ideal choice for short-range wireless communication in embedded systems, robotics, and IoT applications.
Overview of the HC-05 Bluetooth Module
The HC-05 module is a versatile Bluetooth Serial Port Protocol (SPP) device that can function in both master and slave modes. It facilitates wireless serial communication, making it a popular choice for Arduino, Raspberry Pi, and other microcontroller-based projects.
Key Features
- Bluetooth 2.0+EDR Standard: Ensures reliable wireless communication with a range of up to 10 meters.
- Master/Slave Mode: Can be configured as either a master or a slave device.
- Serial Communication: Uses UART with a default baud rate of 9600 bps.
- Low Power Consumption: Operates efficiently with a 3.3V to 5V power supply.
- Integrated LED Indicator: Shows module status and pairing state.
Pin Configuration of HC-05
The HC-05 Bluetooth module consists of six pins:
- VCC – Power supply (3.6V–6V, typically 5V)
- GND – Ground connection
- TXD – Transmit data pin (connects to RX of microcontroller)
- RXD – Receive data pin (connects to TX of microcontroller)
- STATE – Indicates connection status
- EN/KEY – Used to switch between command and data mode
Modes of Operation
The HC-05 operates in two primary modes:
- Data Mode – Used for normal wireless data transfer.
- Command Mode – Enables configuration of the module using AT commands.
AT Commands for Configuration
AT commands allow users to modify the settings of the HC-05 module. Some common AT commands include:
AT
– Checks communication with the module.AT+NAME=<desired_name>
– Changes the module’s Bluetooth name.AT+ROLE=<0/1>
– Sets the module as a slave (0) or master (1).AT+PSWD=<password>
– Sets a pairing password.
Applications of HC-05
- Wireless Data Transmission: Used for sending and receiving data between microcontrollers.
- Home Automation: Enables remote control of smart home devices.
- Robotics: Provides wireless control for robots.
- IoT Projects: Facilitates Bluetooth communication in Internet of Things applications.
- Wearable Technology: Used in smart wearable devices.
Interfacing HC-05 with Arduino
The HC-05 can be easily connected to an Arduino for wireless communication.
Wiring Diagram
HC-05 Pin | Arduino Pin |
---|---|
VCC | 5V |
GND | GND |
TXD | RX (D2) |
RXD | TX (D3) |
STATE | Not Used |
EN/KEY | Not Used |
Sample Arduino Code
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX, TX
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
}
void loop() {
if (BTSerial.available()) {
Serial.write(BTSerial.read());
}
if (Serial.available()) {
BTSerial.write(Serial.read());
}
}