Bluetooth HC-06
Properties
This article describes how to connect the HC-06 Bluetooth module with an Arduino board in order to set the module name, baudrate and pin code.
The AT-commands to be used is described below. Verify the changes by any Bluetooth scanning device such as a smartphone.
Steps
- Connect the HC-06 to the breadboard and wire the 4 cables according to the figure below. TX <-> D7, RX <-> D8
- Power up the arduino
- Start Arduino IDE and select correct Tools/Serial Port
- Install the Arduino sketch below.
- Start the Serial Monitor in Arduino IDE. The AT command: AT shall be answered with OK from the HC-06.
- In the serial MOnitor, type AT+NAMEyourdevicename and the HC-06 shall answer with OKname.
- Continue to send the AT commands you want to execute.
AT Commands:
Component List
- Arduino board
- HC-06 Bluetooth module
- Breadboard
- 4 cables (red, black, green, yellow)
Software
//==============================================
// Arduino Sketch
//==============================================
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7,8); // RX, TX
void setup()
{
Serial.begin(9600);
pinMode(10,OUTPUT); digitalWrite(10,HIGH);
Serial.println("Enter AT commands:");
mySerial.begin(9600);
mySerial.write("AT");
Serial.println("Entered AT!");
}
void loop()
{
if (mySerial.available())
{
Serial.write(mySerial.read());
}
if (Serial.available())
{
mySerial.write(Serial.read());
}
}
//==============================================
Links and References