HC05 Bluetooth Module
The HC-05 Bluetooth Serial Communication Module is a data transmission module based on Bluetooth Specification V2.0 with EDR Bluetooth protocol. It operates in the 2.4GHz ISM wireless frequency band and uses GFSK modulation. The module has a maximum transmission power of 4dBm and a reception sensitivity of -85dBm. It features an onboard PCB antenna that allows for communication over a distance of up to 10 meters. The module uses a stamp hole package, with dimensions of 27mm×13mm×2mm, making it easy for customers to integrate it into application systems. It also has a built-in LED light to visually indicate the Bluetooth connection status. The module uses the CSR BC417 chip and supports AT commands, allowing users to modify parameters such as role (master/slave mode), serial baud rate, device name, and more, providing flexible usage.
Module Source
Specifications
Operating Voltage:3.6-6V
Operating Current:40mA
Transmission Range:4dBm(Maximum)
Reception Range: 10 meters
Control Method: Serial Interface
Pin Count: 6 Pin (2.54mm pitch header)
Instructions for Use:
Before using the HC05 Bluetooth module, you need to know its baud rate so you can control it. Connect the Bluetooth module development board, with the Bluetooth module's TX connected to the development board's TX, and RX connected to RX. Before inserting it into the computer, press and hold the button on the module, then power it on. After inserting the module into the computer and powering it on, the LED on the module will blink slowly, indicating that the HC-05 has entered AT command mode. The default baud rate is 38400. This mode is called the "Original Mode." In this mode, the module remains in AT command mode.
After entering AT command mode, the main task is to set the module to slave mode, meaning it will wait for the phone to connect to the Bluetooth module and be controlled by the phone. When sending commands, it’s important to remember that each command must be followed by \r\n or check the option to "Send New Line." Otherwise, the command won't be recognized.
Key Command Descriptions
Test Commands:
Command | Response | Parameters |
---|---|---|
AT | OK | None |
Set/Query - Module Role:
Set/Query - Serial Parameters:
After completing the configuration, power off the Bluetooth module and then power it back on. The LED on the module will blink quickly, indicating it is in normal working mode. Turn on the Bluetooth on your phone and search for devices. You should see the Bluetooth module named "HC-05." When connecting, you'll need to enter the PIN code, which we previously checked in AT mode and is set to 1234.
After successfully connecting to the phone, the LED on the module will blink slowly, indicating the connection has been established. Next, open a Bluetooth communication app on your phone and test whether you can transfer data between the phone and the computer.
Hardware Connection
- HC-05 VCC connects to the 5V pin of the development board.
- HC-05 GND connects to the GND pin of the development board.
- HC-05 TXD connects to pin 2 of the development board.
- HC-05 RXD connects to pin 3 of the development board.
Usage Method
The following simple example demonstrates how to configure the development board to listen to the HC-05 module via the serial port. When data is received from a paired device, the development board will send the received data back (echo test).
Note: Make sure the baud rate of the Bluetooth module is not set to 115200 or higher, as communication will not work.
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 11, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <SoftwareSerial.h>
// Pin2为RX,接HC05的TXD
// Pin3为TX,接HC05的RXD
SoftwareSerial BT(2, 3);
char val;
void setup() {
pinMode(2,INPUT);
pinMode(3,OUTPUT);
Serial.begin(9600);
Serial.println("BT is ready!");
BT.begin(9600);
}
void loop() {
//将串口调试助手上的数据通过蓝牙发送到手机APP
if (Serial.available()) {
val = Serial.read();
BT.print(val);
}
//将手机上蓝牙APP发送过来的数据通过蓝牙发送到串口调试助手
if (BT.available()) {
val = BT.read();
Serial.print(val);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Usage Testing
Send 'hello lckfb' with phone, and receive 'hello'