Stufin
Home Quick Cart Profile

HC-05 Bluetooth Module

Buy Now

VCC

Power input (3.3V to 5V)

GND

Ground

TXD

Serial data transmission

RXD

Serial data reception

EN

Enable pin (active high)

STATE

State pin (indicates the module's status)

  • Operating Voltage: The module operates at a voltage range of 3.3V to 5V, making it compatible with most microcontrollers and development boards.
  • Dimensions: The module has a compact size of 26.5 mm x 13.5 mm x 2.5 mm, making it suitable for integration into small devices and projects.

Applications

The HC-05 Bluetooth Module is widely used in various applications, including

IoT projects

Home automation, industrial automation, wearable devices, and more

Robotics

Robot control, robotic arms, and other robotic applications

Wireless communication

Wireless serial communication, wireless sensor networks, and more

Medical devices

Wireless health monitoring, medical device control, and more

Conclusion

The HC-05 Bluetooth Module is a reliable and efficient wireless communication module that enables devices to communicate with each other over Bluetooth protocol. Its compact size, low power consumption, and easy configuration make it an ideal module for IoT and robotics projects.

Pin Configuration

  • HC-05 Bluetooth Module Pinout Explanation
  • The HC-05 Bluetooth module is a widely used wireless communication module that enables serial communication between devices. It has a total of 6 pins, each with a specific function. Here's a detailed explanation of each pin and how to connect them:
  • Pin 1: VCC (Power Supply)
  • Function: Provides power to the module
  • Voltage: 3.3V to 5V (recommended 3.3V)
  • Connection: Connect to a stable power source, such as a battery or a voltage regulator output
  • Pin 2: GND (Ground)
  • Function: Ground connection for the module
  • Connection: Connect to the ground pin of the power source or the circuit ground
  • Pin 3: TX (Transmit)
  • Function: Serial transmission pin, sends data from the microcontroller to the Bluetooth module
  • Signal: TTL (Transistor-Transistor Logic) level
  • Connection: Connect to the TX pin of a microcontroller, such as an Arduino or a Raspberry Pi
  • Pin 4: RX (Receive)
  • Function: Serial reception pin, receives data from the Bluetooth module and sends it to the microcontroller
  • Signal: TTL level
  • Connection: Connect to the RX pin of a microcontroller, such as an Arduino or a Raspberry Pi
  • Pin 5: EN (Enable)
  • Function: Enables or disables the Bluetooth module
  • Logic: Active high (high voltage enables the module, low voltage disables it)
  • Connection: Connect to a digital output pin of a microcontroller or a voltage source (e.g., 3.3V or 5V) to enable the module
  • Pin 6: State (Status)
  • Function: Indicates the status of the Bluetooth module (connected, disconnected, or pairing mode)
  • Signal: Digital output
  • Connection: Connect to a digital input pin of a microcontroller to monitor the module's status
  • Connection Structure:
  • When connecting the HC-05 Bluetooth module to a microcontroller, follow this structure:
  • VCC (Pin 1) Power Source (3.3V or 5V)
  • GND (Pin 2) Ground
  • TX (Pin 3) RX Pin of Microcontroller
  • RX (Pin 4) TX Pin of Microcontroller
  • EN (Pin 5) Digital Output Pin of Microcontroller (or 3.3V/5V voltage source)
  • State (Pin 6) Digital Input Pin of Microcontroller (optional)
  • Remember to use appropriate voltage levels and signal levels when connecting the HC-05 module to your microcontroller. Always refer to the datasheet and technical documentation of your specific microcontroller and other components for proper connections and configuration.

Code Examples

HC-05 Bluetooth Module Documentation
Overview
The HC-05 is a widely used Bluetooth module that enables serial communication between devices. It is a slave device that can be connected to a microcontroller or a computer to establish a wireless connection with other Bluetooth devices.
Pinout
The HC-05 module has the following pins:
VCC: Power supply (typically 5V)
 GND: Ground
 RX: Receive pin (connected to the microcontroller's transmit pin)
 TX: Transmit pin (connected to the microcontroller's receive pin)
 EN (optional): Enable pin (used to enable or disable the module)
 STATE (optional): State pin (indicates the module's status)
Code Examples
### Example 1: Basic Arduino Serial Communication
In this example, we will use an Arduino board to send and receive data using the HC-05 module.
Hardware Connection
Connect the HC-05 module's VCC to the Arduino's 5V pin
 Connect the HC-05 module's GND to the Arduino's GND pin
 Connect the HC-05 module's RX to the Arduino's TX pin (pin 1)
 Connect the HC-05 module's TX to the Arduino's RX pin (pin 0)
Arduino Code
```cpp
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10, 11); // RX, TX
void setup() {
  Serial.begin(9600);
  btSerial.begin(9600);
}
void loop() {
  if (btSerial.available()) {
    Serial.write(btSerial.read());
  }
  if (Serial.available()) {
    btSerial.write(Serial.read());
  }
  delay(10);
}
```
In this example, we use the SoftwareSerial library to establish a serial communication between the Arduino and the HC-05 module. The `btSerial` object is used to communicate with the module.
### Example 2: Android App Control using HC-05
In this example, we will use an Android app to control an LED connected to an Arduino board using the HC-05 module.
Hardware Connection
Connect the HC-05 module's VCC to the Arduino's 5V pin
 Connect the HC-05 module's GND to the Arduino's GND pin
 Connect the HC-05 module's RX to the Arduino's TX pin (pin 1)
 Connect the HC-05 module's TX to the Arduino's RX pin (pin 0)
 Connect an LED to a digital pin on the Arduino board
Arduino Code
```cpp
const int ledPin = 13; // LED connected to digital pin 13
void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}
void loop() {
  if (Serial.available() > 0) {
    char cmd = Serial.read();
    if (cmd == '1') {
      digitalWrite(ledPin, HIGH);
    } else if (cmd == '0') {
      digitalWrite(ledPin, LOW);
    }
  }
}
```
In this example, we use the Arduino's serial communication to receive commands from the Android app. The app sends a character '1' to turn on the LED and '0' to turn it off.
Android App Code (using Android Studio)
```java
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class BluetoothControlActivity extends AppCompatActivity {
  private BluetoothAdapter btAdapter;
  private BluetoothSocket btSocket;
  private OutputStream outputStream;
@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bluetooth_control);
btAdapter = BluetoothAdapter.getDefaultAdapter();
    BluetoothDevice device = btAdapter.getRemoteDevice("HC-05's MAC address");
    btSocket = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
    btSocket.connect();
outputStream = btSocket.getOutputStream();
Button btnOn = findViewById(R.id btn_on);
    Button btnOff = findViewById(R.id btn_off);
btnOn.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        try {
          outputStream.write('1');
        } catch (IOException e) {
          Toast.makeText(BluetoothControlActivity.this, "Error sending command", Toast.LENGTH_SHORT).show();
        }
      }
    });
btnOff.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        try {
          outputStream.write('0');
        } catch (IOException e) {
          Toast.makeText(BluetoothControlActivity.this, "Error sending command", Toast.LENGTH_SHORT).show();
        }
      }
    });
  }
}
```
In this example, we use the Android Bluetooth API to establish a connection with the HC-05 module. We then use the `outputStream` object to send commands to the Arduino board, which controls the LED accordingly.