The HC-05 Bluetooth module is a widely-used wireless communication device that enables Bluetooth connectivity for electronic projects. It operates in both master and slave modes, allowing it to either initiate a connection or accept connections from other Bluetooth devices. This versatility makes it ideal for a range of applications, including robotics, home automation, and Internet of Things (IoT) projects.
Pin Number | Name | Type | Description |
---|---|---|---|
1 | KEY | Input | Module enters AT command mode when pulled HIGH |
2 | VCC | Power | Supply voltage (3.3V to 6V) |
3 | GND | Power | Ground |
4 | TXD | Output | Transmit Data (connect to RX of host device) |
5 | RXD | Input | Receive Data (connect to TX of host device) |
6 | STATE | Output | Indicates the connection status |
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup() {
pinMode(9, OUTPUT); // KEY pin if needed for AT commands
digitalWrite(9, HIGH); // Enable AT command mode
Serial.begin(9600);
BTSerial.begin(38400); // HC-05 default speed in AT command mode
Serial.println("Enter AT commands:");
}
void loop() {
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
Q: How do I change the baud rate of the HC-05?
A: Enter AT command mode and use the command AT+UART=<baud rate>,<stop bits>,<parity>
to set the desired baud rate.
Q: Can the HC-05 be used to communicate with smartphones? A: Yes, the HC-05 can communicate with smartphones that have Bluetooth capabilities.
Q: What is the default password for pairing the HC-05? A: The default password is usually '1234' or '0000'.