Modifying the HC-05 Bluetooth module defaults using AT commands

The HC-05, a Bluetooth to serial bridge, can be found for around $5 on the internet and therefore may be the cheapest way to add Bluetooth connectivity to your project.

However, its default settings may need to be changed depending on your application. [Hazim] explains a way to enter the HC-05 AT command mode to benefit from the rich set of features that the device can provide. The process is fairly simple as it only consists of maintaining the key pin of the HC-05 high while powering on. The device then boots in AT command mode with a default 38400bits/s speed and listens for all of the AT command set (PDF). As an example [Hazim] provides a sketch allowing you to write the AT commands directly in your favorite terminal.

With the basics out of your way you may want to further research the hardware, especially if you will be using modules from different sources. They don’t always come with the same firmware.

46 thoughts on “Modifying the HC-05 Bluetooth module defaults using AT commands

    1. Actually you can’t enter into AT mode by just taking one pin HIGH. It has to be high before you power the HC-05. Then you have to ensure the baud rate is 38400. Then you have to ensure you are communicating with the HC-05 via software serial since that’s the Arduino Serial Monitor is using pins 0 and 1. So it’s a number of little things that can throw off most hackers and waste considerable time when taking the HC-05 into AT mode. I have been there. These instructions could have saved me considerable time.

      1. seriously?? all it takes is googling ‘HC-05 + datasheet’… I don’t normally get annoyed, but when I do it’s because ppl don’t know how to find information on the internet :-P

        1. This “hack” can be done by anyone who just reads the datasheet. wow.

          This is possibly the lamest post on hack-a-day of all time.

          Reading the datasheet is a “hack” now? Come On hack-a-day, can you have some standards?

          Where do we draw the line?

          The next “hack” will no doubt be an “unboxing” – probably something like “how to remove an arduino from a UPS package”.

    2. dmitry, if you read carefully, I don’t think this was intended as a hack. It was meant to be an easy to follow guide on how to configure the most popular bluetooth module the HC-05. You should say thank you when people take the initiative to make our lives easier. I had a tough time configuring the HC05 and this helps. Just because you are a guru who can figure things out on your own, the rest of us humans still need some help now and then. if you think this is as simple as turning one pin high, you should try it then you will see what the docs have left out. So be nice or keep your opinion to yourself.

      1. Plenty of things are obvious after spending 6 hours trying every other way you can think of. Lost things are always in the last place you look, too.

      2. I agree, Kevin. Dmitry should keep his rude opinions to himself. I’m having a very difficult time with the HC-05. I have the LED flashing slowly indicating I’m in AT command mode but I get no reply from the HC-05 in the serial monitor. I don’t consider myself stupid as I’m an electrical engineer.

        1. I didn’t finish high school – it’s got nothing to do with being stupid or smart, or what job you do. Experience is all ;)

          As well as having power to pin 32(or whatever method you use to get to command mode) – the most common problem is connecting tx to tx and rx to rx, they need to be tx to rx at both ends.

          As you mentioned the ‘serial monitor’, I can safely assume you are connected via an Arduino and using the IDE. Are you getting anything back from the Arduino at all? You should – if you didn’t get “Enter AT commands:”, your PC>Arduino comms are incorrect.

          If you followed the Instructable, the Arduino to PC serial speed is 9600, the speed between the Arduino and the HC-05 is 38400.

          Check your tx-rx connections, check your serial speed, check your sketch. If all of those are correct, try changing your serial port to something else then back again – sometimes they get a bit screwed up.

          If everything is right, it is very straightforward. I found the first time I tried to do this, I over-analysed things and the simple error that held me up was that I had tx-tx and rx-rx. The next problem was having the pins connected one pin out – so what I thought was 10 was 11, what I thought was 11 was 12. Failing eyesight and a lack of attention to detail :)

    3. Hack or no hack this could have saved me countless hours of aggravations and frustrations. Before you tell people to RTFM maybe you should tell vendors and hackers to learn how to write.

    4. No, the ‘hack’ is to write a sketch and to wire up the arduino and BT module the right way, and to set pin 32 high to get into command mode.

      It must be so gratifying to have an ego larger than your intellect. I don’t know how you manage to live with us little people.

  1. The cool feature on these modules, is that with the right firmware, they can be used as master devices instead of slaves.

    I’ve put together a little setup that uses this and an arduino to interact directly with a mindwave mobile to light up a row of leds based on my perceived levels of concentration. Removing the need for a pc in there completely.

    1. read a wikipedia article on bluetooth – there are generally two classes of bluetooth devices. Class 2 has range of about 10 meters in direct LOS (vast majority of all devices are of this class). Class 1 devices achieve 100 meters. You can achieve more using directional antennas or even amplifiers just as with wifi and there exist special long range modules. It’s all a matter of price and practicality really. If I ever needed longer range I’d probably choose RFM22B – I personally never used one but they do seem pretty impressive

  2. i tried this a few months ago but gave up. the manual is a piece of s@#t. now i can change the settings. thank you for the instructions

  3. I used a bunch of pins or needles in a block of Sculpey (and an LED directly inserted – it had an internal resistor) to program the modules without soldering them to a board.

  4. I heard rumours that some HC-05’s secretly support a DTR signal. Some manufacturers in China say yes in correspondence but English wasn’t so good so I’m unsure. Has anyone had any success?

  5. kerimil: I see your name along with an army off your fake aliases pop up every time someone posts anything about arduino and bluetooth, always trying to start flame wars. grow up and get a life man. There are more important things in life than bluetooth and your project which you keep promoting as if the greatest thing since sliced bread. It’s just bluetooth dude :)

  6. Big like. I had to wrestle for hours with crappy HC-05 documentations when I should have been focused on my project. Unfortunately I gave up and bought a different Bluetooth transceiver. Time to dust off the HC-05 for the next project.

  7. this isnt working for me, i followed everything, and nothing happens when i open serial monitor and type AT. =/ frustrating

    1. I am trying to do the same thing and cant find out. if you managed to find a way can you inform me of how you did it?

      1. no i Didn’t got any way to do, but the thing which we can try is reducing the power. That what answer i got over irc, but i havn’t tried it yet.

        1. how would do i do that? i have two bluetooths, one connected to my initial project and one which has to portable. For the one conncted to my projected, i have it on a breadboard, can i just put resistors to decrease the power and for the wireless just give it a weak battery?

  8. Hello Everyone Eh Created a program to Set all parameters of a Hc-05 Bluetooth Module, arduino By,
    Is Very Intuitive and shows the potential of these modules,
    download:

    https://mega.co.nz/#!IlgEhL7D!49AyfrlgPI2pjhWUyRTMK85TBGRP-BbSxW712nDXsdg

    Various Tools As has:
    Slave Name
    The Error Manager
    The Finder Device
    Configure All in one
    etc
    Since the program is written in Basic, the Deputy Pograma compiled and Soft for uploading to the Arduino
    It is compatible with Arduino Uno, Duemilanove, Nano, MiniPro, Etc
    Requirements,
    Micro: ATmega328P
    Clock: 16Mhz
    Baud: 4800
    Send the CR at the end of any order.
    regards

  9. As for someone who has been working with digital electronics since the 8080 cpu, I welcome any and all insight. I’ve just started messing with arduino and find there is much more to HC-05 than one rule. There are many versions out there, are they all the same? I can see physically they aren’t some have 4 pin carriers, some 6. Is the firmware the same? IDK because I have yet to learn how to get to it. Am I dumb, no I’m inexperienced. So all you know it all’s give those fresh to the technology a break.

    1. John,

      The HC-05 is a designation given to the bunch of components used to make a Bluetooth SPP (Serial Port Profile) device.

      The chip can be from a number of manufacturers and the software stack can offer a bunch of different functionality, as long as it presents as an SPP and gives the kinds of features needed to enable an SPP, the components are less important.

      ‘HC-05′ seems to be a catch-all name to cover a bluetooth master/slave SPP. HC-06 is slave only, but the hardware is identical, within manufacturers.

      There are a number of different chips that offer BT services – from CSR there is the BC-417 which seems to be the most commonly used for SPPs: http://www.olimex.cl/documents/msds/Datasheet%20CSR-BC417.pdf

      The ‘HC’ designation was from Guangzhou HC Information Technology Co., Ltd., which was one of the main manufacturers of this sort of device, and like most things in China, when something is successful, others just jump on the bandwagon and name them the same.

      Further complicating things is that people name the carrier or ‘sled’ that the BTR module sits on as ‘HC05′, but it is just a breakout board offering up certain pins and voltage regulation to make using the modules easier. The most common one is the JY-MCU, but personally, I like to use the CZ-HC-05 module from GOMCU (http://item.taobao.com/item.htm?spm=a1z10.3.w4002-2105864473.9.tKArX6&id=36228408577) They are small, they have the right pins broken out for my needs, the firmware is good and they are cheap and reliable. They use the BC-417 chip, also.

      You can get different firmware from different manufacturers and they will all work – because they are all using the BC-417.

      An HC-06 is an HC-05 set to slave-only mode. You can re-purpose it to master/slave with a firmware change.

      One failing of the HC-05 modules for use with Arduino is that one of the coolest things you could want to do would be to upload your sketches over BT, but the HC-05 (and 6, 10,11) don’t have a DTR pin broken out. But it is certainly possible, as this AT command set of the firmware from Lairdtech indicates: http://www.lairdtech.com/brandworld/library/Bluetooth%20Development%20Kit%20AT%20Command%20Reference%20v2.7%20Download.pdf

      So, the extremely comprehensive Lairdtech firmware on a cheap HC-05 module from China? That’s my next project.

  10. i am using hc-o5 in my project so i connected this to my laptop using usb but i do not understand that the hc05 device is ON or OFF.How to recognize these?is there any led indicator on hc05 bt ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s