Jan 06 2013

Getting Bluetooth modules talking to each other

Before we start, please note that most Apple devices don’t support the virtual serial link profile that these modules use.

A really easy method of making your projects wireless is to use serial Bluetooth modules, these modules take standard serial data and transparently transmit it via Bluetooth to another connected Bluetooth module, no extra code is needed.

Adding Bluetooth to your project so it can be controlled by your phone is easy, just plugging in a slave module and connecting to it from your phone is all it takes, but getting 2 modules to communicate with each other is a bit trickier.

What you need to know
Bluetooth works by having a slave and a master. The slave modules can not initiate a connection to another Bluetooth device, but can accept connections, the master can be be set to either master or slave mode, when in master mode the module can initiate a connection to other devices. Be sure not to make the mistake of buying 2 slaves like I did! 2 masters or 1 master and 1 slave is what you need.
Sometimes eBay sellers don’t put much information about their module, to find out if its a slave or master check the following:

  Slave Master
Number of pins 4 6
Firmware Linvor 1.5 or HC06 HC05

The master modules (~£8) are usually a little bit more expensive than the slave modules (~£6).


The modules contain 2 parts, the back plane and the main Bluetooth board. The main Bluetooth part of the module is designed for 3.3V, the back plane board has a 3.3V regulator built in so supplying 5V for power is fine, but there is no level conversion for the serial data, you probably don’t need to level convert the output (TXD) data since most 5V controllers see 3.3V as high, but the serial input (RXD) does need conversion, a voltage divider or resistor and zener diode will do the job.

Divider Zener
bt_res_div bt_zener

To configure the modules you will need a USB to serial converter, search for CP2102 on eBay or DealExtreme and you should be able to find them for less than £2, I’d recommend you get 2 so you can have both slave and master connected to your computer at the same time, make sure at least one of the converters has a 3.3V out as well as 5V out.

Connect the serial converter and Bluetooth modules like so:

Module Converter

The serial converters usually use 3.3V signaling for serial, so no level conversion needed.
You will need a serial console program, I use RealTerm.

The slave module can be configured whenever no other BT devices are connected to it, the default baud rate is 9600, no parity, 8 data bits, 1 stop bit. Once you’ve opened the COM port in your serial console, type AT, the module should reply back with OK.
The timing of sending characters is important, if you type too slow the module won’t recognise the command, it will see it as 2 separate commands A and T, its probably best to copy & paste.
To check the firmware copy & paste AT+VERSION and it should respond with OKLinvor1.5.


Set PIN:

There are only a few available commands for slave modules –

Command Info
AT+BAUD<setting> Set baud rate
1 – 1200
2 – 2400
3 – 4800
4 – 9600
5 – 19200
6 – 38400
7 – 57600
8 – 115200
9 – 230400
A – 460800
B – 921600
C – 1382400
AT+NAME<name> Name – Max 20 characters
AT+PIN<number> PIN – 4 digit number

Master (and master as a slave)
Configuring the master is a little different from the slave, there are 2 ways to put the module into AT mode:

Method 1

  • Turn off module
  • Connect the key pin on the module to 3.3V on the serial converter
  • Turn on module

The baud rate will always be 38400 with this method, the module must also be power cycled to get back into normal mode.

Method 2

  • Turn on module
  • Connect the key pin on the module to 3.3V on the serial converter

The baud rate will be whatever it’s configured to, default 9600, the module can be put in and out of AT mode without being power cycled.

Quick Check
The timing of commands doesn’t matter with the master modules, instead you need to end each command by pressing the enter key (\r\n), sometimes the response will be continually repeated, pressing enter again will stop it.
Entering AT should return OK, entering AT+VERSION? should return something similar to +VERSION:2.0-20100601


Master as a slave
If you’ve got 2 masters you will need to have one operating as a slave which isn’t too hard to do:

Reset to defaults:

Clear any paired devices:

Set PIN:

Slave mode:

Get the address of the device:
Now that you have the address you can skip the AT+INQ and AT+RNAME? parts for configuring the master.

Turn off the module, disconnect key from 3.3V and turn back on.


