Instructions to set Bluetooth Module HC-05 password using Arduino
Published by Ram on 24th Jun 2019
Hardware required
- Arduino
- BT Module HC-05 (ZS-040)
- Male to Male Jumper Wires(4)
Circuit design
Before making the connection make sure to unplug the power source from Arduino UNO. Make the following circuit with the help of the below-mentioned components.
Configure with AT Mode:
After the connection, If you Plug the power source, you will see the HC-05 power on with short rapid blink, which is the standard pairing mode of the module.
For At Mode, you need to plug the power source while holding down the reset button on the module. The long(2seconds) slow blinks show that we are in AT Command mode.
Code:
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(5, 6); // RX | TX
void setup()
{
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
if (BTSerial.available()) // read from HC-05 and send to Arduino Serial Monitor
Serial.write(BTSerial.read());
if (Serial.available()) // Keep reading from Arduino Serial Monitor and send to HC-05
BTSerial.write(Serial.read());
}
Output
Open the serial monitor. Be sure that the baud rate is set to 9600 and Both NL & CR are selected.
If you send AT from serial monitor, OK will appear on the screen. Now you can change the name or password of the module
To see the current password, enter the command:
AT+PSWD?
To change the password, enter the command:
AT+PSWD="5555" (FOR password 5555)