Introduction
- It is used for many applications like wireless headset, game controllers, wireless mouse, wireless keyboard, and many more consumer applications.
- It has range up to <100m which depends upon transmitter and receiver, atmosphere, geographic & urban conditions.
- 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 uses serial communication to communicate with devices. It communicates with microcontroller using serial port (USART).
HC-05 Bluetooth Module
- HC-05 is a Bluetooth module which is designed for wireless communication. This module can be used in a master or slave configuration.
HC-05 Bluetooth Module Pin Diagram
Bluetooth serial modules allow all serial enabled devices to communicate with each other using Bluetooth.
It has 6 pins,
1. Key/EN: It is used to bring Bluetooth module in AT commands mode. If Key/EN pin is set to high, then this module will work in command mode. Otherwise by default it is in data mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in data mode.
HC-05 module has two modes,
1. Data mode: Exchange of data between devices.
2. Command mode: It uses AT commands which are used to change setting of HC-05. To send these commands to module serial (USART) port is used.
2. VCC: Connect 5 V or 3.3 V to this Pin.
3. GND: Ground Pin of module.
4. TXD: Transmit Serial data (wirelessly received data by Bluetooth module transmitted out serially on TXD pin)
5. RXD: Receive data serially (received data will be transmitted wirelessly by Bluetooth module).
6. State: It tells whether module is connected or not.
HC-05 module Information
- HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds.
- This module works on 3.3V. We can connect 5V supply voltage as well since the module has on board 5 to 3.3 V regulator.
- As HC-05 Bluetooth module has 3.3V level for RX/TX and microcontroller can detect 3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit voltage level from microcontroller to RX of HC-05 module.
- The data transfer rate of HC-05 module can vary up to 1Mbps is in the range of 10 meters.
Specification of HC-05 Bluetooth Module
- Bluetooth version: 2.0 + EDR (Enhanced Data Rate)
- Frequency: 2.4 GHz ISM band
- Modulation: GFSK (Gaussian Frequency Shift Keying)
- Transmit power: Class 2 (up to 4 dBm)
- Sensitivity: -80 dBm typical
- Range: approximately 10 meters (or 33 feet) in open air
- Profiles supported: SPP (Serial Port Profile), HID (Human Interface Device) and others
- Operating voltage: 3.3V to 5V DC
- Operating current: less than 50mA
- Standby current: less than 2.5mA
- Sleep current: less than 1mA
- Interface: UART (Universal Asynchronous Receiver/Transmitter)
- Baud rates: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, and 460800
- Operating temperature: -20°C to 75°C (-4°F to 167°F)
Bluetooth communication between Devices
E.g. Send data from Smartphone terminal to HC-05 Bluetooth module and see this data on PC serial terminal and vice versa.
To communicate smartphone with HC-05 Bluetooth module, smartphone requires Bluetooth terminal application for transmitting and receiving data. You can find Bluetooth terminal applications for android and windows in respective app. store.
So, when we want to communicate through smartphone with HC-05 Bluetooth module, connect this HC-05 module to the PC via serial to USB converter.
Before establishing communication between two Bluetooth devices, 1st we need to pair HC-05 module to smartphone for communication.
Pair HC-05 and smartphone:
- Search for new Bluetooth device from your phone. You will find Bluetooth device with “HC-05” name.
- Click on connect/pair device option; default pin for HC-05 is 1234 or 0000.
After pairing two Bluetooth devices, open terminal software (e.g. Teraterm, Realterm etc.) in PC, and select the port where we have connected USB to serial module. Also select default baud rate of 9600 bps.
In smart phone, open Bluetooth terminal application and connect to paired device HC-05.
It is simple to communicate, we just have to type in the Bluetooth terminal application of smartphone. Characters will get sent wirelessly to Bluetooth module HC-05. HC-05 will automatically transmit it serially to the PC, which will appear on terminal. Same way we can send data from PC to smartphone.
Command Mode
- When we want to change settings of HC-05 Bluetooth module like change password for connection, baud rate, Bluetooth device’s name etc.
- To do this, HC-05 has AT commands.
- To use HC-05 Bluetooth module in AT command mode, connect “Key” pin to High (VCC).
- Default Baud rate of HC-05 in command mode is 38400bps.
- Following are some AT command generally used to change setting of Bluetooth module.
- To send these commands, we have to connect HC-05 Bluetooth module to the PC via serial to USB converter and transmit these command through serial terminal of PC.
Command | Description | Response |
AT | Checking communication | OK |
AT+PSWD=XXXX | Set Password e.g. AT+PSWD=4567 | OK |
AT+NAME=XXXX | Set Bluetooth Device Name e.g. AT+NAME=MyHC-05 | OK |
AT+UART=Baud rate, stop bit, parity bit | Change Baud rate e.g. AT+UART=9600,1,0 | OK |
AT+VERSION? | Respond version no. of Bluetooth module | +Version: XX OK e.g. +Version: 2.0 20130107 OK |
AT+ORGL | Send detail of setting done by manufacturer | Parameters: device type, module mode, serial parameter, passkey, etc. |
Alternate options for HC-05 Bluetooth Module
- HC-06 Bluetooth module: This is a similar module to the HC-05, but it is limited to a slave role only. It has a smaller form factor and is generally cheaper than the HC-05. However, it does not support some of the advanced features of the HC-05, such as the ability to enter AT mode to configure the module.
- HM-10 Bluetooth module: This is a more advanced Bluetooth module that supports Bluetooth 4.0 (BLE) and can act as both a master and slave device. It also supports a wider range of AT commands for configuring the module, and has a longer range than the HC-05. However, it is generally more expensive than the HC-05.
- RN-42 Bluetooth module: This is another Bluetooth module that supports both the SPP and HID profiles, similar to the HC-05. It has a longer range than the HC-05 and supports faster data rates. However, it is also more expensive and may require additional configuration to work properly.
- ESP32 Bluetooth module: This is a powerful Wi-Fi and Bluetooth module that includes a dual-core processor and support for both Bluetooth Classic and BLE. It is more expensive than the HC-05, but offers more advanced features and capabilities.
- nRF24L01+ Wireless module: This is a wireless module that operates at 2.4GHz and uses a different protocol than Bluetooth. It is generally cheaper than Bluetooth modules and can be used for applications where a shorter range and lower data rate are acceptable.
HC-05 Bluetooth Module interface with Arduino
HC-05 Bluetooth Module code for Arduino
#include<SoftwareSerial.h>
/* Create object named bt of the class SoftwareSerial */
SoftwareSerial bt(2,3); /* (Rx,Tx) */
voidsetup(){
bt.begin(9600); /* Define baud rate for software serial communication */
Serial.begin(9600); /* Define baud rate for serial communication */
}
voidloop(){
if (bt.available()) /* If data is available on serial port */
{
Serial.write(bt.read()); /* Print character received on to the serial monitor */
}
}
The output of the above code is any data that is received on the software serial port, and printed on the serial monitor.
To know more about HC-05 Bluetooth Module using Arduino refer to this link
Examples of Bluetooth Module interfacing
- HC-05 Bluetooth Module Interfacing with PIC18F4550
- HC-05 Bluetooth Module Interfacing with 8051
- HC-05 Bluetooth Module Interfacing with ATmega32
- HC-05 Bluetooth Module Interfacing with Arduino
- HC-05 Bluetooth Module Interfacing with TI Launchpad
- HC-05 Bluetooth Module Interfacing with LPC2148
- HC-05 Bluetooth Module Interfacing with NodeMCU
- HC-05 Bluetooth Module Interfacing with ESP32
Components Used |
||
---|---|---|
Bluetooth Module HC-05 Bluetooth is a wireless communication protocol used to communicate over short distances. It is used for low power, low cost wireless data transmission applications over 2.4 – 2.485 GHz (unlicensed) frequency band. |
X 1 |