Master as a master
Now, to get the master to connect to the slave module you will need to find the address of the slave. Make sure the slave module is powered up and enter these commands into the master module:

Reset to defaults:

Clear any paired devices:

Master mode:

Need to restart after changing role:

Allow connecting to any address:

Inquire mode – Standard, stop after 5 devices found, (or) stop searching after 5 seconds:

Set PIN, should be the same as the slave:

Start SPP profile lib (needed to do any Bluetooth transmitting/receiving):
Note: If it says Error:(17) then that means it’s already loaded, you can carry on.

Start searching:

A short list of devices found should appear, one of them will be the slave module.


The format of the output is as follows:

Type can be ignored. The signal will be 7FFF since inquire is in standard mode, in RSSI mode you’ll get a load of the same device but with different signal levels which you don’t want at the moment.

Copy the address part of the devices found, for example 12:3:289431 and change the colons to commas – 12,3,289431. To find out which device is the slave module you will need to query each address for its name:
AT+RNAME? <address>

Replace <address> with address of device like 12,3,289431

Response should be +RNAME:linvor if you’re using a normal slave module or +RNAME:HC05 if you’re using a master module as a slave.

Now you’ve got the address of the slave module you need to pair with it:
Note: If you are going to make the master connect to your phone then you need to set the timeout long enough for you to type in the PIN.

Bind address:

Only allow connecting to the bound address:

And now to actually connect:


If successful the slave LED should be on solid and the master LED should have a heartbeat flash pattern.

The modules have now been configured! They should automatically connect to each other whenever possible.

A full list of commands for master modules can be found in the download below.

Sending data
Now, if you entered AT mode on the master module by connecting key to 3.3V before turning on the module, you will need to turn off the module, disconnect key and turn it back on.
If you connected key while the module was on then all you need to do is disconnect key.

If you open up 2 serial consoles and have one open the COM port to the slave and the other open the COM port to the master you should be able to type in one and it will appear in the other console, if that worked you just need to plug them in to your projects!


Extra stuff
The Bluetooth board of these modules also have connections for SPI, USB and PCM audio, no idea if they work or not.
It also seems to be possible to upgrade the firmware on the modules too, making it possible to put master firmware onto a slave module – http://byron76.blogspot.co.uk/2011/09/i-hope-you-have-good-time-soldering.html


btinfo_20140510.zip (564.28 kB)
Bunch of pdfs and stuff with Bluetooth commands and info
Downloaded 571 times
MD5: BA64E38C473F7E2E21EC91A92996CFB5

btinfo_20130106.zip (243.41 kB)
Bunch of pdfs and stuff with Bluetooth commands and info
Downloaded 502 times
MD5: 9E79AD4A022DA1D4A0D694A2F6E35541


2 pings

