กลับหน้าหลัก
views
How to Change HC-05 Bluetooth Module Password and Name Using AT Command
Last updated on

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-05Arduino
VCC5V
GNDGND
TXPin 2
RXPin 3
Circuit diagram showing HC-05 connected to Arduino UNO with VCC to 5V, GND to GND, TX to Pin 2, RX to 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
Serial Monitor settings showing Both NL & CR and 38400 baud rate selection

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:

  1. Disconnect VCC wire
  2. Hold down the KEY button on HC-05 module
  3. Reconnect the VCC wire
  4. Release the KEY button

If done correctly, the LED will change to slow blinking indicating Command Mode is active

Diagram showing KEY button location on HC-05 module and LED slowly blinking in Command Mode

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

CommandUsageExample
ATTest connectionAT
AT+NAMEChange nameAT+NAME=MyDevice
AT+PSWDChange passwordAT+PSWD=“1234”
AT+UARTView/set Baud RateAT+UART?
AT+ROLEView/set Master/SlaveAT+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

https://www.youtube.com/embed/SL0-9E5tJno

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the home page

จ้างทำโปรเจคเลย

ความคิดเห็น