Introduction: AT Commands for Bluetooth Module (HC-05 W/ EN Pin and BUTTON) Using Arduino Board!

About: fb @ geeameal

By Jay Amiel Ajoc
Gensan PH

This instructable will help you get started with using your HC05 bluetooth module.
By the end of this instructable, you will have learned about sending AT commands to the module to configure/modify it (name, passkey, baud rate etc) using your arduino board.

Step 1: Materials

1. Arduino UNO

2. HC05 Bluetooth Module

3. Jumper Wires

4. Breadboard

5. Resistors (1k and 2k)

That's it!

Step 2: Wiring Diagram

Follow this procedure if you want to begin AT comms with your HC-05 (with EN pin and BUTTON on the far-right side of BT)

Make the ff connections!

BT VCC to Arduino 5V

BT GND to Arduino GND

BT TX to Arduino D2

BT RX to Arduino D3 (Use a VOLTAGE DIVIDER for this part! BT Rx can't handle 5V signal from arduino!)

Step 3: Upload Code to Arduino Board

NOTE: Before uploading, remove the tx and rx wirings leaving the 5V and ground connections only.

After the "Done uploading" part, reconnect BT TX to ARDUINO D2 and BT RX to ARDUINO D3(still, with the voltage divider).

The LED on the HC-05 should be blinking quickly at about 5 times a second.

--------------------------------------------------------------------------------------------------------------------------------------------------

#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

char c = ' ';

void setup() {

Serial.begin(9600);

Serial.println("Arduino is ready");

Serial.println("Remember to select Both NL & CR in the serial monitor");

// HC-05 default serial speed for AT mode is 38400

BTserial.begin(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();

BTserial.write(c); }

}

---------------------------------------------------------------------------------------------------------------------------------------------------

Step 4: Putting the BT Module to AT MODE.

With the Arduino on, do the following:

Remove the 5V connection to BT VCC

Press and hold the button switch on the BT module

Re-connect BT VCC to 5V (while still pressing the button switch), the LED should come ON.

Release the button switch and the LED should be blinking slowly on/off once every couple of seconds (approx 2 sec).

This indicates AT mode.

Step 5: Send AT Commands

Now that you're in AT mode, you can now begin AT comms.

Here are some example of AT commands you can use or you can search the internet for other AT commands.

To return HC-05 to mfg. default settings: "AT+ORGL"

To get version of your HC-05 enter: "AT+VERSION?"

To change device name from the default HC-05 to let's say MYBLUE enter: "AT+NAME=MYBLUE"

To change default security code from 1234 to 2987 enter: "AT+PSWD=2987"

To change HC-05 baud rate from default 9600 to 115200, 1 stop bit, 0 parity enter: "AT+UART=115200,1,0"

IMPORTANT NOTE: If you're using AT commands with "?", do this, while pressing the button on BT board, press enter on the computer. That should do it.