Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Easy Method Using CMODE

Making a connection Between a HC-05 and a HC-06: Method 1

Using the CMODE command we have an easy way to connect the HC-05 and the HC-06. When the HC-O5 is configured to pair with any address (AT+CMODE=1) it should connect to a HC-06 automatically. No binding etc is required.

I am not sure how reliable this method is and do not know if the connection will be made every time. I also do not know what happens if you have more than one slave module. I suppose if you only have 1 slave and 1 master then the master should connect to it every time. I will try some experiments in the near future when I get time.

I am using the zs-040 modules and I do not know if other modules are the same.

The Set Up

I am using 2 different Arduino IDEs; version 1.0.5 and version 1.6.3 but this not required. You can run 2 instances of the same IDE which then allows yo to have 2 serial monitor open at the same time.

The Arduino connected to the HC-05 is on COM8 and the Arduino using the HC-06 is on COM17


On the HC-05, I have changed the baud rate used in the communication mode to 38400. This means I do not need to change anything when switching between AT mode and Communication mode.

I am using the HC-05_AT_MODE_01 sketch on the Arduino connected to the HC-05 and the HC-06_01 sketch on the Arduino connected to the HC-06


// Basic Bluetooth sketch HC-05_AT_MODE_01
// Connect the HC-05 module and communicate using the serial monitor
// The HC-05 defaults to commincation mode when first powered on you will need to manually enter AT mode
// The default baud rate for AT mode is 38400
// See for details
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX. 
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.
char c = ' ';
void setup() 
    Serial.println("Arduino is ready");
    Serial.println("Remember to select Both NL & CR in the serial monitor");
    // HC-05 default serial speed for AT mode is 38400
void loop()
    // Keep reading from HC-05 and send to Arduino Serial Monitor
    if (BTserial.available())
        c =;
    // Keep reading from Arduino Serial Monitor and send to HC-05
    if (Serial.available())
        c =;


// Basic bluetooth test sketch. HC-06_01
// HC-06 ZS-040 
//  Uses hardware serial to talk to the host computer and software serial for communication with the bluetooth module
//  Pins
//  BT VCC to Arduino 5V out. 
//  BT GND to GND
//  BT RX to Arduino pin 3 (through a voltage divider)
//  BT TX  to Arduino pin 2 (no need voltage divider)
//  When a command is entered in the serial monitor on the computer 
//  the Arduino will relay it to the bluetooth module and display the result.
//  These HC-06 modules require capital letters and no line ending
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX
void setup() 
  Serial.println("Enter AT commands:");
  // HC-06 default baud rate is 9600
void loop()
  // Keep reading from HC-06 and send to Arduino Serial Monitor
  if (BTSerial.available())
  // Keep reading from Arduino Serial Monitor and send to HC-06
  if (Serial.available())


Both Bluetooth modules are connected in the same way


HC-05 to HC-06 Easy Method Using CMODE

Make the 2 circuits and power on. The LEDs on both the HC-05 and the HC-06 should be blinking quickly.

To get the HC-05 to connect to the HC-05 we need to
– set the HC-05 as a master device
– configure to pair with any address
– cycle the power to the module

Put the HC-05 in to AT mode (hold the button switch closed while powering on). If you are not sure how to do this see Arduino with HC-05 (ZS-040) Bluetooth module – AT MODE. When in AT mode the LED on the HC-05 should blink on/off every second.

First, check that we are in AT mode. Enter AT and hit Send. You should get “OK”

Set the HC-05 as a master device with the AT+ROLE command: AT+ROLE=1. You should get another “OK”

Configure the HC-05 to pair with any address: AT+CMODE=1. You should get yet another “OK”

Cycle the power to the HC-05. The LED on the HC-05 will blink twice a second as it searches and once it has connected with the HC-06 the LED will quickly blink twice every 2 seconds or so. The LED on the HC-06 should be constant on.

Now, what every you enter in one of the serial monitors will be sent by Bluetooth to the other Arduino and then displayed in the opposite serial monitor.


Hello sent from the HC-06 to the HC-05



