Communicating using Bluetooth HC-06

The HC-06 serial port bluetooth module provides a wireless communication link between your arduino and any bluetooth capable device. HC-06 is in practice a bluetooth to serial adapter. It is an ideal replacement to your wired serial connection.
arduino breadboard hc-06 board

Wiring

  • HC-06 VCC –> Arduino +5V
  • HC-06 GND –> Arduino GND
  • HC-06 TXD –> Arduino Pin 0 (RX)
  • HC-06 RXD –> Arduino Pin 1 (TX)

Instructions and Code

    1. Connect your arduino board to your PC and open Arduino software to upload the following code.The code should successfully be verified and uploaded.
  1. Setup the breadboard circuit with the HC-06 and arduino as shown in the above image. Power the arduino board. The HC-06 bluetooth module should start flashing a red light.
  2. Install and run the BlueSoleil bluetooth manager. On the tray area of your desktop (bottom right – next to the clock) there should be a bluetooth icon, indicating the state of the bluetooth dongle that is connected to your PC. Right-click the icon and select “Display Classic View”. On the window that opened, right-click the yellowish circle in the center and select “Search Devices”. Once searching is complete, HC-06 should be shown as a newly found device. Right-click on the “HC-06” icon and select “Search Services”. One service should be found. Right-click on the “HC-06” icon again and a new option should be listed, writing “Connect Bluetooth Serial Port (COM13)”. Go ahead and select it. Once the link is complete the red flashing light on the HC-06 module should stop blinking and stay red. You should note down the port that the HC-06 module connected to, as we’re going to need to connect to it to read back the data coming from the arduino board.NOTE: COM13 is the serial port where the HC-06 module will send data. It is not necessary for the port to be COM13, it could happen to be any other COM port.
  3. Now install PuTTY and run it. We will use PuTTY as a serial console; a replacement for Windows® HyperTerminal, which is not available in latest versions of Windows.On the PuTTY window select “Serial” as a ‘Connection Type’, set ‘Serial line’ to the port where HC-06 is sending data (“COM13” for our example) and set ‘Speed’ to “9600”. Click open and a black/white terminal/console window should open showing you the data that is received.


Arduino + GRobotronics = 2102 times awesome
Arduino + GRobotronics = 2103 times awesome
Arduino + GRobotronics = 2104 times awesome
Arduino + GRobotronics = 2105 times awesome
Arduino + GRobotronics = 2106 times awesome

Posted in Arduino Tutorials Tagged with: , , , ,
14 comments on “Communicating using Bluetooth HC-06
  1. Daniel says:

    Thanks for the great tutorial. But I am a little confused as to the voltage of the tx and rx lines. Does the hc-06 on the daughter board have a logic level converter or voltage divider built on to the daughter board that it is attached to? Or do I need to add one. I see on the wiring breadboard image above that it doesn’t have on added on the breadboard. So I thought I would ask. Thanks again.

    • GRobotronics Learning Dep says:

      Hi Daniel,
      The level conversion is done onboard, you don’t need to add anything else.

      • Daniel says:

        That’s good news and nice to have confirmed. Less wiring and components to add. Thanks for the reply to my comment and once again to the great tutorial.

  2. Paul says:

    In case you need a code for pairing the bluetooth module with your computer, the default pairing code is 1234.

  3. George Tsafos says:

    With all respect and if got your statement right….what you say is inaccurate.
    Once connected with my phone I was able to send simple characters.
    The fact that Rx, Tx lines between HC-06+MCU are cross-connected “gives away” a bidirectional communication channel. Here’s how I send data over my phone. If you have any problems just “play” with the baudrate.

    I hope I helped

    //————————————————
    void setup()
    {
    Serial.begin(9600);
    Serial.begin(9600);
    }

    void loop()
    {
    if(Serial.available())
    {
    byte a=Serial.read();
    Serial.write(a);
    }
    }

  4. Richard says:

    What do you mean it can only send serial information? It has Rx pin, right? It is used for Transmission as well.. am I missing something?

  5. Richard says:

    edit: I mean it can receive serial information as well.

  6. learning kid says:

    Hi, i have a question and i hope you guys can help me with this. how does the arduino actually know actually know which data it is going to send or receive? in which part of the code does it do that? i want to make two arduinos one having a HC05 as a master sending data over to a HC06 slave on two different laptops. I hope you can answer me.

  7. BluJay says:

    Is it possible to interface Bluetooth HC-06 with other micro controller e.g., Ti cc3200?

  8. Quentin says:

    I’m using an Arduino nano. Will the voltage of 3v instead of the 5v for the HC-06 matter? Please respond quickly, Thanks for the great tutorial!

  9. Dimitrios says:

    I bought this module (itead HC-06 ) from your store , it works perfectly.
    My question is, how do we “put” this module in “command line mode” so that the default password can be changed. As I have a couple Arduino’s (Uno R3) sitting on my desk , the ideal solution would be to use one of those to customize the HC-06 module (password, name of module ….) .
    Kind regards .

  10. Obrelix says:

    Hi and thank you for the nice tutorial!
    This sketch works fine on me but when i am trying to send data to arduino, it cant receive anything!!
    Arduino can write to serial monitor but it cant receive anything. I dont know why this is happening… I triple checked the HC-06 connection to the board and it is ok! TXD to RXD0 , RXD to TXD1, vcc to 5 volt and ground to ground. I tried all the available baud rates from serial monitor nothing change and i tried to connect from my tablet and phone with a bluetooth Terminal but with the same result! Arduino can write to terminal but it cant recieve from terminal!

    this is one of the sketches that i tried!

    void setup()
    {
    Serial.begin(9600);
    }

    void loop() // run over and over
    {
    char a;

    Serial.println(“Goodnight moon!”);

    delay(1000);
    a=Serial.read();
    if(a!=’ ‘){
    Serial.println(“Galabanka!”);
    }
    delay(500);
    }

    it works fine when i tried it with usb connection ! My arduino board is an arduino uno r3

    • Obrelix says:

      Sorry i paste a sketch that it doesnt work

      void setup()
      {
      Serial.begin(9600);
      }

      void loop() // run over and over
      {
      char a = 0;

      Serial.println(“Hello from arduino”);

      delay(500);

      a=Serial.read();
      if (a == ‘0’){
      Serial.println(“Galabanka”);
      }

      delay(500);
      }

      this work with usb connection but not with bluetooth !

      P.S: I disconnect the arduino from usb when i use the bluetooth connection to avoid data conflict.

Leave a Reply

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

*