Stufin
Home Quick Cart Profile

HC-06 Bluetooth Module

Buy Now

VCC

Power supply (3.3 V to 5 V)

GND

Ground

RX

Receive data

TX

Transmit data

STATE

Indicates the module's status (highconnected, low: disconnected)

The module's dimensions are approximately 26.9 mm x 13.4 mm x 2.2 mm (1.06 in x 0.53 in x 0.09 in).

Conclusion

The HC-06 Bluetooth Module is a reliable and affordable wireless communication solution for various IoT projects and applications. Its compact size, low power consumption, and ease of use make it a popular choice among hobbyists and professionals. With its robust feature set and AT command support, the HC-06 module is an ideal solution for remote control, monitoring, and data transmission applications.

Pin Configuration

  • HC-06 Bluetooth Module Pinout Explanation
  • The HC-06 Bluetooth Module is a popular and widely used IoT component for establishing wireless communication between devices. It's essential to understand the pinout of the module to connect it correctly and utilize its features. Here's a detailed explanation of each pin on the HC-06 Bluetooth Module:
  • Pinout Structure:
  • The HC-06 Bluetooth Module has a total of 6 pins, arranged in two rows of 3 pins each.
  • The pins are labeled as VCC, GND, TXD, RXD, STATE, and EN (Enable).
  • Pin-by-Pin Explanation:
  • 1. VCC (Power Supply):
  • Pin Function: Positive Power Supply
  • Pin Type: Power Input
  • Description: Connect this pin to a power source (usually 3.3V or 5V) to supply power to the module.
  • 2. GND (Ground):
  • Pin Function: Ground
  • Pin Type: Power Input
  • Description: Connect this pin to the ground of the power source to provide a return path for the current.
  • 3. TXD (Transmit):
  • Pin Function: Serial Data Transmission
  • Pin Type: Output
  • Description: This pin is used to transmit data from the microcontroller to the Bluetooth module. It's connected to the TX (Transmit) pin of the microcontroller.
  • 4. RXD (Receive):
  • Pin Function: Serial Data Reception
  • Pin Type: Input
  • Description: This pin is used to receive data from the Bluetooth module and send it to the microcontroller. It's connected to the RX (Receive) pin of the microcontroller.
  • 5. STATE (Status):
  • Pin Function: Status Indicator
  • Pin Type: Output
  • Description: This pin indicates the status of the Bluetooth module. It can be used to monitor the module's working state, such as pairing, connected, or disconnected.
  • 6. EN (Enable):
  • Pin Function: Module Enable
  • Pin Type: Input
  • Description: This pin is used to enable or disable the Bluetooth module. Connect it to a digital output of the microcontroller to control the module's operation. When EN is high, the module is enabled; when EN is low, the module is disabled.
  • Important Notes:
  • The HC-06 module operates at a voltage range of 3.3V to 5V. Ensure the power supply voltage matches the module's requirement.
  • The module's transmission and reception pins (TXD and RXD) are tolerant of 5V logic levels, making it compatible with 5V microcontrollers.
  • When using the module with a microcontroller, ensure the baud rate of the serial communication is set to 9600 (default). The baud rate can be adjusted using AT commands.
  • Always follow proper safety precautions when working with electronic components, and ensure the module is properly connected to avoid damage or electrical shock.

Code Examples

HC-06 Bluetooth Module Documentation
Overview
The HC-06 Bluetooth Module is a widely used Bluetooth Serial Port Protocol (SPP) module that allows microcontrollers to communicate with Bluetooth-enabled devices. It is a low-cost, compact module that operates at a frequency of 2.4 GHz and has a transmission range of up to 10 meters.
Pinout
The HC-06 Bluetooth Module has the following pins:
VCC: Power supply (3.3V - 5V)
 GND: Ground
 TXD: Transmitter data
 RXD: Receiver data
 STATE: State indicator (high when paired, low when not paired)
 EN: Enable pin (high to enable, low to disable)
Operation
The HC-06 Bluetooth Module operates in two modes:
Command mode: Allows the user to configure the module using AT commands.
 Data mode: Used for transmitting and receiving data.
Code Examples
### Example 1: Arduino Serial Communication with HC-06 Bluetooth Module
In this example, we will connect the HC-06 Bluetooth Module to an Arduino board and establish a serial communication between the two devices.
Hardware Requirements
Arduino Board (e.g., Arduino Uno)
 HC-06 Bluetooth Module
 Jumper Wires
Software Requirements
Arduino IDE
Code
```cpp
#include <SoftwareSerial.h>
// Define software serial pins for HC-06 Bluetooth Module
SoftwareSerial BTSerial(2, 3); // RX, TX
void setup() {
  Serial.begin(9600);
  BTSerial.begin(9600);
}
void loop() {
  if (BTSerial.available() > 0) {
    char c = BTSerial.read();
    Serial.print(c);
  }
  if (Serial.available() > 0) {
    char c = Serial.read();
    BTSerial.print(c);
  }
  delay(50);
}
```
In this code, we use the SoftwareSerial library to establish a serial communication between the Arduino board and the HC-06 Bluetooth Module. The `BTSerial` object is used to send and receive data with the Bluetooth module.
### Example 2: Android App Communication with HC-06 Bluetooth Module using Python
In this example, we will create a simple Android app that communicates with the HC-06 Bluetooth Module using Python.
Hardware Requirements
Android Device with Bluetooth capability
 HC-06 Bluetooth Module
 Microcontroller (e.g., Raspberry Pi) with Python installed
Software Requirements
Python 3.x
 PySerial library
 Android Studio
Code
Python Code (HC-06 Bluetooth Module side)
```python
import serial
# Open the serial port
ser = serial.Serial('/dev/ttyUSB0', 9600)
while True:
    # Read data from the serial port
    data = ser.readline().decode('utf-8').strip()
    print(data)
```
In this code, we use the PySerial library to open the serial port and read data from the HC-06 Bluetooth Module.
Android Code (Android App side)
```java
// Import necessary libraries
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
// Create a Bluetooth adapter
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
// Connect to the HC-06 Bluetooth Module
BluetoothDevice device = btAdapter.getRemoteDevice("HC-06_MAC_ADDRESS");
BluetoothSocket socket = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
// Send data to the HC-06 Bluetooth Module
socket.getOutputStream().write("Hello, HC-06!".getBytes());
// Receive data from the HC-06 Bluetooth Module
byte[] buffer = new byte[1024];
int bytesRead = socket.getInputStream().read(buffer);
String data = new String(buffer, 0, bytesRead);
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(data);
```
In this code, we use the Android Bluetooth API to connect to the HC-06 Bluetooth Module and send and receive data.
Note: Replace "HC-06_MAC_ADDRESS" with the actual MAC address of your HC-06 Bluetooth Module.