32 thoughts on “Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Easy Method Using CMODE

  1. Hi Martyn,

    I am really enjoying your flurry of BT blogs. I am setting up a bluetooth connection and have received a lot of help through your efforts. Thank You.

    Did you ever notice you can run several instances of the same version of the Arduino IDE simply by starting the application a second or third plus times? This has worked since before 1.0. I remember??? It works are the current versions too. I’ve been doing this without thinking about it for quite a few years.

    • Good to hear the blog is useful and thanks for your comment.

      I started using 2 separate IDEs a while ago due to issues I had having 2 serial monitors open at the same. This became a habit and ever since I never thought to try running multiple instances of the newer IDEs. Thanks for the tip.

  2. Pingback: Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Pair, Bind, and Link | Martyn Currey

  3. Hi Martyn,

    Thanks for this post. It is great. I am new to this bluetooth thing and I have some questions.

    I was able to connect the HC 05 (master, cmode=1) to android (slave) using AT+PAIR command. Before they were paired, the android pops up a screen to ask for the password (1234). I typed it and they were paired.

    Looked your post, I don’t see anything about providing password when connecting hc-05 to hc-06.

    Can you provide me more info ?

    Many thanks


  4. CMODE=1 allows the HC-05 to pair with any device. I can’t remember if the passwords have to be the same though (I suspect they need to be) and I am traveling at the moment so can’t confirm. Try a test. Set the the HC-05 and the HC-06 to have different passwords and see if they still connect. Report back what you find.

  5. Hi Martyn!

    I really enjoyed working on your setup. Its an awesome tutorial for starters like me. Thanks for the post. I was just wondering can I connect 2 master HC05s or 2 slave hc05s only? I mean can I configure both as either master or slave and still initiate communication between both of them?

    • Bluetooth connections always require a Master/Slave combination with the Master device initiating the connection.

      The HC-05 can be used as a Master or a Slave device and so 2 HC-05s can be used (one must be set as a Slave though). The HC-06 is a Slave only device and can only accept connection requests, it cannot make them and so will always need a Master device to connect with.

  6. Hi Martyn!
    I shorted pin 34 with EN pin. But now I cannot see my LED on BT module blinking 5 times a second by providing digital LOW to EN pin. Anyhow, if I provide digital HIGH to EN pin it blinks on/of f every second. What am I doing wrong here? How can I control configuring BT module either in Command mode or in Data mode as per my wish through my Arduino Code. Kindly help!

  7. AT+CMODE=0 means connect to one slave module, AT+CMODE=1 means what ,

    can we connect more than two slave at the time with master . ?

    • AT+CMODE=0 mean connect to a specified address (specific BT module) only
      AT+CMODE=1 means the module can connect with any BT device.

      You can only make one connection at a time. If you want to connect to several BT modules you need connect one at a time.

  8. hi, I’ve managed to get two hc05’s paired, one on a Leonardo as a master and one on an Uno set as slave. they seem paired ok.
    what I was wanting to do is send variable values that have been calculated on the Leonardo across to the slave (Uno) to control a motor.
    have been looking for some sketches to get an idea of the send / receive commands between the two but no luck. I’m new to arduino and have only been learning for a few weeks, any idea where I can learn specifically on this? every search I do comes up with how to pair modules and not how to use them once paired….

    • It would be better to sort out the communication side using a wired connection first. Once you have this working add the BT connection.

      Think about how you want to format the data,not just for sending but also how to make it easier for receiving. For example I generally use ascii formatted data as this makes the code on the receiving end a little easier. It is not the fastest way to send numeric data though.

      Start with Arduino Serial Basics at
      This thread is very useful and Robin’s recvWithEndMarker() function forms the starting point for all my projects that use serial communication.

  9. Hello. Your blog has been really helpful in my project. I am working on connecting two micro-controllers using bluetooth. For that I want to light a LED connected to one arduino by giving command to the other one. Is that possible?

  10. Actually , i want to pair the two HC-05 bluetooth Modules but according to your site , USB to TTL convertor has been used . How can we pair the 2 bluetooth modules withou using USB to TTL Convertor? Can pairing of bluetooth be done with help of AT commands ?

    • To use AT mode you need to communicate with the BT modules by serial. This means using a USB to serial converter. This can either a dedicated device or an Arduino with a basic sketch.

      You do not need to have both BT modules connected by serial at the same time.
      Connect device 1, set as a slave, set up the password and baud rate etc, then connect device 2 and set up as a Master.

  11. Thanks for the help. I have successfully been able to light an LED by connecting a button to one arduino and the LED to another. But Can you suggest some real life application of such connection between two arduinos?
    Thank you

    • It’s hard to suggest an application and most of my projects are things I do simply to learn how to do them.

      I do have a a turtle lamp that is controlled by an Arduino. This normally works on a timer but has a Bluetooth controller for manual over-ride.
      I also have a Bluetooth LCD. This is simply an Arduino connected to a 4×20 LCD and a Bluetooth module. I then display things on the LCD from remote Arduinos. No real application and I usually use it for debugging.

  12. Hey Martyn,
    This post is really useful. I am trying to use Bluetooth to transmit a potentiometer value between two arduino nanos. I followed this guide to setting up the modules however when I type “Hello”, for example, it gives “zú”. On the HC-06 my serial settings are No Line Ending and 9600 baud. The HC-05 Both NL CR and 38400.
    Many Thanks

  13. Bonjour à tous,

    J’essaye de connecter 2 arduino uno entre eux par le biais de 2 modules bluetooth HC05 et HC06.
    En essayant avec le tuto ci dessus ça ne fonctionne toujours pas.
    Peut etre ne suis je pas le premier …
    Quelqu’un pourrai m’aider svp?

  14. Thanks for this, been a great help. Do you know why the receiving unit is showing symbols instead of the text that has been inputed by the transmitting unit?

    ie typing TEST comes out as øøx€x€xøxø

  15. Hi,if the default baud rate of hc-06 is 9600 as the previous article you post,then I cant send right data to each other BT,I also check MY default baud rate ,is also 9600.
    So I change the BTserial.being() to 9600 ,so it works.
    I still want to make a sure,do you use 38400 or you change the baud rate already?

Leave a Reply

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

6 + = seven

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>