Power supply (3.3 V to 5 V)
Power supply (3.3 V to 5 V)
Ground
Receive data
Transmit data
Indicates the module's status (high: connected, 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.
HC-06 Bluetooth Module DocumentationOverviewThe 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.PinoutThe 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)OperationThe 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 ModuleIn this example, we will connect the HC-06 Bluetooth Module to an Arduino board and establish a serial communication between the two devices.Hardware RequirementsArduino Board (e.g., Arduino Uno)
HC-06 Bluetooth Module
Jumper WiresSoftware RequirementsArduino IDECode
```cpp
#include <SoftwareSerial.h>// Define software serial pins for HC-06 Bluetooth Module
SoftwareSerial BTSerial(2, 3); // RX, TXvoid 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 PythonIn this example, we will create a simple Android app that communicates with the HC-06 Bluetooth Module using Python.Hardware RequirementsAndroid Device with Bluetooth capability
HC-06 Bluetooth Module
Microcontroller (e.g., Raspberry Pi) with Python installedSoftware RequirementsPython 3.x
PySerial library
Android StudioCodePython 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.