Using the HC-05 Bluetooth RS232 Serial module for cheap wireless communication between your PC and Arduino

Using the HC-05 Bluetooth RS232 Serial module for cheap wireless communication between your PC and Arduino


I recently purchased the HC-05 RS232 serial bluetooth module from eBay. These modules sells from $10 to $20 including shipping. My plan was to use it as a economic wireless communication tool between PC and the Arduino board. The module has built-in Serial<–>Bluetooth protocol converter. Therefore it can be connected directly to Arduino serial pins without any ttl level translator chip and with a few external components. One thing to note though, the seller I purchased the module from on ebay had the wrong schematic posted on the listing which was meant for a older version of this module. So depending on which version you have, you will have slightly different pin connection for the AT command enable pin and led indicator pins. The major difference between the two version of the module is, the newer version works in both master and slave mode depending on how you set it up via AT commands and improved firmware. The specification of this module is as follows:

● Bluetooth protocol:  Bluetooth Specification v2.0+EDR
● Frequency:  2.4GHz ISM band
● Modulation:  GFSK(Gaussian Frequency Shift Keying)
● Emission power:  ≤4dBm, Class 2
● Sensitivity:  ≤-84dBm at 0.1% BER
● Speed: Asynchronous:  2.1Mbps(Max) / 160 kbps, Synchronous: 1Mbps/1Mbps
● Security:  Authentication and encryption
● Profiles:  Bluetooth serial port

Power supply: +3.3VDC 50mA
Working temperature: -20 ~ +75 Centigrade
Dimension: 26.9mm x 13mm x 2.2 mm

Here are the data sheet, example schematic for this module:

BC4_Bluetooth Module Datasheet.zip (1.12 mb)

The schematic I used to connect to arduino is as follows:

This can be used as a cheap way to talk to your Arduino wirelessly and debug your quad copter over serial port without using the relatively expensive XBee modules, even though you will not get as much range as the XBees.

Here is my version of the break out board.

Figure: Front side of the break out board.

Figure: Back side of the break out board.

Testing the module with MultiWii quad and configuration tool:

42 thoughts on “Using the HC-05 Bluetooth RS232 Serial module for cheap wireless communication between your PC and Arduino

  1. Kai

    Thanks for your reply. But my questions was, why to use a resistor in TX (!) line (regardless which size).
    I know that using a voltage dividor in RX is needed to come get it from 5V down to 3.3V. But TX is 3.3V going to the Arduino…

  2. Teejay

    Hi Pial,

    I have the same bluetooth but the one i bought is the master not the slave one. Now i got this bluetooth working on uart interfaced to my microcontroller.

    The problem is that when i want to change the name,password,baud etc. i cannot go to the AT command via serial com in pc

    i already put the PIO11 in 3.3v or high level and still no response to any AT command. Everything is check even the connections, level converter.

    Thanks
    Teejay

  3. pial

    Hi Teejay,
    There are couple of firmware versions available for this module. You will need to check the data sheet or manual that is provided with your module. Your module could be programmed in a different way. Therefore it may not respond to AT commands exactly the way my modules did. Hope this helps.

  4. Anand Dhuru

    Hi, I have been trying to get an answer to this; hoping you can help!

    I understand the ratio of resistors in the voltage divider for the Rx line. That is when you connect it to a TTL micro, right?

    So, when one connects the module directly to a PC (real serial port, NOT USB-to-serial), wouldnt these have to be changed, to say 10K and 2.2K? Would like to be sure before I toast my module!

    Regards,

    Anand Dhuru

  5. pial

    Hi Anand,
    The voltage divider is used to lower the voltage to a tolarable limit of the module. When you are connecting it to the PC serial port, I believe the voltage will be more than 3.3v; which is the operating voltage of this module. So you will need a voltage divider to manage the voltage on tx/rx lines. Check this page to calculate your resistor values: http://en.wikipedia.org/wiki/Voltage_divider

    Hope this helps.

  6. Anand Dhuru

    Of course! I was being very dense. I now realize the module, when connected to a PC, will be thru’a level shifter (like a MAX232), so will not have to deal with non-TTL levels at its input. So, just a drop from 5 to 3.3 is what is required.

    Thanks for the prompt response.

    Regards,

    Anand

  7. Pooya

    Pial, do you know how I could set this module (HC-05) to low-power (energy-saving) mode? I’d really appreciate it if you could help me out.

    Thanks
    Pooya

  8. Andre Matos

    Pial, I use same module, but I don’t put resistor on tx / rx line, and my status led only work only on pin 24 (http://www.gemmarduino.com/PM-1/00100-002/datasheet.pdf page 4 ) , Bluetooth parity work ok on mac osx , what baud rate you are using ? I set mine as 115200 , configured with AT command with usb rs232 ttl ( http://wiki.openpilot.org/display/Doc/Serial+Bluetooth+Telemetry ) with pin 34 on 3v3 ( hight level ) .. but my setup don’t work with my multiwii GUI … start, connect to bluetooth , but don’t star cycles, and sensors graph .. Thanks for any help and idea … best regards, and great job, sorry bad english. Andre from Brazil

  9. pial

    Hi Andre,
    One major reason for the multiwii configuration to unable to communicate with the BT module is the BT stack installed on your mac/pc. I am not exactly sure about mac, but on my pc I had to install the toshiba bluetooth stack to make it work. Hope this helps.

  10. Marcelo

    Hello Pial,

    I’m sorry i did a mistake and called you Pail instead of Your name in the earlier note.

    Can you help me with the above

    best regards,
    Marcelo

  11. pial

    Hi Marcelo,
    I heard there are couple of variations of this module in the market. However, I was able to see only two of the variations. The picture posted here in this post with one of the chip marked as MX… is the HC-05 version, at least at the time I purchased the modules. The HC-04 module had a different chip (that was not marked as MX…). This module runs on 3.3V, so it will be a good idea to use a level converter/voltage devider between the rx/tx pins of the module and your microcontroller just to protect the module from over voltage damage. If you already have a toshiba laptop and it has the BT stack installed, you should be good to go. I had a dell and needed to install the toshiba BT stack on it.

    I hope this helps.

  12. Mehqui

    Hi Pial,

    I’m doing a same project, but i need to integrate this module with Android plataform…

    But at this moment, i had a lot difficult to communicate with bluetooth module… Apparently, my bluetooth module doesn’t responding… I don’t know why…

    I’m trying to do a simple communication by UART interface on AT mode… i don’t no why doesn’t working…

    Have some idea?
    Maybe you can help me…

    thank you

  13. Khan

    Hi Pial,

    Please help me with the bluetooth module, i want to change the baud rate and the pairing info, i used a usb to ttl adapter, connected TX, RX of USB to ttl to RX, TX of Bluetooth Module respectively and applied 3.7V to the Bluetooth module(made sure that its not in paired mode, Led flashing) – The problem i have is, as soon as i open session – hyper-terminal or putty or any com tool, the BT module is contentiously sending non stop ‘Y’ kind of characters
    "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ"

    This is what i bought off ebay : "NEW Serial Bluetooth RF Transceiver Module RS232 Master + backplane 4 pin TTL"
    Item No: 110805911219

    I tried going through all the google searches but no vail, please help. Thanks in advance, Khan

  14. pial

    Hi Khan,
    From your description it seems you do not have the correct baud rate set up in your terminal connection. Try changing the baud rate to match the one specified in your user manual and you should see correctly decoded characters on hyper terminal.

    I hope this helps and good luck.

  15. Khan

    Thanks Pial,

    As per the product description provided by the seller the default baud is 9600, i will try all the available baud rates and will get back to you. Thanks again for the help.

    >My other concern is (when connected to ttl adapter to modify the values), even if nothing is issued to the BT Module, its continuously sending data …not sure y, do i have to pull up High – to the Key Pin ? and is there a way to identify what Module i am using, like HC04 or 05 or 06 .. ?

  16. Mehqui

    I think your problem is with baud rate…
    I had the same problem here… I changed the baud rate so many times to discover the correct baud rate of communication… When the baud rate is wrong, you will receive this kind of characters…

    When i changed the baud rate to 115200, the communication works…

  17. Khan

    Thank you Pial and Mehqui,

    I am not sure what fixed it, but i was finally able to change the baud and pairing info.

    I tried all the baudrates this time but nothing worked, all these time it would not even display those wierd characters and would never go into pairing, i tried 2 different rs232 to ttl boards nothing worked.

    What my guess is, this time i soldered the tx,rx, gnd directly on the BTModule it self and used 9600 Baud, And was good to go.

    So i am guessing a simple loose connection might have caused it, i didnt do any pullup or reset as mentioned at few places on googling..

    By the way, i found this tool to be very helpful, you can type the AT+ command and then click send.. i was not able to do that on Hyperterminal

    http://musicshield.googlecode.com/files/sscom32E.exe

    Thanks guys for the help.
    Good luck.

  18. bambuko

    Thanks Pial !! – very useful, although might a bit too late for me? :-)
    Before I have found your blog I have connected my TX directly without voltage divider (at 5V) – I guess I have fried it? because now even with divider it doesn’t work :-(
    Or do you reckon it might have survived 5V and there is something else wrong with my setup?

  19. bambuko

    Just a follow up to my yesterday’s comment:
    No I didn’t fry it up! :-)
    After a bit of googling I have discovered that I needed MAX232 or MAX233 (I used the latter because it was easier to use) – my logger (which I have been trying to connect to BT module) was RS232 and the module requires TTL.
    All is working perfect now – thank you.

  20. B M Sangati

    Hi all,
    i used 29lv800bbxei-70g bluetooth module ,here i faced one problem this device detected first 2 times when power ON and OFF. But 3rd time not detected i checked 4 modules same problem so please any one help me how to test this module.
    regards,
    B M sangati

  21. Varma Naidu V

    Hi,
    I am not able to detect this module through and android phone. I am able to detect it through my nokia phone and all laptops but not android phone.
    is there any reason, can you help me on this?

  22. pial

    Which android phone are you using. Is the bluetooth hardware on the android phone of higher version than the bluetooth module module? I believe you need to have bluetooth v1.1 or v2.0 hardware on the android phone. I can not think of any other reason but the hardware compatibility in this case. Please check the specifications of your android phone and the bluetooth module.

  23. Fadi

    I am wondering, and could not find any definitive answer online. Does the master mode support multiple active connections?
    (BT 1.1 / 2.0 dictates piconets and multiple active connections/slaves)

    Thanks

  24. ashwini

    can 3 bluetooth modules interact simultaneously ? how to program it ? i am using arduino with bluetooth . kindly replay soon ..

    regards Ashwini

  25. david

    Hi

    I want to use HC-05 for projects in my schoole using MCU 8051.

    Is there any schematic for it ?

    Where can I find C code for it ?

    Thnaks

    Solemany

  26. viki

    hi pial
    iam using this module to control my bot using mobile…iam having app in my mobile to communicate ….i connected tx, rx, 3.3, gnd pins to arduino.. i didnt used 31,32 pins . my device is detected in the app…nothing happns that is bot not moving ..iam usin following code

    #define lp 9
    #define ln 8
    #define rp 7
    #define rn 6

    int val; // Variable to receive data from the serial port

    void setup() {

    // initialize the digital pins as output
    pinMode(lp, OUTPUT);
    pinMode(ln, OUTPUT);
    pinMode(rp, OUTPUT);
    pinMode(rn, OUTPUT);

    Serial.begin(9600);
    }

    // Read serial port and perform command
    void loop () {
    if (Serial.available()>0) {
    val = Serial.read();
    switch (val) {
    case ‘D1′:
    digitalWrite(lp, HIGH);
    digitalWrite(ln, LOW);
    digitalWrite(rp, HIGH);
    digitalWrite(rn, LOW);
    Serial.println(" go straight");

    break;
    case ‘D4′:
    digitalWrite(lp, LOW);
    digitalWrite(ln, HIGH);
    digitalWrite(rn, HIGH);
    digitalWrite(rp, LOW);
    Serial.println("back");

    break;
    case ‘D2′:
    digitalWrite(ln, HIGH);
    digitalWrite(lp, LOW);
    digitalWrite(rn, LOW);
    digitalWrite(rp, HIGH);
    Serial.println(" left turn");

    break;
    case ‘D3′:
    digitalWrite(lp, HIGH);
    digitalWrite(ln, LOW);
    digitalWrite(rn, HIGH);
    digitalWrite(rp, LOW);
    Serial.println(" right turn");
    break;
    }}}

  27. pial

    Hi Vicky,
    Looking at your code I see issues in the case statement. Please note that Serial.read() returns you one character byte at a time. Meaning if you are trying to read D1, you need to put the input in a buffer and run the case statement when the buffer reaches two characters. Instead, you can go with the simple approach and write the case statement for one character, Like instead of D1, use 1, D2 for 2 etc. and send the commands accordingly from your remote control device over bluetooth.

    Hope it helps.

Leave a Reply

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


6 + = fifteen

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>