Skip to comment form

  1. James

    Can you send me a hi-res image of the components on the backplane of your bluetooth modules? Or can you get the numbers off the regulator so I can make a backplane? The bluetooth modules I ordered did not come with a voltage regulating backplane and I plan to work in the voltage conversion circuit you diagrammed above so its all compact.

    1. Zak Kemble

      I couldn’t get a decent photo, but the number of the regulator is 662K. The backplane just contains a 3.3V regulator, some capacitors for the regulator, an LED, a resistor for the LED (2.2K), a resistor for pulling down the key pin (10K) and a diode to to protect against wiring power backwards. Any 3.3V regulator that can supply 50mA will work.

  2. bbb

    Do I have to set some setting on the module before use first time with microcontroller?

    1. Zak Kemble

      No, once configured they should just work with the microcontroller.

  3. raheela

    i have interfaced HC05 bluetooth module with arduino.. i also changed the name and password using AT commands but it doesn’t inquire device when i enter AT+INQ command.. plz help me regarding this issue

    1. Zak Kemble

      Does it just reply with OK and no list of devices after a few seconds? And what kind of device is it meant to be looking for (phone, another BT module etc)?

      1. Fred vom Jupiter

        I had exactly the same issue. Module is HC-05 with backplane that has a push button to put it into AT command mode (bought from Banggood). Most commands worked okay when powering up the module with the button pressed. Commands like AT+NAME? or AT+INQ are only working for me, when putting the thing into command mode AFTER applying power.
        For the moment this leaves me with manually pressing the button as it is not connect to one of the pins. This can be quite challenging (missing a third hand) when you want to enter a couple of commands. I just found that using a crocodile clip can be used to press the button as a workaround.

  4. yong

    why i enter command at+init , it does not reply?

  5. yong

    i solved the problem
    but i can’t c other bt module on my device list after enter command at+inq, it only reply ok

    1. Zak Kemble

      Hmm, maybe the CLASS has been changed, try entering this:
      and then search again.

  6. NicoHood

    i’ve been searching through almost the whole internet about information how to use the HC-05 as a master. This is the only tutorial i found which explains what commands you actually need to type in. Getting into AT mode wasnt that problem. So thanks for sharing this information! :)

    What i try to do is to connect my HC-05 device with my Wii-Mote. Sadly noone ever did that before with “real hardware”, only with usb doogles and windows/linux software. But what i want to do is to connect with my HC-05 (or whatever else i should buy) with my Wiimote. The HC-05 is connected with my Arduino so i can controll the communication very easy.

    The problem is that i cannot pair the two devices. I read that you dont need that for the Wii-Remote and linking should be fine. But i cant get a connection, it always says FAIL. Getting the Address and the name just works fine. It also responds to the inq. Maybe you can help me or know any website where i can get information/help to get this working?

    The only website i found about how the Wii-Remote works is this:

    It also sais that SPP is NOT supported. Does this mean that i can give this up?

    Here is another Datasheet what covers the Errorcodes, you might want to add this to your post:

    I got the HC-05 connected to the PC as slave (just connected after received the package and powered the module). Pairing as master might work, i am not sure. Windows sais error but my toshiba bluetooth stack wants the pin from me and the hc-05 saves the connection. At least my old sony ericsson k610i is connected properly but i do not know how the protocol works, will check this out now. (dont wanna destroy something).

    One thing i want to mention: I was confused: in your tutrial you switched the cmode possibly? the datasheet sais 0 and 1 the other way around. Not sure what is correct.

    It would be nice if you can help me or just tell me that my project just wont work :D

    1. Zak Kemble

      If the Wii-remote doesn’t support SPP then these Bluetooth modules won’t be able work with it, don’t waste your time trying it get it so work :P
      CMODE 0 and 1 are the wrong way around, fixed. Though it can probably be left at its default 0 in this situation. Thanks for the datasheet, I’ll add it to the download.

  7. Lars Ole Belhage

    You saved my afternoon – after spending lots of time seaching for linux/mbed/bluez and other farout topics – I found your guide a blessing – 20min’s, and my 2 hc0x’s chatter like teenagers stapped to their breadboards ;)

    Thanks a lot
    Lars Ole

  8. ramin

    thanks for the phantastic tutorial!

    i was just wondering whether it’s possible to connect multiple slaves to one master?
    the idea is to have one “controller” and a couple of slaves that can be controlled by the
    one controller. i know that the standard arduino itself has just one serial port but the question
    is whether the bt master module can connect at all to a couple of slaves.
    i could imagine that if this is possible, we could find some wiring where the arduino
    would actively use the key-pin and direct communication to different slaves by connecting
    to the respective one via some AT commands.

    1. Zak Kemble

      Yeah it’s possible, but only 1 device at a time. The AT+DISC command will make the master disconnect and then you can run through the AT+PAIR and AT+LINK commands to connect to another BT device. Just set the key pin HIGH when you’re dealing with commands and LOW when dealing with data (once you’ve connected). You can do the AT+INQ and AT+PAIR commands while still connected to another device, but make sure you disconnect before the final AT+LINK otherwise the master will bug out.

  9. wesch

    Hi, I’m a beginner with BT, bought my HC-05 today (mounted on a BT Shield V2.2 for Netdiuno). First I’ve tried to see, if my phone can finde the device and it did. I also could connect.
    Then I started to discover it and wrote a small programm to handle AT commands. Since I’ve set Baudrate to 9600 first I couldn’t estabish a connection. Then I set the correct Baudrate, sent AT and got an ERROR back. My idea was, I have something misconfigured with the first Trials, the correct reason was some pending AT commands from previous trials.
    But since the ERROR I decided to send AT+ORGL. I think this was a mistake. The the device name changed, I found another on my phone. Then I changed the Name, AT-NAME? gives me the correct one.
    But now the HC-05 is no more shown on the phone or laptop.

    What do I have to do to get it back shown on other devices?
    I send the following commands:
    AT-STATE? which respondes “INIZIALIZED”, I assume it should be “PAIRABLE”, right? What am I missing.

    1. Zak Kemble

      CMODE and CLASS are only for master mode (ROLE=1). STATE returning “INIZIALIZED” is correct because in slave mode (ROLE=0) the module is only pairable/discoverable after setting the KEY pin low (or disconnecting the KEY pin).

  10. Samuel J Garcia

    Hello! I followed this tutorial and everything worked, congrats and thank you!

    I have a question, maybe you could help me:

    I have a HC-05(Master) and other HC-05(Slave), they are paired and connected, there’s a way to send an AT command thru HC-05(Master) to work with some HC-05(Slave)’s PIO?

    Thank you

    1. Zak Kemble

      No problem :)
      As far as I know there’s no way of directly sending commands to other connected BT modules. You’ll need a microcontroller connected to the slave to receive and store the command, put the slave into command mode and then send the stored command to it.

  11. Gursehaj

    I bought the module and it was HC-06 …..

    It doesn’t have Key pin but it have Wakeup pin on it.

    I can’t get it to work on AT mode !!!!

    1. Zak Kemble

      HC-06 is the slave only module. It’s in AT mode only when it’s not connected to another device (like just after turning it on). I don’t think the wakeup pin does anything with HC-06 modules.

  12. Jimit

    Hi Zak,

    Thanks for great tutorial.

    I am trying to connect HC 05 module in master mode with Android phone : “AT+LINK=” command but is always shows “fail” indication.

    HC05 is been paired successfully, also AT+FSAD= is working successfully.

    please help on how to connect master mode of HC05 with android mobile.

    Thanks in advance.

    1. Zak Kemble

      Your phone needs to be running an app that uses the serial port profile, like this one.

  13. Saurabh

    Thanks for the great Tutorial.
    I am trying to communicate between 2 AT89C51 MCUs using HC05 module.
    Currently struggling to get into AT command mode. Do I need to have MAX232 while connecting HC05 to PC using RS232 to serial USB converter.

    I am able to pair HC05 (while connected to AT89C51) using Blueterm app in Android. And it sends and receives data perfectly.
    But, I want to know is it possible to use one HC05 (connected to AT89C51) as master and other HC05(connected to other At89C51) as slave and these communicate.
    Also, can I configure AT commands by having program in AT89C51, i.e. changing the frequency of oscillator in AT89C51(through program) to the one that matches AT command mode i.e., 38400.

    Please help me.

    1. Zak Kemble

      MAX232 is only for interfacing 5V/3.3V serial devices with real serial ports which use voltages around -12V to +12V. A serial USB converter doesn’t deal with voltages above 5V so no MAX232 is needed.
      HC05 modules can be configured as master or slave and can communicate with each other once connected. They can be configured by a microcontroller the same way as you would with typing the commands in with a serial terminal program; send “AT+RST” over UART and the module will reset.
      Normally you would know the baud rate beforehand and therefore already know what clock frequency and UART divider values you should use for the controller.

      1. Saurabh

        In that case I have set Baud rate for AT89C51 as 38400. And HC05 is in AT command mode (Key pin is high – I get LED blink rate of 2 sec).
        Now should I try sending “AT\r\n” (ASCII values of \r and \n followed by “AT”) from microcontroller to the HC 05.
        I have connected LCD to check the response from HC05.

        I have been trying sending AT commands to HC05 (by connecting it to PC using USB-serial converter). In this case, there’s no MCU involved.

        HC05 – USB to serial converter
        Rx – Tx
        Tx – Rx
        Key Pin (connected to 5.5 V)
        VCC (connected to 5.5 V)

        I use Docklight, Teraterm and RealTerm on PC (Set baud rate as 38400 and Transmit as CR+LF)
        But I observe nothing getting received in response of the AT command that I send through terminal on PC.
        I observe constant 3.3 V on Tx pin (of USB to serial converter). But Rx remains always 0.
        I also tried adding Voltage divider of 3.3 V at Rx and in that case I get Tx and Rx pin (on USB to serial converter) always 3.3 V
        But no response is seen from HC05 on terminal.

        Kindly help me. Thanks a lot

        1. Zak Kemble

          The key pin should have 3.3V, not 5.5V and VCC should only have 5.5V if the module has a built-in 3.3V regulator (they usually do).
          Have you verified that the serial converter is actually sending data when nothing connected? And that it can also receive data from other devices that are known to work?

  14. Darkbyte

    It does help. My two HC-05 talked each other successfully by following your steps. Just one question, after power-off and power-on again, the connection could not be recovered automatically, anything I missed ?

    1. Zak Kemble

      Odd, the module should automatically save and load the settings. Does running AT+BIND? return the correct address and AT+CMODE return 0?

  15. Chris

    thx for that tutorial. I’ve got an arduino nano rev.3.0 clone and tried the AT-Command-Mode with the hc-05-modul. The baudrate on the arduino is 9600 and from arduino to the hc-05 is 38400. But when I start and type AT i’ll get strange signes but not really an “OK”. When I test the Modul with an USB-TTL-(FTDI)-Adapter it works fine with Realterm. So there is an Problem with the Commication of the arduino and the hc-05-modul.
    The hc-06-bluetooth-modul works with the USB-TTL-Adapter and the arduino nano clone.
    I hope you can help me to get the hc-05-modul working on the arduino nano.
    Greetings Chris

    1. Zak Kemble

      >The baudrate on the arduino is 9600 and from arduino to the hc-05 is 38400.
      Are you using software serial for the 38400 baud part?
      Sounds like a baud rate mismatch somewhere.

  16. david

    hey, trying to get my hc-05 to auto-connect with my android phone. I have the hc-05 as master and following your steps everythings works great up until AT+LINK command, just says

    +INQ: (my address here)

    any ideas why? it pairs and binds up fine

    1. Zak Kemble

      It’s been a while since I last did this, but from what I remember you need to have an app running on your phone to accept new connections. I used this one – https://play.google.com/store/apps/details?id=com.sena.bterm

  17. Sachin

    thanx for that tutorial . i am a beginner with BT, SPP etc.
    i have hc-05 module. Is it possible to send/receive .txt file from android to microcontroller( which interface with hc-05 and sd card) or microcontroller to android.? is SPP support file transfer?

    1. Zak Kemble

      SPP just sends raw bytes so you can send any type of data, but you need to implement some kind of protocol (an existing one or make up your own) so each each end knows what is going on, like for sending a file you might want to tell the receiving end the size of the file, but what happens if a few bytes are lost or the transfer is stopped early? etc etc

  18. Zubair

    I have an Android Phone, HC-05 gets paired with my phone (configured as Master) same as your steps.

    But when I have issued the command, AT+LINK=, It gives me error.

    Please recommend me with your valuable suggestions.
    @David, You also have the same issue. Please update me with solution.

  19. Zubair

    I have also installed the Sena BTerm APP. But still no Success.

    Is I need to do any setting in Sena BTerm APP?

    1. Zak Kemble

      In the Sena BTerm App go to Menu > Bluetooth Configuration > configuration > Mode > Set to ‘3: Listen To Any’ > Apply then do the AT+LINK command. Once it connects, disconnect the KEY pin and you should be able to type stuff and it will appear at the other end.

  1. Telemetry: Bluetooth | Abboud's Corner

    […] Before connecting these modules to the scanner and stm32, you have to set the modes, one to master, and the other to slave. There is already a great blog that describes these steps, which I used to set my modules. Getting-Bluetooth-modules-talking-to-each-other, by Zak Kemble […]

  2. Pairing two HC-05 bluetooths with each other using arduino mega

    […] should help. http://blog.zakkemble.co.uk/getting-…to-each-other/ Reply With […]

Leave a Reply

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

6 + 2 =

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=""> <strike> <strong>