The following are the general steps and common instructions for configuring a Bluetooth module using the AT command:

1. Enter AT command mode
Different Bluetooth modules enter AT mode in different ways. For example, for HC-05, the KEY on the module needs to be held down when powered on, and for HC-08, it is necessary to ensure that the module is not connected to other devices.
2. Basic test
Send the AT command. If the module returns "OK", it indicates that the serial communication is normal and the operation can continue.
3. Common configuration instructions
- Modify the device name
AT+NAME=" New Name"
For example: AT+NAME="MY_DEVICE"
The module needs to be restarted after modification to take effect.
- Set the pairing code
AT+PSWD=" New Password"
For example: AT+PSWD="1234"
- Set serial port parameters
AT+UART= baud rate, stop bit, check bit
For example: AT+UART=115200,0,0 (baud rate 115200, 1 stop bit, no check)
- Switch master-slave mode
AT+ROLE=0 (Slave Mode)
AT+ROLE=1 (Host Mode)
- factory data reset
AT+ORGL or AT+DEFAULT
After recovery, the parameters need to be reconfigured.
4. Exit AT mode
Send the "AT+RESET" command to restart the module, exit the AT mode and apply the new configuration.
Precautions
- Instruction format: After each instruction, \r\n (carriage return and line feed) must be added. Some modules support automatic addition.
- Baud rate matching: Before configuring the serial port parameters, it is necessary to ensure that the baud rate of the serial port assistant is consistent with that of the module.
- Module differences: The AT commands of different models of Bluetooth modules may vary. Please refer to the specific module manual.

