How to enter AT mode in HC-05 bluetooth module

Hi guys, I'm new to arduino and electronics so please bare with me. I've been trying to enter AT mode with a HC-05 bluetooth module (http://www.ebay.ca/itm/180957186752?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649). This is what I did;

  1. I used a USB to Serial adaptor (http://www.ebay.ca/itm/170910289160?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649).
  2. Connected TX bluetooth to RX adaptor, RX bluetooth to TX adaptor (Via a voltage regulator http://www.instructables.com/id/Cheap-2-Way-Bluetooth-Connection-Between-Arduino-a/step3/Wiring-the-Arduino-Bluetooth-transceiver/).
  3. Connected power (3.3v) and ground (I used a voltage regulator to bring the 5v from the adaptor down to 3.3v).
  4. Then I connected pin 34 bluetooth (PIO11) to 3.3v (To make the pin go high).
  5. Opened PuTTY and set it to Serial mode. Used COM8 (the USB to Serial adaptor COM port) and 9600 baud rate. (When this didn't work I also tried 38400 baud rate).
  6. In the terminal section of PuTTY set Local echo to Force on.
  7. Entered "AT\r\n" in PuTTY.

I didn't get an OK as the result. Did I do something wrong? Any help please?

Instructions on how to enter AT command mode (http://elecfreaks.com/store/download/datasheet/Bluetooth/HC-0305%20serail%20module%20AT%20commamd%20set%20201104%20revised.pdf)

Bump! Anyone have any idea?

Found a manual that’s a bit easier to read here http://iteadstudio.com/Downloadfile/BluetoothHC05.pdf and as you say it states you pull pin 34 (PIO11) to VCC (3.3V) and then power on.

How to set the mode to server (master):

  1. Connect PIO11 to high level.
  2. Power on, module into command state.
  3. Using baud rate 38400, sent the “AT+ROLE=1\r\n” to module, with “OK\r\n”
    means setting successes.
  4. Connect the PIO11 to low level, repower the module, the module work as server
    (master).

Is your FTDI serial cable set for 3.3V or 5V

Thanks for replying! My FTDI is set for 5V but I'm powering the bluetooth through a voltage divider. When I send AT\r\n I don't get anything back (no OK, the cursor in PuTTY just goes back to the beginning). Help? :disappointed_relieved:

syntax_error: Thanks for replying! My FTDI is set for 5V but I'm powering the bluetooth through a voltage divider. When I send AT\r\n I don't get anything back (no OK, the cursor in PuTTY just goes back to the beginning). Help? :disappointed_relieved:

Maybe the FTDI should also be set to 3.3V as the device is 3.3V else your pumping 5V into the RX pin. A better manual here http://www.hobbytronics.co.uk/datasheets/EGBT-bluetooth-module.pdf says at the bottom of page 7

EGBT-045MS RX input is not 5V tolerant. A schottky diode connected as shown will keep 5V volt- ages out of the Bluetooth module when operated with a 5V host microcontroller.

i'm sorry but i didnt get the idea i have bought this bluetooth module http://ram-e-shop.com/oscmax/catalog/product_info.php?products_id=2244 i would like to pair it with another Bluetooth module i think i just need to use AT modes for this but i really don't know how to use this modes i have succeed in pairing this module with pc but this is not what i need any help please

The link you supplied for your BT module makes me think it is a slave only device that you can only link to from another device. It is not capable of creating a link to other devices, just receiving them. If it is a slave module (HC-06) then normally the AT commands must not have line termination (carriage return/line feed) as it uses a 1 second timeout to assume end of command.

Hi there, here is the code I use to get the HC05 in AT mode. it works on my arduino UNO, I hope it’ll help you.

//Caution: Tx of the module is to connec twithpin 10 of the arduino and RX with pin 11
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // TX | RX
void setup()
{
pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(115200);
Serial.println(“Enter AT commands:”);
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
//Take the string returned by the module and print it
Serial.println(BTSerial.readString());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.println(Serial.readString());
}

i used the exact same code and my hc-05 goes in AT mode but repies nothing when i type in any command

BASIC CONFIG
1º Connect TX with 10,RX with 11,VCC(3.3v) and GND
2º Load the program in Arduino

Model ZS-040
1º Push button in bluetooth module and hold
2º Disconnect VCC of bluetooth module
3º Connect VCC
4º Release button - Led must flash very slow. Now you are in AT MODE
5º Reset Arduino with reset button
6º Start the Monitor Serial, select “Both NL & CR”
7º Enter command “AT” and Enter. You must receive OK.

Other →
1º supply 3.3v to 34 pin and hold
2º Disconnect VCC of bluetooth module
3º Connect VCC
4º Release 3.3v from 34pin - Led must flash very slow. Now you are in AT MODE
5º Reset Arduino with reset button
6º Start the Monitor Serial, select “Both NL & CR”
7º Enter command “AT” and Enter. You must receive OK.

That’s all.

Regards

P.D.: Excuse for my english. The program is in spanish:

#include <SoftwareSerial.h>

#define RxD 10
#define TxD 11

SoftwareSerial BTSerial(RxD, TxD);

void setup(){
  BTSerial.begin(38400);
  Serial.begin(9600);
  BTSerial.print("AT\r\n");
  Serial.println("Si a continuacion pone OK ->> El dispositivo esta listo.");
  Serial.println("En caso contrario ->> El dispositivo no esta en modo AT.");
  Serial.println("Realice el siguiente procedimiento:");
  Serial.println("- Pulse el boton y mantengalo.");
  Serial.println("- Quite VCC del modulo.");
  Serial.println("- Vuelva a alimentar el modulo.");
  Serial.println("- Suelte el boton.");
  Serial.println("- El modulo parapadeara lentamente, indicando que esta en modo AT.");
  Serial.println("- Resetee Arduino.");
  Serial.println("-------------------------------------------------------------------");
}

void loop(){

  if (BTSerial.available())
    Serial.write(BTSerial.read());

  if (Serial.available())
    BTSerial.write(Serial.read());

}

thibaultlieux, Thank you for that code. I have tried every way I've found online and couldn't get my HC-05 to respond. Was going into AT Mode, but would never get any type of response. That code/setup worked perfect. Using UNO and MEGA 2560. I get a response from that setup. Thank you so much

Hi, I am a beginner with Arduino, I am trying the same thing and I am having the same problem, when I type the AT commands, I get no response, so I have change a part of code to understand what was going wrong.

if (Serial.available()>0) { char x = (char)Serial.read(); switch (x) { case '1': Serial.println("Opcao 1:"); BTSerial.print("AT+VERSION?\r\n"); break; case '2': Serial.println("Opcao 2:"); BTSerial.print("AT+PSWD?\r\n"); break; case '3': Serial.println("Opcao 3:"); BTSerial.print("AT+ADDR?\r\n"); break; case '4': BTSerial.print("AT+NAME?\r\n"); break; case '5': BTSerial.print("AT+IAC?\r\n"); break; case '6': BTSerial.print("AT+INQM?\r\n"); break; case '7': BTSerial.print("AT+UART?\r\n"); break; default: BTSerial.println(Serial.read()); } }

All the commands worked fine EXCEPT the one in default, there must be some kind of problem in the Serial.read() return format. Anyone knows??

Hi, I am a beginner with Arduino, I am trying the same thing and I am having the same problem, when I type the AT commands, I get no response, so I have change a part of code to understand what was going wrong.

if (Serial.available()>0) { char x = (char)Serial.read(); switch (x) { case '1': Serial.println("Opcao 1:"); BTSerial.print("AT+VERSION?\r\n"); break; case '2': Serial.println("Opcao 2:"); BTSerial.print("AT+PSWD?\r\n"); break; case '3': Serial.println("Opcao 3:"); BTSerial.print("AT+ADDR?\r\n"); break; case '4': BTSerial.print("AT+NAME?\r\n"); break; case '5': BTSerial.print("AT+IAC?\r\n"); break; case '6': BTSerial.print("AT+INQM?\r\n"); break; case '7': BTSerial.print("AT+UART?\r\n"); break; default: BTSerial.println(Serial.read()); } }

All the commands worked fine EXCEPT the one in default, there must be some kind of problem in the Serial.read() return format. Anyone knows??

Ok after testing and looking closer, the default is not working because at that time the serial.read() is empty, and I think that serial.read() doesn´t work because it returns a byte.

I use this code that has been post before, and it works just fine, don't need "\r\n" at the end of the command for my hc-05.

BTSerial.println(Serial.readString());

Hi,

Some people don't realize that to get into command mode you must first bring KEY to a HIGH and THEN apply Vcc. The LED should then flash SLOWLY: 2 seconds ON, 2 seconds OFF. If you don't see that you are not in command mode.

I wrote a sketch that automates that by supplying VCC from 2 paralled Arduino pins. See it HERE:

I need to write a good How-To on that page but it's LATE! I'll update this...

HI, I have a really dumb question :-[ , but can't seem to get a concept through my head. I've used the HC-05's with much success in the past, and set those things aside for a bit. I'd been setting them up using at commands via an Uno in the past, but I bought an FTDI converter w/3.3v option to make things a bit easier. I just received a couple HC-05's and plugged them together with the FTDI; entered the command mode, and was able to send AT commands via the serial monitor in the Arduino IDE.

NOW for the part I'm not understanding. The baud rate in the serial monitor is set at 38400, but when I query the HC-05, (AT+UART?) It comes back with 9600,0,0. I would have thought the baud would have been the same as the serial monitor....or is there a conversion in the FTDI? What am I not getting? This ol'e man/geek would be ever so grateful if you could explain. Thanks in advance.

Perhaps the 9600 refers to the HC-05's Bluetooth baud rate when connecting wirelessly to your PC, and the 38,400 refers to the wired connection that the FTDI uses to connect the HC-05 to the PC?

The fact that when you connect the HC-05 to your PC via both BT and serially at the same time you have to use 2 different serial ports (on the PC & Arduino) suggests that it's possible to have 2 different baud rates, one for each.

But I'm just guessing here.

The 9600 is the setting the HC-05 uses on the RX and TX pins when paired with another bluetooth device and it's actually communicating over the air. When you hold the key pin high at 3.3V while powering up the HC-05 (or some HC-05s have a key button you hold while powering up the HC-05) it goes into programming mode at 38400. If you do not hold the key pin high at 3.3V while powering up, but instead you later connect the key pin high, it goes into programming mode at whatever baud rate you or somebody else set previously with the AT+UART command. Since you may not remember or know what baud rate it was last set for, the special programming mode which always uses 38400 is there for you, so you don't have to hunt through many possible baud rates to establish a programming connection to re-program it.

dmjlambert: The 9600 is the setting the HC-05 uses on the RX and TX pins when paired with another bluetooth device and it's actually communicating over the air. When you hold the key pin high at 3.3V while powering up the HC-05 (or some HC-05s have a key button you hold while powering up the HC-05) it goes into programming mode at 38400. If you do not hold the key pin high at 3.3V while powering up, but instead you later connect the key pin high, it goes into programming mode at whatever baud rate you or somebody else set previously with the AT+UART command. Since you may not remember or know what baud rate it was last set for, the special programming mode which always uses 38400 is there for you, so you don't have to hunt through many possible baud rates to establish a programming connection to re-program it.

Doesn't the HC-05 have the ability to communicate with a PC or Arduino serially two ways, simultaneously, if you have two free serial ports available? One is wirelessly, using BT of course, and the other is via wire, either an FTDI-type cable if it's connected to a PC or regular wires (with level shifting) if connected to an Arduino. Each connection can have its own, different baud rate, as I understand it. You use the wired connection to program the HC-05 via AT commands, and the wireless BT connection to actually use the module normally. Could this not explain why they're getting two different baud rates?

No, only the wired serial connection has a baud rate setting. It is not 2 serial connections. There is only one serial connection and that is between the HC-05 and whatever it is connected to using the RX and TX pins. The baud rate 38400 is normally used to program the HC-05 with whatever settings (including baud rate) you will want to use, and once it is power cycled and they key pin is left untouched the programmed baud rate is used from that point on.