HC-05 Serial Bluetooth Module
Bluetooth is a technology for wireless communication. It is designed to replace cable connections.It uses serial communication to communicate with devices. It communicates with microcontroller using serial port (USART). Usually, it connects small devices like mobile phones, PDAs and TVs using a short-range wireless connection to exchange documents. It uses the 2.45GHz frequency band. The connection can be point-to-point or multi-point where the maximum range is 10 meters. The transfer rate of the data is 1Mbps.
HC-05 Bluetooth module provides switching mode between master and slave mode which means it able to use neither receiving nor transmitting data.
Comparing it to the HC-06 module, which can only be set as a Slave, the HC-05 can be set as Master as well which enables making a communication between two separate Arduino Boards.
You can use Bluetooth module simply for a serial port replacement to establish connection between MCU, PC to your embedded project and etc.
- Bluetooth protocol: Bluetooth Specification v2.0+EDR
- Frequency: 2.4GHz ISM band
- Modulation: GFSK(Gaussian Frequency Shift Keying)
- Emission power: ≤4dBm, Class 2
- Sensitivity: ≤-84dBm at 0.1% BER
- Speed: Asynchronous: 2.1Mbps(Max) / 160 kbps, Synchronous: 1Mbps/1Mbps
- Security: Authentication and encryption
- Profiles: Bluetooth serial port
- Power supply: +3.3VDC 50mA
- Working temperature: -20 ~ +75Centigrade
- Dimension: 26.9mm x 13mm x 2.2 mm
- It is IEEE 802.15.1 standardized protocol, through which one can build wireless Personal Area Network (PAN). It uses frequency-hopping spread spectrum (FHSS) radio technology to send data over air.
It has 6 pins,
1.Key/EN:It is used to bring Bluetooth module in AT commands mode. By default this pin operates in data mode. Key/EN pin should be high to operate Bluetooth in command mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in data mode.HC-05 module has two modes,
- Data mode: Exchange of data between devices. Baud rate is 9600bps in data mode.
- Command mode: It uses AT commands which are used to change setting of HC-05. Baud rate is 38400bps in command mode.
2. VCC: Connect 5 V or 3.3 V to this Pin.
3. GND: Ground Pin of module.
4. TXD: Connect with Microcontroller RXD pin of Microcontroller. Transmit Serial data (wirelessly received data by Bluetooth module transmitted out serially on TXD pin)
5. RXD: Connect with Microcontroller TXD pin of Microcontroller. Received data will be transmitted wirelessly by Bluetooth module.
6. State: It tells whether module is connected or not. It acts as a status indicator.
For HC-05 Bluetooth Hardware Package details you can refer the document which we have provided at the end of article.
HC- 05 vs HC-06
|Master and slave mode can be switched||Master and slave mode can’t be switched|
|Bluetooth name: HC-05||Bluetooth name: linvor|
|Master role: have no function to remember the last paired salve device. It can be made paired to any slave device.||Master role: have paired memory to remember last slave device and only make pair with that device unless KEY (PIN26) is triggered by high level. The default connected PIN26 is low level.|
|KEY: PIN34, for entering to the AT mode.||KEY: PIN26, for master abandons memory.|
| Default communication baud rate: 9600,
4800-1.3M are settable.
|Default communication baud rate: 9600, 1200-1.3M are settable.|
|During the communication mode, by setting PIN34 to high the module can enter to the AT mode.||During the communication mode, the module can’t enter to the AT mode.|
|Pairing: Master device can’t only make pair with the specified Bluetooth address, it can also search and make pair with
the slave device automatically.
|Pairing: Master device search and make pair with the slave device automatically.|
Connecting HC-05 with Microcontroller
- Connect Power Supply(based on datasheet of modules) for Bluetooth and Microcontroller which you are using.
- Connect TXD pin of HC-05 Bluetooth module to RXD pin of Microcontroller.
- Connect RXD pin of HC-05 Bluetooth module to TXD pin of Microcontroller.
- Common grounding should be needed for both modules.
- Computer and peripheral devices
- GPS receiver
- Industrial control
- MCU projects
Modes of Operation
1. How to get to the AT Mode
a) Way 1:
- Step 1: Input low level to PIN34.
- Step 2: Supply power to the module.
- Step 3: Input high level to the PIN34. Then the module will enter to AT mode. The baud rate is as same as the communication time, such as 9600 etc.
b) Way 2:
- Step 1: Connect PIN34 to the power supply PIN.
- Step 2: Supply power to module (the PIN34 is also supplied with high level since the PIN34 is connected with power supply PIN). Then the module will enter to AT module. But at this time, the baud rate is 38400. In this way, user should change the baud rate at the AT mode, if they forget the communication baud rate.
How to get to the communication mode
- Step 1: Input low level to PIN34.
- Step 2: Supply power to the module. Then the module will enter to communication mode. It can be used for pairing.
2. How to set this module be the Master Role
- Step 1: Input high level to PIO11.
- Step 2: Supply power to the module. And the module will enter to the order-response work mode.
- Step 3: Set the parameters of the super terminal or the other serial tools (baud rate: 38400, data bit:8, stop bit:1, no parity bit, no Flow Control)
- Step 4: Sent the characters “AT+ROLE=1\r\n” through serial, then receive the characters “OK\r\n”. Here, “\r\n” is the CRLF.
- Step 5: Input low level to PIO, and supply power to the module again. Then this module will become master role and search the other module (slave role) automatically to build the connection.
- HC-03 and HC-05’s command should end up with “\r\n”. It’s different from HC-04 and HC-06 (They don’t need terminator).
- The most common commands for HC-03 and HC-05 are: AT+ROLE (set master –slave), AT+CMODE( set address pairing) , AT+PSWD (set password). If you want the master module has the function of remembering slave module, the most simply way is: First, set AT+CMODE=1. Make the master module pair with the slave module. Second, set AT+CMODE=0. Then the master module just can make pair with that specified slave module.
- When PIN34 keeps high level, all commands can be used. Otherwise, only some of them can be used.