How to Change HC-05 Bluetooth Module Password and Name Using AT Command
How to Change HC-05 Bluetooth Module Password and Name Using AT Command
HC-05 is a Bluetooth module that works easily with microcontrollers like Arduino, AVR, and PIC through Serial Port communication. This article covers how to change the password and device name of HC-05 using AT Commands via Serial Monitor.
Required Components
- Arduino UNO R3
- Bluetooth Module HC-05
- Breadboard
- Jumper wires
- Power Adapter 9V 2A (if needed)
Wiring HC-05 to Arduino
| HC-05 | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| TX | Pin 2 |
| RX | Pin 3 |
Arduino Code for AT Command Communication
This code uses SoftwareSerial to create an additional serial port on pins 2 and 3 for communicating with HC-05
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
Serial.begin(38400);
while (!Serial) ;
mySerial.begin(38400);
}
void loop() {
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
Upload this code to your Arduino board before proceeding
Serial Monitor Configuration
Open Serial Monitor in Arduino IDE and configure as follows:
- Baud Rate: 38400
- Line Ending: Both NL & CR
How to Enter HC-05 Command Mode
HC-05 starts in normal operating mode with fast blinking LED. To send AT Commands, you must enter Command Mode first.
Steps to enter Command Mode:
- Disconnect VCC wire
- Hold down the KEY button on HC-05 module
- Reconnect the VCC wire
- Release the KEY button
If done correctly, the LED will change to slow blinking indicating Command Mode is active
Testing Connection with AT Command
Type AT in Serial Monitor and click Send. If HC-05 responds with OK, the connection is successful.
Changing HC-05 Device Name
Use the command AT+NAME= followed by the desired name
AT+NAME=myarduino_HC05
If successful, HC-05 will respond with OK. Search for Bluetooth signals on your phone to see the new name
Changing HC-05 Password
Use the command AT+PSWD= followed by the new password (include quotes)
AT+PSWD="1234"
HC-05 will respond with OK and the new password takes effect immediately
Common AT Commands Reference
| Command | Usage | Example |
|---|---|---|
| AT | Test connection | AT |
| AT+NAME | Change name | AT+NAME=MyDevice |
| AT+PSWD | Change password | AT+PSWD=“1234” |
| AT+UART | View/set Baud Rate | AT+UART? |
| AT+ROLE | View/set Master/Slave | AT+ROLE? |
Summary
Changing HC-05 password and name is straightforward using AT Commands. Just enter Command Mode correctly, set Serial Monitor to 38400 baud with Both NL & CR, and send your desired commands.
Reference Video
อยากทำโปรเจคแบบนี้?
รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน
If you need Arduino project service or urgent IoT development, see full service details on the home page
จ้างทำโปรเจคเลย