Arduino HC-05 Bluetooth Module Usage and AT Commands
Arduino HC-05 Bluetooth Module Usage and AT Commands
What is HC-05?
HC-05 is a Bluetooth module you can use with Arduino, which allows you to connect to your Arduino board via Bluetooth and give commands with devices such as phone, computer, or tablet.It enables communication between devices via UART and I can say that it does this quite fast.
How to Connect HC-05 to Arduino?
HC-05 ArduinoEN 5V (You do not need to connect, but connect it for entering AT commands)
VCC 5V
GND GND
TXD RX
RXD TX
STATE
Normally, you can connect the HC-05 module to Arduino as shown above, but if you take my suggestion, I recommend connecting the TXD and RXD pins to any two digital pins on the Arduino and using a library on Arduino to convert them to RX and TX.
To make AT commands work, you need to connect the EN pin to 5V, otherwise, it will not allow you to change the HC-05 module’s name or baud values.
When uploading code to the board, disconnect the HC-05 Module from the Arduino; otherwise, you may get errors. After the software is loaded to the board, reconnect it.
Don’t forget to select the option with NL and CL on the serial screen; otherwise, responses will not come.
To put the HC-05 module into AT mode, hold down the small button on the module and power it up, i.e., you need to hold down the small button while the module is off.
If the light on the module blinks every 2 seconds, it means it has entered AT mode.
Sending AT Commands to the HC-05 Module via Arduino
When you upload the code below to your Arduino board, you can send AT commands to the HC-05 module over the serial connection.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11); // RX, TX
void setup() {
Serial.begin(9600); // PC and Arduino connection
pinMode(9,OUTPUT); // EN connection
digitalWrite(9,HIGH); // EN active
Serial.println("Enter AT commands:");
mySerial.begin(38400); // HC-05 connection
}
void loop(){
if (mySerial.available())
Serial.write(mySerial.read()); // message to HC-05
if (Serial.available())
mySerial.write(Serial.read()); // response from HC-05
}When uploading code to the board, disconnect the HC-05 Module from the Arduino; otherwise, you may get errors. After the software is loaded to the board, reconnect it.
Don’t forget to select the option with NL and CL on the serial screen; otherwise, responses will not come.
To put the HC-05 module into AT mode, hold down the small button on the module and power it up, i.e., you need to hold down the small button while the module is off.
If the light on the module blinks every 2 seconds, it means it has entered AT mode.
- AT : Tests the connection
- AT+NAME? : Tells the board name
- AT+ADDR? : Shows the address
- AT+VERSION? : Shows the version
- AT+UART? : Shows the baudrate (like 38400)
- AT+ROLE? : Shows Master/Slave mode (1=master/0=slave)
- AT+RESET : Restarts
- AT+ORGL : Resets to factory settings
- AT+PSWD? : Shows the password
- AT+NAME=NAME : Sets the name of the board, appears in connection
- AT+UART=9600 : Changes the board's baudrate
- AT+PSWD=PASSWORD : Changes the board's connection password
You can refer to the documentation for more detailed commands and information about the board.
Click here for the documentation document.


Yorum Gönder