Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Pair, Bind, and Link

In a previous post I showed how the HC-05 can auto connect to other Bluetooth devices by setting the HC-05 to pair with any device using CMODE=1. This is quick and easy but does not give any control over which other device the HC-05 connects to.

In this post I show how to set up the HC-05 to always connect to the same HC-06. For this we use PAIR, BIND, and LINK.

I am using 2 separate Arduino IDEs; version 1.6.3 which is installed, and version 1.0.5 which I run from a folder (it is the non install version). This allows me to use 2 IDEs at the same time, each connected to a different Arduino. It also gives me 2 serial monitors, one for each Arduino.

The modules used are the zs-040 versions of the HC-05 and the HC-06.

The HC-05 has 2 AT modes which I refer to as “mini” AT mode and “full” AT mode and some commands only work when in “full” AT mode. To enter “full” AT mode pin 34 needs to be HIGH and kept HIGH. To accomplish this I have made a connection from pin 34 to +3.3v. See the diagram below (or after the jump).

If you are not sure about the different AT modes take a look at Arduino with HC-05 (ZS-040) Bluetooth module – AT MODE

If you are not familiar with how the HC-06 and HC-05 work it may be worth while checking out some of the other posts:
HC-05 and HC-06 zs-040 Bluetooth modules
Arduino and HC-06 (ZS-040)
Arduino With HC-05 Bluetooth Module in Slave Mode
Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Easy Method Using CMODE

 
 

Connections

I have 2 Arduinos. One connected to a HC-05 zs-040 and one connected to a HC-06 zs-040.

The HC-05 has a connection from pin 34 to +3.3v. This activates “full” AT mode.
HC-05 zs-040

HC-05_to_HC-06_CircuitDiagram

HC-05_to_HC-06_HC-05_BreadBoard

HC-05_to_HC-06_HC-06_BreadBoard

 

HC-05 Set Up

I have the HC-05 set with the following values:

– ROLE = 0 (slave mode)
– UART = 9600 (baud rate for communication mode)
– CMODE = 0 (only connect to paired devices)
– PSWD = 1234 (password/PIN for pairing)

In AT mode I will be using a baud rate of 38400.

Build the circuit, power on and load the following sketch.

// Basic Bluetooth sketch HC-05_02_38400
// Connect the HC-05 module and communicate using the serial monitor
//
// The HC-05 defaults to commincation mode when first powered on.
// Needs to be placed in to AT mode
// After a factory reset the default baud rate for communication mode is 38400
//
//
//  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)
 
 
#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() 
{
    // start th serial communication with the host computer
    Serial.begin(9600);
    Serial.println("Arduino with HC-05 is ready");
 
    // start communication with the HC-05 using 38400
    BTserial.begin(38400);  
    Serial.println("BTserial started at 38400");
}
 
void loop()
{
 
     // Keep reading from HC-05 and send to Arduino Serial Monitor
    if (BTserial.available())
    {  
        c = BTserial.read();
        Serial.write(c);
    }
 
    // Keep reading from Arduino Serial Monitor and send to HC-05
    if (Serial.available())
    {
        c =  Serial.read();
 
        // mirror the commands back to the serial monitor
        // makes it easy to follow the commands
        Serial.write(c);   
        BTserial.write(c);  
    }
 
}

Because pin 34 on the Bluetooth module is brought HIGH, the HC-05 should enter AT mode on power on.
Open the serial monitor on the host computer and confirm you are in AT mode by typing “AT” (no quotes). You should get a reply of “OK”
Remember that the HC-05 requires “Both NL & CR” to be set.

The sketch echos the commands you enter back to the serial monitor. This makes it a bit easier to follow.
HC-05_to_HC-06-HC-05_AT_2

 

HC-06 Set Up

Build the HC-06 circuit, power on and load the following sketch. My HC-06 is set to use 9600 baud rate. If yours is using a different speed then you will need to change the sketch. Change the following lines:
BTSerial.begin(9600);
Serial.println(“BTserial started at 9600″);
Change the 9600 to what ever speed your HC-06 is using.

// Basic bluetooth test sketch. HC-06_01_9600
// 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.begin(9600);
    Serial.println("Arduino with HC-06 is ready");
 
    // HC-06 default baud rate is 9600
    BTSerial.begin(9600);  
    Serial.println("BTserial started at 9600");
}
 
void loop()
{
 
  // Keep reading from HC-06 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());
 
  // Keep reading from Arduino Serial Monitor and send to HC-06
  if (Serial.available())
  BTSerial.write(Serial.read());
}

HC-06 modules start in AT mode so we can start entering commands as soon as we open the serial monitor. Remember that the HC-06 requires commands to be upper case and does not want new lines or carriage returns so set “No line endings” at the bottom of the serial monitor window. Open the serial monitor on the host computer and confirm you are in AT mode by typing “AT” (no quotes). You should get a reply of “OK”

HC-05_to_HC-06-HC-06_AT

We don’t need to do much to prepare the HC-06. Just make sure the password is the same as the HC-05.
To change the password/PIN to 1234 enter “AT+PSWD1234″ (no quotes) and click Send

HC-05_to_HC-06-HC-06_setPin

 

Pairing and Binding

At this point we should have the HC-06 waiting for a connection. The password/PIN is 1234.

The HC-05 should be in “full” AT mode. If you are not sure what this is see Arduino with HC-05 (ZS-040) Bluetooth module – AT MODE

The steps to connect to the HC-06 are
1. set the same baud rate on both devices.
2. make sure the passwords on the HC-05 and the HC-06 are the same
3. find the address of the HC-06
4. pair the HC-05 with the HC-06
5. bind the HC-06 to the HC-05
6. set the HC-05 to only connect with paired devices
7. link to the HC-06

1. Set the same baud rate on both devices.

Set the communication mode baud rate to 9600 on the HC-05 and the HC-06. I have already done this.
This is only for the purpose of this example. Once you have got everything working you can change the baud rates.

2. Make sure the passwords on the HC-05 and the HC-06 are the same

We have already set the passwords.

3. Find the address of the HC-06

You can do this with an Android device or you can do it with the HC-05. Here is how to it with the HC-05.

Make sure the HC-05 is in AT mode and enter the following commands.
AT+RMAAD
AT+ROLE=1
AT+RESET
HC-05_to_HC-06-HC-05_Connect01

AT+RMAAD clears any previously paired devices.
AT+ROLE=1 puts the HC-05 in Master Mode
AT+RESET reset the HC-05. This is sometimes needed after changing roles.

Now enter the following
AT+CMODE=0
AT+INQM=0,5,9
AT+INIT
AT+INQ

AT+INQM=0,5,9, AT+INIT and AT+INQ require pin 34 to be HIGH. If pin 34 is not HIGH then you will not receive any reply from these commands. No message, no error message.
HC-05_to_HC-06-HC-05_Connect02

AT+CMODE=0 allows the HC-05 to connect to any device
AT+INQM=0,5,9 set inquiry to search for up to 5 devices for 9 seconds
AT+INIT initiates the SPP profile. If SPP is already active you will get an error(17) which you can ignore.
AT+INQ searches for other Bluetooth devices.

In the above screen shot you can see that the HC-05 found 2 Bluetooth devices.
+INQ:A854:B2:3FB035,8043C,7FFF
+INQ:3014:10:171179,1F00,7FFF
One of these is the HC-06. To find out we can use the AT+RNAME? command.

AT+INQ returns 3 values, the first is the address and this is the value we need. The second value is the class of the device and the third value is the signal strength (RSSI).
AT+INQ will only work if the HC-05 is in Master Mode and after a AT+INIT command.

To get the name of the found devices we use the AT+RNAME? command. The address is the first field returned by AT+INQ; A854:B2:3FB035 and 3014:10:171179.

When we enter the address we need to replace the colons with commas. The format is AT+RNAME?A854,B2,3FB035 and AT+RNAME?3014,10,171179
Of course, you would use the address of your HC-06.
HC-05_to_HC-06-HC-05_Connect03
You can see from the above. A854:B2:3FB035 is my TV and 3014:10:171179 is the HC-06.

Now we have the address of the HC-06 we can finish making the connection.

4. Pair the HC-05 with the HC-06

To pair we use the AT+PAIR=<addr>,<timeout> command.
Enter “AT+PAIR=3014,10,171179,9″ (no quotes)
If the HC-05 cannot pair with the HC-06 within 9 seconds you will get an error message. If the pairing is successful you will get an “OK”

5. Bind the HC-06 to the HC-05

Bind using “AT+BIND=3014,10,171179″

6. Set the HC-05 to only connect with paired devices

