Home»Arduino Hc 05 At Command
» Here's A Compilation Of All HC-05 Bluetooth AT Commands. For Beginners, See Arduino Bluetooth.
...
Set/Check Connect Mode:
The HC-05 is a common Bluetooth module used in many microcontroller projects. Here's a compilation of all HC-05 Bluetooth AT Commands. For beginners, see Arduino Bluetooth.
Contents
Toggle
Setting HC-05 to AT Command Mode
Test command
Reset
Get firmware version
Restore default
Get module address
Set/Check module name:
Get the Bluetooth device name:
Set/Check module mode:
Set/Check device class
Set/Check GIAC (General Inquire Access Code)
Set/Check — Query access patterns
Set/Check PIN code:
Set/Check serial parameter:
Set/Check connect mode:
Set/Check fixed address:
Set/Check LED I/O
Set PIO output
Set/Check – scan parameter
Set/Check – SNIFF parameter
Set/Check security mode
Delete Authenticated Device
Delete All Authenticated Device
Search Authenticated Device
Get Authenticated Device Count
Most Recently Used Authenticated Device
Get the module working state
Initialize the SPP profile lib
Inquiry Bluetooth Device
Cancel Inquiring Bluetooth Device
Equipment Matching
Connect Device
Disconnect
Energy-saving mode
Exerts Energy-saving mode
Pairing Two HC-05 Modules
Setting HC-05 to AT Command Mode
By default, the HC-05 is configured in data mode. In this mode, the module acts like a serial bridge. To put into AT command mode the KEY pin must be set (high).
However, there are modules where the KEY pin is missing or is not wired to the actual KEY pin of the IC. To solve this, wire pin 34 of the IC to 3.3 V:
The HC-05 is now in command mode if the red LED flashes once every two seconds.
The following commands require that the HC-05 is connected to the Arduino as a serial device. Below is an example wiring diagram and sketch/code:
AT+INIT OK AT+IAC=9e8b33 OK AT+CLASS=0 AT+INQM=1,9,48 AT+INQ +INQ:2:72:D2224,3E0104,FFBC +INQ:1234:56:0,1F1F,FFC1 +INQ:1234:56:0,1F1F,FFC0 +INQ:1234:56:0,1F1F,FFC1 +INQ:2:72:D2224,3F0104,FFAD +INQ:1234:56:0,1F1F,FFBE +INQ:1234:56:0,1F1F,FFC2 +INQ:1234:56:0,1F1F,FFBE +INQ:2:72:D2224,3F0104,FFBC OK
Cancel Inquiring Bluetooth Device
Command
Response
Parameter
AT+ INQC
OK
-
Equipment Matching
Command
Response
Parameter
AT+PAIR=<Param1>,<Param2>
OK
or
FAIL
Param1:Device Address
Param2:Time out
Connect Device
Command
Response
Parameter
AT+LINK=<Param>
OK
or
FAIL
Param:Device Address
Example:
AT+FSAD=1234,56,abcdef OK AT+LINK=1234,56,abcdef OK
Disconnect
Command
Response
Parameter
AT+DISC
+DISC:SUCCESS
OK
or
+DISC:LINK_LOSS
OK
or
+DISC:NO_SLC
OK
or
+DISC:TIMEOUT
OK
or
+DISC:ERROR
OK
Param:Device Address
Energy-saving mode
Command
Response
Parameter
AT+ENSNIFF=<Param>
OK
Param:Device Address
Exerts Energy-saving mode
Command
Response
Parameter
AT+ EXSNIFF =<Param>
OK
Param:Device Address
Pairing Two HC-05 Modules
Use an FTDI USB to Serial converter to configure the bluetooth module once it’s in command mode (how to set in command mode). Then use Arduino’s serial monitor to send out commands. The default baud rate for command mode is 38400. One module is the master device while the other is the slave device. Pairing configuration is done through the master device.
Step 1: Check if the HC-05 master is in command mode:
AT > OK
Step 2: Reset the configurations to their default values:
AT+ORGL > OK
Step 3: Set the module to master:
AT+ROLE=1 > OK
Step 4: Reset the module:
AT+RESET > OK
Step 5: Wait, then initialize:
AT+INIT > OK
Step 6: Forget all the previous connections:
AT+RMAAD > OK
Step 7: Determine MAC address of slave device. Set slave device to command mode and issue command:
AT+INQ > +INQ:98D3:31:FC20A9,1F00,7FFF
Here, it shows that the slave device has a MAC address of 98D3:31:FC20A9. The 1F00 is the device class while the 7FFF is the received signal strength indicator (RSSI).
Step 8: Back to master module; pair with the slave device:
AT+PAIR=98D3,31,FC20A9,20 > OK
After pairing, the LED on the master module will start flashing with about two seconds of pause.
Step 9: Bind the master and slave devices:
AT+BIND=98D3,31,FC20A9 > OK
Step 10: Link the two devices:
AT+LINK=98D3,31,FC20A9 > OK
If successful, both the master and slave device's LED will now blink twice followed by about two seconds of pause.