Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use HC-05 Bluetooth Module: Examples, Pinouts, and Specs

Image of HC-05 Bluetooth ModuleDesign with HC-05 Bluetooth Module in Cirkit Designer

Introduction

The HC-05 Bluetooth Module, manufactured by Bluetooth Serial Port Profile (Part ID: HC-05), is a versatile wireless communication module designed for short-range data transfer. It operates using Bluetooth technology and is widely used in embedded systems, IoT devices, and robotics. The module supports both master and slave modes, making it suitable for a variety of applications requiring wireless communication.

Explore Projects Built with HC-05 Bluetooth Module

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino UNO Bluetooth-Controlled Relay System: A project utilizing HC-05 Bluetooth Module in a practical application
Arduino UNO Bluetooth-Controlled Relay System

This circuit features an Arduino UNO microcontroller interfaced with an HC-05 Bluetooth module for wireless communication. It also includes two 5V two-channel relay modules, which are connected to the Arduino for controlling external devices. The setup allows for remote control of devices via Bluetooth.

Open Project in Cirkit Designer
Image of Raspberry Pi Pico-Based Navigation Assistant with Bluetooth and GPS: A project utilizing HC-05 Bluetooth Module in a practical application
Raspberry Pi Pico-Based Navigation Assistant with Bluetooth and GPS

This circuit features a Raspberry Pi Pico microcontroller interfaced with an HC-05 Bluetooth module for wireless communication, an HMC5883L compass module for magnetic field measurement, and a GPS NEO 6M module for location tracking. The Pico is configured to communicate with the HC-05 via serial connection (TX/RX), with the compass module via I2C (SCL/SDA), and with the GPS module via serial (TX/RX). Common power (VCC) and ground (GND) lines are shared among all modules, indicating a unified power system.

Open Project in Cirkit Designer

Common Applications and Use Cases

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

The HC-05 module has 6 pins, as described in the table below:

Pin Name Pin Number Description
VCC 1 Power supply input (3.3V to 5V).
GND 2 Ground connection.
TXD 3 Transmit data pin (connects to RXD of the microcontroller).
RXD 4 Receive data pin (connects to TXD of the microcontroller).
EN (Key) 5 Enable pin for entering AT command mode (active HIGH).
STATE 6 Indicates the connection status (LOW: not connected, HIGH: connected).

Usage Instructions

How to Use the HC-05 in a Circuit

  1. Powering the Module: Connect the VCC pin to a 3.3V or 5V power source and the GND pin to ground.
  2. Connecting to a Microcontroller:
    • Connect the TXD pin of the HC-05 to the RXD pin of the microcontroller.
    • Connect the RXD pin of the HC-05 to the TXD pin of the microcontroller. Use a voltage divider if the microcontroller operates at 5V logic levels to avoid damaging the RXD pin.
  3. Configuring the Module:
    • To configure the module, set the EN (Key) pin HIGH and use AT commands via a serial terminal.
    • Example AT commands:
      • AT: Test the connection.
      • AT+NAME=YourDeviceName: Set the module name.
      • AT+PSWD=YourPIN: Set the pairing PIN.
      • AT+ROLE=0: Set the module to slave mode (default).
  4. Pairing with a Device:
    • Search for the HC-05 module on your Bluetooth-enabled device.
    • Pair using the default PIN (1234) or the PIN you configured.

Important Considerations and Best Practices

Example Code for Arduino UNO

Below is an example of how to use the HC-05 module with an Arduino UNO for basic serial communication:

#include <SoftwareSerial.h>

// Define RX and TX pins for SoftwareSerial
SoftwareSerial BTSerial(10, 11); // RX = Pin 10, TX = Pin 11

void setup() {
  // Initialize hardware serial for debugging
  Serial.begin(9600);
  // Initialize Bluetooth serial communication
  BTSerial.begin(9600); // Default baud rate of HC-05
  Serial.println("HC-05 Bluetooth Module Initialized");
}

void loop() {
  // Check if data is available from Bluetooth
  if (BTSerial.available()) {
    char data = BTSerial.read(); // Read data from HC-05
    Serial.print("Received: ");
    Serial.println(data); // Print received data to Serial Monitor
  }

  // Check if data is available from Serial Monitor
  if (Serial.available()) {
    char data = Serial.read(); // Read data from Serial Monitor
    BTSerial.write(data); // Send data to HC-05
    Serial.print("Sent: ");
    Serial.println(data); // Print sent data to Serial Monitor
  }
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. Module Not Powering On:

    • Ensure the VCC pin is connected to a 3.3V or 5V power source.
    • Check for loose connections or damaged wires.
  2. Unable to Pair with a Device:

    • Verify the module is powered on and in discoverable mode.
    • Ensure the correct PIN (default: 1234) is used during pairing.
    • Check for interference or obstacles between the module and the device.
  3. No Data Transmission:

    • Confirm the TXD and RXD pins are correctly connected to the microcontroller.
    • Ensure the baud rate of the microcontroller matches the HC-05's baud rate.
    • Use a voltage divider on the RXD pin if the microcontroller operates at 5V logic levels.
  4. AT Commands Not Working:

    • Ensure the EN (Key) pin is set HIGH to enter AT command mode.
    • Use a serial terminal with the correct baud rate (default: 38400 bps in AT mode).

FAQs

Q: Can the HC-05 module be used with a 5V microcontroller?
A: Yes, but a voltage divider is recommended on the RXD pin to prevent damage, as the HC-05 operates at 3.3V logic levels.

Q: How do I reset the HC-05 to factory settings?
A: Enter AT command mode and send the AT+ORGL command to reset the module to its default settings.

Q: What is the difference between master and slave modes?
A: In master mode, the HC-05 initiates connections with other devices. In slave mode, it waits for incoming connections.

Q: Can I change the default baud rate?
A: Yes, use the AT command AT+UART=<baud rate>,0,0 to set a new baud rate. For example, AT+UART=115200,0,0.

By following this documentation, users can effectively integrate the HC-05 Bluetooth Module into their projects and troubleshoot common issues.