We do this with the CMODE command – “AT+CMODE=1″

7. Link to the HC-06

Use the link command AT+LINK=<addr>
In my case “AT+LINK=3014,10,171179″. If all is well you will get the “OK” reply.

HC-05_to_HC-06-HC-05_Connect04

The LED on the HC-05 should have 2 quick blinks every 2 seconds (or so).
The LED on the HC-06 should be on (not blinking).
You have now connected the HC-05 and the HC-06

Now that the connection has been formed, the HC-05 will automatically connect to the HC-06 every time they are turned on.

Once the connection is formed the HC-05 will switch to communication mode. If you want to continue with AT Mode then you will need to reset the module with pin 34 HIGH or with the button switch closed.

 
 

Test The Connection

On the HC-05, remove the connection to pin 34 and upload the following sketch to the Arduino connected to it. The sketch opens the BTserial at 9600 for communication mode.

// Basic Bluetooth sketch HC-05_03_9600
// Connect the HC-05 module and communicate using the serial monitor
//
// The HC-05 defaults to commincation mode when first powered on.
// Needs to be placed in to AT mode
// After a factory reset the default baud rate for communication mode is 38400
//
//
//  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)
 
 
#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() 
{
    // start the serial communication with the host computer
    Serial.begin(9600);
    Serial.println("Arduino with HC-05 is ready");
 
    // start communication with the HC-05 using 9600
    BTserial.begin(9600);  
    Serial.println("BTserial started at 9600");
}
 
void loop()
{
 
     // Keep reading from HC-05 and send to Arduino Serial Monitor
    if (BTserial.available())
    {  
        c = BTserial.read();
        Serial.write(c);
    }
 
    // Keep reading from Arduino Serial Monitor and send to HC-05
    if (Serial.available())
    {
        c =  Serial.read();
        BTserial.write(c);  
    }
 
}

Reset both Arduinos and remove power from the HC-05 and the HC-06

Power on the HC-06. The LED should be rapidly blinking 5 times per second. This indicates it is waiting for a connection or to be paired.
Power on the HC-05. The LED will blink a couple of times when first on and then change to a the regular pattern of blinking quickly every couple of seconds.
The LED on the HC-06 will turn on full time (no blinking).
The modules are now connected.

Open the serial monitors and what ever you enter in one will appear the the other and visa versa

Every time the modules are powered on they should connect. If you find they do not connect then cycle the power to the Arduinos. Sometimes the HC-05 will get stuck trying to make a connection. In this case the LED on the HC-05 will either
1. quickly blink 3 times every couple of seconds.
2. blink on/off twice a second.
This normally happens when the HC-06 is turned off and then back on again without resetting the HC-05.

The devices seem to connect more quickly when the HC-06 is started first.

 
 

Additional information

For more information about AT commands look at the HC-05 user guide or the EGBT-046S/EGBT-045MS user guide

Phillipe Cantin has a similar article here

 
 
Next step. Get Arduinos talking over Bluetooth. Arduino to Arduino by Bluetooth
 
 

68 thoughts on “Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Pair, Bind, and Link

  1. Reference: http://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-pair-bind-and-link/

    Hello Martyn,

    Great BT posts. Thanks for your efforts which have made it simple and clear what and how to work these fun and handy modules – HC-05, HC-06 & ZS-040.

    In your more recent post about pairing the HC-05 & HC-06 there are some typos. I’ve shown below. I may have missed others. I also have some suggestions for the article to help the readers, me ;-).

    I have some editing suggestions below:
    Clarifications
    Top of the document after first Arduino code reference/listing you write,
    “The LED on the HC-05… 5 times a second… device is in slave mode.” Rather than Slave Mode – This is actually indicating that the device is ready and waiting to be connected/paired. Not the mode?

    Typos
    Section 7. Link to the slave device
    -> “The LED on the HC-06 should have two quick…” (should be HC-05).
    -> “Now that the connection… HC-05… to the HC-05 every time…” (should be HC-06).

    Reference:
    It would be good to again reference techbitar as base for your AT command code. And if you used his other code for your other code also. I know you referenced him in another blog but, each blog stands alone so it is helpful to have references/statements throughout or begin having a bibliography and footnotes.

    Great layouts on your blogs. I find them easy reads.

    Additions
    * You mention to put the device into AT mode and do not describe how this is done. It would be helpful to add a link to the ‘How to’ of yours.

    * Ref. note to the ZS-040 to hold down the button to gain ‘full’ AT Mode and link to your description of the modes.

    * Method 2 for query of the device address. You give a great tutorial on how to gain a remote devices MAC address from the HC-05. It would be helpful in this blog describing how to setup two (2) BT devices how to simply query the HC-06 device for its address then type it into the HC-05. I did see this in another blog of yours.

    Hint/Tip
    At you connection description where you describe “the HC-06 no blink and HC-05… quickly every couple of seconds…” Add a note that when pairing with another HC-05 or the ZS-040 the two connected device’s LEDs will each quickly blink and pause in unison.

    Side Note:
    If you haven’t yet experimented – The Arduino IDE will run multiple instances of the same version on Windows. You can have the same version of the IDE with multiple instances by simply double clicking on the app icon for several mcu boards. I’ve been running the IDE this way for a few years. I commonly play with a couple boards at a time.

    Forgive me for my edit/suggestion note not being as complete and clear as your blog.

    Thanks again! Good stuff you have put on the net.

    Best Regards,

    Brian Stott
    Springfield, MO

    • Hi Brian, thanks for the kind words.

      I have started to add clarifications and to make the corrections. Some points I want to double check when I get time.

      I didn’t have a lot of time when I was doing this and obviously didn’t proof read it. I also changed the setup after I started the write up and missed some of the bits that should have been changed.

      While updating I did think about other things I have not tried or have not included. I will try to make further updates at the weekend. This is a regular pattern for me. As I think of new things I will go back end add to old posts.

  2. you said that: “the LED on the HC-05 should have two quick blinks every 2seconds (or so)
    the LED on the HC-06 should be on (NOT BLINKING)
    you have now connected the HC 05 and the HC 06″

    when i paired my master and slave module (both HC -05), they BOTH blink quickly twice every 2seconds.

    what does this mean?
    thank you :)

    • Not sure what the 2 blinks on the HC-06 means. On the HC-05 it normally means there is an active connection.

      When doing the above; pairing, binding and linking here are the LED patterns I get.

      Before pairing
      HC-05 – blinks quickly about 5 times per second
      HC-06 – blinks quickly about 5 times per second

      After pairing
      HC-05 – blinks quickly about 5 times per second
      HC-06 – blinks quickly about 5 times per second

      After binding
      HC-05 – blinks quickly about 5 times per second
      HC-06 – blinks quickly about 5 times per second

      After CMODE
      HC-05 – blinks quickly about 5 times per second
      HC-06 – blinks quickly about 5 times per second

      After linking
      HC-05 – blinks quickly 2 times every 2 or 3 seconds
      HC-06 – LED is on (no blinking)

  3. hi martyn,

    we’re having trouble pairing the modules. i connected the HC 05 (MASTER) to arduino NANO and the another HC 05 (SET AS SLAVE) to arduino MEGA.

    can you write a sketch for the SLAVE module using arduino MEGA?

    thank you :)

  4. hi Martyn,

    sorry for always bothering you but i need some help
    we already paired the 2 bluetooth modules and we tried to test the communication between the modules using the sketch below. The slave module is connected to a 16×2 LCD display.

    everytime we run the sketch, the slave status is “inactive”

    how could we make this active?
    thank you :)

    #include
    #include

    #define rxPin 18
    #define txPin 19
    #define lcd1 30
    #define lcd2 31
    #define lcd3 32
    #define lcd4 33
    #define lcd5 34
    #define lcd6 35
    SoftwareSerial master(rxPin,txPin);
    LiquidCrystal lcd(7,8,9,10,11,12);
    void setup() {
    Serial.begin(9600);
    lcd.begin(16,2);
    master.begin(9600);
    }

    void loop() {
    master.listen();
    if(master.isListening()){
    lcd.setCursor(0,0);
    lcd.print(“Slave BT Status”);
    lcd.setCursor(0,1);
    lcd.print(“ACTIVE”);
    }
    else{
    lcd.setCursor(0,0);
    lcd.print(“Slave BT Status”);
    lcd.setCursor(0,1);
    lcd.print(“INACTIVE”);
    }

    }

  5. Hi thanks for this nice post……. i could not connect my fc-114 HC-05 to my pc or android it shows “paired but not connected” could u please help me in this regard…..

  6. Pingback: Quick Links | Martyn Currey

  7. Hy Martyn
    Nice and useful blog you have.
    I want to connect an BT (as master) with and Android smart-phone (as slave)
    I followed you steps (RMAAD, ROLE,RESET,INIT,…,PAIR,BIND), everything is OK except LINK step which always finalize with FAIL and the BT enters in PAIRING phase.
    What is wrong ?

    Thanks you and all the best

    Mihai

    • Hi,
      I haven’t tried this but I suspect it is a problem with the PIN/pass code.
      The Bluetooth module doesn’t have the facility to enter a PIN when pairing. Try setting the PIN codes for the Android phone and the Bluetooth module to the same number.

  8. Thank for your post, I want to do the same using 2 HC05.
    I followed your instructions, but when it comes to testing I send from the master HC05 “abc” but I received strange strings in HC05 salve!!
    I set the baud rate to 38400 in both “buBTserial.begin(38400);”
    I also get both HC05 blinking twice every 2 seconds when they are paired.

    Any idea?

  9. Hi,
    Is it really necessary to make one device master and other slave ?
    I want to make an IPS and i want both my bluetooths to return RSSI values of each other and I guess slave can’t return RSSI values.
    I’ve searched everywhere but couldn’t find the solution
    Can you please help ?

  10. hi, if u having trouble in making into AT mode of HC-05 (ZS-040)(especiall if one having en/wakeup up pin instead of key pin). Follow they bellow procedure
    Power off HC-05 module.
    Press and hold small button above EN pin.
    Power on and keep pressing small button.
    Small LED should start to blink slowly about once every 2 seconds.

    for more info visit below site:
    http://abratukhin.blogspot.in/2015/04/connect-atmega328-with-hc-05-zs-040.html

  11. hello your post is great helpful to us thank you
    i want to ask you sth’
    im using two hc-06s.
    is it ok to use same with your scetch

  12. Thank you very much for this helpful tutorial.
    i connected my two module hc05 one on master mode the other on slave mode. My problem is that the slave one blinks like the master one: two times every two seconds. Is it really important ?

  13. sir , I am paired both HC-05 Bluetooth modules and when sending data it is showing in unknown letters like this ô ö

  14. Hi Martyn,
    nice tutorial!
    I was wondering how can I make the connection istantaneous. I have the HC-06 that has to disappear for 30 minutes and then it has to reconnect to the HC-05. How can I make the connection time shorter? Is there a way?

  15. Hi Martyncurrey,
    In this “+INQ:3014:10:171179,1F00,7FFF”. What is RSSI and how to convert them to distance?
    Thank you.

  16. Hi Martin,
    actually i have successfully paired the two, but when i check it using code it is giving values in a pattern when i ask for a single value.. plz help!!

    • If the characters appear to be random garbage or a pattern of irregular characters then you are likely to have an incorrect baud rate between one of the Arduinos and the BT module attached to it.

  17. Your post on connecting the HC-05 and HC-06 was very helpful, everywhere I have looked they just show you how to connect them physically and a quick glance at some AT commands. I should be able to use this to connect two HC-06’s ? My next question is what would i have to do to get an input (toggle switch, turning it off and on as needed) from one to turn on a LED on the other?

  18. Hello Martyn,

    I have successfully paired both the devices but there is no data being sent. I checked it in the serial monitor and I have the baud rate set correctly. Can you tell me what this issue could be? I am stuck with my project.
    Thanks in advance.

  19. Dear sir,
    i am currently doing my project based on BLE, am not getting OK response by serial monitor when i enter the AT command like AT+CMODE, AT+BIND and AT+LINK . so please give me the solution for the above problem sir.

    Thank you in advance

  20. Thank you for the post. It is very helpful. Now my hc 05 and 06 are being connected, but the communication is only one sided. if i write in the slave it does not appear in the master but when i do the reverse.i.e, write in the master i get it in slave. help me pls.

  21. can i connect 2 bluetooth module hc-06- hc-06 with 2 different arduino uno board ? please i need help if it is possible.

  22. hi i have a problem. i have sucessfully connect both the hc05 and hc 06 i can send from one to the other but i want the master to send automatically data from a photo resistor and when i receive it on the slave i have some weird characters. if anyone can help me it will be nice.

    • Weird characters are normally a sign of a wrong baud rate somewhere of misinterpreting numeric data as ascii (45 instead of “45”).

      Double check the baud rates the Bluetooth modules are using for communication mode and ensure the Arduino sketches are using the same.

      The double check how you are sending and receiving the data. Are you using the same data type at both ends.

    • yes it is but not all at the same time. You need to connect to them one at a time.
      Connect to BT #1. Get data. Close connection
      Connect to BT #2. Get data. Close connection
      Connect to BT #3. Get data. Close connection
      Connect to BT #4. Get data. Close connection

  23. Pingback: LED Brille für das Wrench Cosplay – Enjinia

  24. Ok I got this to work. Now what if the other side is not another arduino with a bt module running the same code but rather a relay board with a bluetooth module that you know takes string commands like 100 and 110 to turn off and on a relay. Is it possible to send it those commands from the arduino with bt?

  25. Hi Martyn,
    I’d like to mail to you on this more detail but I really fight hard to make these modules work with Arduino Micro. Not sure why eventhough I use serial1 instead of serial as the microcontroller is different than the standard Arduino; I can not manage to make these work.

    I simply can’t configure HC05 either. Tried different modules but nothing. Same modules work on regular UNO as well. Replaced the micro, no result. Micros are also tested, they are working well on other things too.

    So bottomline, if you had any chance that worked with Micro and these modules. can you please share the simplest AT configuration code you are absolutely sure that made it work with Micro?

    More on this may be found on the topic I already started weeks ago on Arduino forum:
    http://forum.arduino.cc/index.php?topic=415856.0

    Thanks in advance.

  26. Hi Martyn,
    Can i use Arduino uno instead to pair hc 05 with 06 together? Can I get the same result if I’m pairing with both HC 05 instead?

      • Hey Martyn,
        Thanks for the reply though and if i paired both HC 05 will i get the same result as pairing a HC 06 and 05 together. Do you have any idea what are the cons and pros of pairing HC 05 to 05 compared with pairing with both HC 05 and also do I follow this guide?

  27. Hello Martyn,
    Sorry to trouble you again, I have a few questions first do I need to configure both my 05 and 06 before following this guide? Secondly, is it a must to place resistors just for syn purposes as after I successfully syn I don’t need the resistors anymore and also I have tried using this guide but it doesn’t reply ‘OK’ back to me. Can you help please.

    • And also I see that you are using 2 nano with 2 breadboard to do the following but can i use 2 UNO with 2 separate port to connect 05 and 06? I’ve tried this but it seems that i can’t switch PORT separately. Whenever i switch to port 3 the other IDE follows. Please help..

      • The BT modules should have the same password and although not strictly required, it makes things easier if they have the same baud rate.

        The transmit and receive pins are 3.3v only. The resistors protect the receive pin from the Arduinos 5V signal.

        Based on my own experiments you will eventually damage the pin if you connect dirsct to 5v.

        Unos are fine and any 5V Arduino can be swapped with the Nanos.

        To get 2 separate serial monitors use separate IDEs. You can download a zip file / non install version as the second IDE and run it from the folder. The only requirement is that you need to have the drivers installed which you will have if you have already installed a Arduino IDE. I generally use 1.6.3 as the main IDE and 1.0.5 as the second. Or, use a better serial app / terminal program like putty or similar.

        Using one HC-05 and one HC-06 may make things a little easier. The process for binding and connecting is the same either way.

  28. Hi,
    Well written!
    I am having trouble getting my hc-05 state pin to work. It is always low, even when my android phone says it is paired. I have the zs-040 version with a built in button.

    I am trying to using the state pin as a trigger for a relay module. – That way, when my phone becomes in proximity to the circuit, it triggers the relay. It would have a ton of fun uses such as playing a tune when I enter a room, shutting of sprinklers so I can pass by unsoaked, keeping lights on only while I’m there, or unlocking and opening my garage door automatically as I approach.

    I read elsewhere that others have had the same problem with the state pin always being low.

    Perhaps it was the merchant I purchased the module selling a knockoff , or different firmware?

    Hopefully you can give my some tips and help!
    – Donovan

    • Hi,
      The STATE pin goes HIGH when there is an active connection rather than when the module is paired or in range.

      Although it can be used, Bluetooth 2/2.1 is not really suitable for proximity alerts. For this Bluetooth 4/BLE should be used. The advertisement/beacon feature of BT4 was designed exactly for this kind of thing.

Leave a Reply

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


six − = 1

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>