Bluetooth Module
Diagram

Serial communication
#include <SoftwareSerial.h>
SoftwareSerial hc06(2,3);
void setup(){
//Initialize Serial Monitor
Serial.begin(9600);
Serial.println("ENTER AT Commands:");
//Initialize Bluetooth Serial Port
hc06.begin(9600);
}
void loop(){
//Write data from HC06 to Serial Monitor
if (hc06.available()){
Serial.write(hc06.read());
}
//Write from Serial Monitor to HC06
if (Serial.available()){
hc06.write(Serial.read());
}
}
Sending commands
- Open Tools → Serial Monitor (No line ending, 9600 baud)
- Commands to interact:
Simple Check:
AT
Returns
OK
Set name:
AT+NAMEsanbt
Returns
OKsetname
Set password:
AT+PIN0000
Returns
OKsetPIN
Set baud rate:
AT+BAUD4
Returns
OK9600
(Note: 1 for 1200, 2 for 2400, 3 for 4800, 4 for 9600, 5 for 19200, 6 for 38400, 7 for 57600, 8 for 115200)
Bluetooth test with Android App
Step 1. Run Arduino script
#include <SoftwareSerial.h>
SoftwareSerial hc06(2, 3);
char a;
//byte receivedData;
void setup() {
//Initialize Serial Monitor
Serial.begin(9600);
Serial.println("Listening to Bluetooth port:");
//Initialize Bluetooth Serial Port
hc06.begin(9600); // TAMTAM 0000
}
void loop() {
//Write data from HC06 to Serial Monitor
if (hc06.available()) {
// if text arrived in from BT serial...
a = (hc06.read());
if (a == '1')
{
hc06.println("LED on");
}
if (a == '2')
{
hc06.println("LED off");
}
}
}
Step 2. Download app on Android
Get one of the following apps:
Bluetooth Terminal HC-05:
Bluetooth Terminal by Qwerty: