The HC-06 Bluetooth module is similar to the HC-05 but with a few key differences. It is specifically designed to operate in slave mode only, unlike the HC-05, which can be set to either master or slave mode. The HC-06 is often used for communication between microcontrollers (like Arduino) and Bluetooth-enabled devices, such as smartphones, tablets, or PCs.
Key Features:
- Bluetooth Version: Bluetooth 2.0 + EDR (Enhanced Data Rate).
- Mode: Slave mode only (cannot act as a master).
- Communication Interface: Uses UART (Serial communication) with TX (Transmit) and RX (Receive) pins.
- Voltage: Operates with 3.3V logic for communication but can be powered with 3.3V to 5V.
- Data Transfer Speed: Typically 9600 bps (default baud rate).
- Pairing: You can pair it with other Bluetooth-enabled devices to exchange data.
Applications:
- Wireless Communication: Allows communication between microcontrollers and Bluetooth-enabled devices.
- Control Systems: Used in robotics, home automation, or remote control systems where you want to control devices wirelessly.
- Wireless Data Transfer: For transferring sensor data to a smartphone or computer.
- Remote Control: Controlling appliances or robots from a smartphone or other Bluetooth-enabled device.
Wiring HC-06 to Arduino:
The wiring is very similar to the HC-05:
- HC-06 VCC → Arduino 5V
- HC-06 GND → Arduino GND
- HC-06 TX → Arduino RX (Pin 0)
- HC-06 RX → Arduino TX (Pin 1) (Note: The HC-06 RX pin operates at 3.3V, while Arduino TX typically outputs 5V. You may need a voltage divider or level shifter to step down the voltage from 5V to 3.3V for safe operation.)
Basic Code for Communication (Arduino Example):
This is a simple example to demonstrate how to send and receive data between an Arduino and an HC-06 Bluetooth module.
#include <SoftwareSerial.h>
// Create software serial port
SoftwareSerial BTSerial(10, 11); // RX, TX pins
void setup() {
// Start serial communication
Serial.begin(9600);
BTSerial.begin(9600); // HC-06 default baud rate
Serial.println("Bluetooth communication started!");
}
void loop() {
// Read data from Bluetooth and send to Serial Monitor
if (BTSerial.available()) {
char receivedChar = BTSerial.read();
Serial.print(receivedChar);
}
// Read data from Serial Monitor and send to Bluetooth
if (Serial.available()) {
char inputChar = Serial.read();
BTSerial.print(inputChar);
}
}
AT Commands for HC-06:
The HC-06 module can be configured using AT commands for tasks like changing the name, pairing password, and setting other parameters. To enter AT mode, follow these steps:
- Disconnect from the microcontroller (e.g., Arduino).
- Connect the module to a serial interface (either USB-to-Serial adapter or Arduino, if using a software serial interface).
- Send AT commands using a serial terminal program (such as the Arduino Serial Monitor).
Here are some basic AT commands:
- Check if in AT mode: Type
AT and the module should reply with OK. - Change Bluetooth Name:
AT+NAME=NewName - Change Baud Rate:
AT+BAUD8 (For 9600 baud). - Set Pin Code:
AT+PSWD=1234 - Query the Current Baud Rate:
AT+BAUD?
Example of Using HC-06 with a Smartphone:
- Pair your HC-06 module with your smartphone.
- Use a Bluetooth terminal app on your phone (like the "Bluetooth Terminal" app for Android).
- Connect to the HC-06 and send/receive data.
Differences Between HC-05 and HC-06:
- Master/Slave Mode: The HC-05 can be both a master and a slave, while the HC-06 can only be a slave.
- Baud Rate: Both have similar baud rates, but the default baud rate for HC-06 is typically set to 9600.
- Configuration: Both modules support AT commands, but the HC-05 offers more flexibility since it supports master mode.
Origin: China
Brand: Generic