Communication, Embedded systems

Control it All with HC-05/HC-06 Bluetooth Module

In this article, weā€™ll look at how to control an LED over Bluetooth using the HC-06 Bluetooth module, Bluetooth Serial mobile app and your Arduino.

Youā€™ll need the following items to carry out this project

Hardware

  • HC-06 Bluetooth module, get itĀ here
  • USB to UART cable, get itĀ here
  • Arduino UNO, downlaodĀ here

Software

  • Any terminal of your choice, iā€™ll be using Tera Term for this project, get itĀ here
  • Latest Arduino IDE, get itĀ here
  • Go to your mobile app store and downloadĀ Bluetooth Serial App.

Introducing the HC-06 Bluetooth Module

The HC-06 module is a device based on the BC417 2.4GHz Bluetooth radio chip. It uses an 8MB flash memory. These small 3 cm long modules run off 3.3V power and logic level. The HC-06 module includes the Radio and Memory chips, 26 MHz crystal, antenna and RF matching network. The right section of the BT Board has connection pins for power and signals as well as a 5V to 3.3V Regulator, LED, and level shifting.Ā Baud Rate: 9600 bps, Data : 8 bits, Stop Bits: 1 bit, Parity : None, Handshake: None

Please note that HC-05 is the sister module of the HC-06 which can act alternately as a master or slave device. HC-06 functions only as a slave.

HC-06 Bluetooth module
HC-06 Bluetooth module

IMPLEMENTATION

STEP 1: CIRCUIT CONNECTION

FTDI to HC-06 circuit
USB-UART ConverterĀ to HC-06 circuit

STEP 2: COMMUNICATION

If you havenā€™t downloaded the Tera Term software and Bluetooth Serial mobile app, please refer to the beginning of this article.

Start your Tera Term software

  • Click on the Serial radio button
  • Click the port drop down select the appropriate COM port
Tera Term software
Tera Term software
  • Type in AT, you should get an ā€œOKā€ response, that means your module is functioning correctly.
  • Type in AT+VERSION? to get the version of your module
  • Type in AT+PSWD? to get the password of your module
  • To change the name of your HC-06 module, disconnect power from the module, hold down the button on the module and re-connect the power, then type in AT+NAME CHOICEOFNAME, replace CHOICEOFNAME with the name you want.

Start your Bluetooth Serial mobile app,

  • Click the connect button on the top right
  • Select the HC-06 module to connect to it
Bluetooth Serial mobile app
  • If your textbox isnā€™t showing below the screen, click the Preference button on the top right
  • Scroll down and toggle the Text Box and Sent Data mode
Bluetooth Serial mobile app
Bluetooth Serial mobile app
  • Click on the text box, type any letter or word of your choice
  • Youā€™ll see them appear on the Tera Term software screen.

Now, we can communicate with the HC-06 module, letā€™s control an LED with an Arduino using the Bluetooth Serial mobile app.

STEP 1: CIRCUITRY

 

HC-06 Arduino LED circuit
HC-06 Arduino LED circuit

STEP 2: CODE

  • Start your Arduino IDE and copy the following code
char data = 0; //Variable for storing received data
void setup()
{
 Serial.begin(9600); //Sets the baud for serial data transmission 
 pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
 if(Serial.available() > 0) // Send data only when you receive data:
 {
   data = Serial.read(); //Read the incoming data & store into data
   Serial.print(data); //Print Value inside data in Serial monitor
 
 if(data == '1') // Checks whether value of data is equal to 1
   digitalWrite(13, HIGH); //If value is 1 then LED turns ON
 
 else if(data == '0') // Checks whether value of data is equal to 0
   digitalWrite(13, LOW); //If value is 0 then LED turns OFF
 }
}

STEP 3: RESULTS

  • Start the Serial Monitor and set the BAUD rate to 9600.
  • In your Bluetooth Serial mobile app, type in 1/0 to turn on/off the LED
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā Arduino serial monitor result

Wanna do more?

You can control things robots and and carry out home automation projects with your smart phone. Get a relay, Ā hereĀ and start to switch real loads.

Leave a Reply

Your email address will not be published. Required fields are marked *