Arduino HC-05(ZS-40) AT Commands

The Bluetooth Module HC-05 can be act as Master and Slave. By default it is a master .

It can also be configured to have different baud rates:9600, 19200,38400 etc. By default the baud rate is 38400.

If you want to modify these settings. It can be acheived by sending AT Commands to the HC-05 Module.

In order to send AT commands , you have to connect HC-05 Module to an USB-to-TTY module. If you dont have that like me and have an arduino board then you can use it for sending AT Commands.

In order to achieve this, Open Arduino IDE Upload an empty sketch to the Arduino

void setup()
{

}

void loop()
{

}


Connections:

1. Connect RX pin of Arduino to RX pin of HC-05(Not the other way:RX to TX)
2. Connect TX Pin of Arduino to TX pin of HC-05 .

Don't connect power then before this, you have to switch HC-05 Module to AT Mode. It can be achieved in two modes:

1.One is to hold the switch and then apply the power to it, i.e. connecting VCC of Arduino to HC-05 VCC and GND of Arduino to GND of VCC.

2. Connect the 3.3v of Arduino to Key Pin and then apply power and then remove the 3.3 V.

Now you can see the LED present on HC-05 blinks for every 2 Seconds. This is a confirmation saying that the HC-05 Has entered AT Mode.

Now open Arduino IDE , Tools->Serial Monitor

Set the Baud Rate to 38400 and also at the bottom select "BOTH NL & CR" and now you can type your AT Commands and it works





Various AT Commands:

1. AT+VERSION? : Returns the software version
Eg:+VERSION:2.0-20100601

2.AT+STATE:Returns the state of the module
Eg:+STATE:INITIALIZED

3. AT+UART: Returns the baud rate of the device
Eg: +UART:9600,0,0

4. AT+ROLE:Returns the role of the device either master or slave
Eg:+ROLE:0.If it is 0 it means slave and if 1 it means master.

To change to master mode type AT+ROLE=1

To change the baud rate type AT+UART=38400,0,0

AT+NAME only works when the KEY pin is high


Comments

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto