Add Bluetooth to Your Arduino Project - Arduino+HC-06




Introduction: Add Bluetooth to Your Arduino Project - Arduino+HC-06

About: I am an electrical engineer and an Arduino and electronics enthusiasts. I believe working with electricity should be fun as well as beneficial to engineers and the world at large. Twitter handle: @arduinoha...

Wouldn't you love to switch on and off the lights in your house without having to raise a finger? (well, technically you would have to raise a finger or two, but you get the jist of the story). The good news is that you can. All you needs is an arduino, HC-06 bluetooth module, some relays and a little electrical know-how.

In this tutorial, however, i am going to show you how to setup the HC-06, send some data to the arduino and receive and echo and control an LED via bluetooth. At least this should get you started, before you get to control the whole grid with your HC-06...just kidding.

Step 1: Setup

Setting up the HC-06 is as easy as ABC. All you need to know is the pin configuration. The HC-06 has 6 pins: wakeup, VCC, GND, TXD, RXD and State. Right now I will only deal with 4 pins, which are VCC, GND, TXD and RXD.

Here is how you should connect the Bluetooth module to your Arduino.





The HC-06 acts as a serial port through which you can send and receive data. So using a serial terminal or a Bluetooth customized application on your computer or phone, you can control and monitor your project. I used Teraterm as the serial terminal.
Before, uploading the code to the Arduino, disconnect the HC-06 module, since it shares the tx/rx pins and will interfere with the upload. Connect it back once the code has been uploaded successfully.

Step 2: Echo Code

This code enables you to send a string to the Arduino via Bluetooth and get an echo back on your serial monitor.

NB: if you are using an arduino mega change this line of code while(Serial.available()); to while(Serial.available()>0); otherwise the code will not work

Step 3: LED Code

This code allows you to switch on and off an LED using by sending a command to the Arduino via Bluetooth.

Step 4: Pairing HC-06 to the Computer

Pair the HC-06 with your computer or any other Bluetooth device you have as shown in the video

NB: In the video I say that you should connect your serial terminal program (teraterm) to the INCOMING com port. This is not right. The correct way should be connecting your serial terminal program to the OUTGOING com port.

Step 5:

Once the module is paired. Open Teraterm, or any other serial terminal program you have. Select the serial port that corresponds to the HC-06 (I have explained how to identify that port in the video).

Once you successfully connect to the HC-06 serial port you will be able to send strings to your Arduino and get an echo back. If you have uploaded the second code, you will be able to switch on and off and LED by sending “n” and “f” respectively.

Step 6: Echo Example

Step 7: LED Example

Step 8:

There are many applications of the HC-06. Learn more about it in my next post as I show you how to control an Arduino robot arm via bluetooth. For a more detailed tutorial on the HC-06 visit this link.



  • Fix It! Contest

    Fix It! Contest
  • Creative Misuse Contest

    Creative Misuse Contest
  • Metalworking Contest

    Metalworking Contest

81 Discussions

I seem to be having trouble either in pairing or else nothing is being sent/received. It looks like it should be so easy. I can get teraterm to seemingly connect but there's no data.

also, ideally I'd like to get the serial monitor output from a remote Arduino to be sent over BT, rather than sending data from the PC to the remote. What changes to your project would you recommend for that?

I use mega 2560 but it doesnt work and has alot of errors ... how can i fix it? Please recommend me.

1 reply

We can't debug your code if we don't have your code, and we can't solve your errors if we don't know what they are.

Thanks for the great and useful tutorial. I followed instructions and it worked first time. Only got a bit stuck on tera term but found some info on the web. I had bought an HC-05 and wanted to test it quickly and your project was perfect and easy to follow for a beginner like me. Also gave me a chance to learn about Tetra term! Thanks !!

3 replies

There are many bluetooth terminal apps available for Android too. I was also successful the first time using one of these apps. Of course I was stuck on forgetting to disconnect the HC-06 (if using the standard Arduino Tx/Rx pins) while trying to upload. Oh well.

If you're still stuck on that, you can use SoftwareSerial to use different pins for the serial connection to the HC-06 which will leave your hardware serial pins open for communication with the computer.

Yes I see the web is full of interesting apps for Arduino and, in particular bluetooth and/ or bots

Sometimes feel like a kid in a candy shop. I Want to dive in the deep end but better to start with basics first!


Question 5 months ago

What about the code of 8 LED !!!!!

Question, once a HC-06 is connected to an arduino you cannot use USB to upload an updated sketch any longer right? If a simple power interrupt switch was added to the vcc between the Arduino and the HC-06 would that enable the USB again? or must all four lines me disconnected? I have a project I added the HC-06 to but I have to keep disassembling it to temp remove the BT just to push a new sketch up :( wondering if a simple switch could be added to simplify the issue....


1 reply

I had the exact same issue and the thing that causes the trouble is using pin 0 and 1 . You can use the SoftWareSerial library to enable the usesage of all the pins on your arduino for your bluetooth module. For example insted of using 0 and 1 i use 10 and 11 now for the RX and TX and now it works fine! Hope i helped you with this

When i write something on the bluetooth terminal it answers me back with random letters

2 replies

Your baud rate on your Serial Monitor doesn't match the program setting or the default. Change it in the bottom right corner of the Serial Monitor screen.

I downloaded your attached ino file and compiled code successfully but unable to upload to my uno board...
Can you plz help me why this is happening? Failed to upload code to uno board.

1 reply

You need to unplug the buetooth device before uploading the code. The arduiono Uno only has one serial port. after uploading the code you can then reconnec the buletooth

am i missing something then?
i have on the UNO a 5v and a 3.3v output (tose i mean.
but i bigin to understand something here.( you mean the DIGITAL PINS stay 5V.
or am i go down even more now hahahahaha
watch my name eeh. a WannaDuino
thanx for the quick response, i wil not put it ON before i know for sure how to give it GOOD voltage.

With Regards WannaDuino