AT Mode Configuration of HC-05 Bluetooth Module

by Mr.What in Circuits > Arduino

571 Views, 1 Favorites, 0 Comments

AT Mode Configuration of HC-05 Bluetooth Module

modified_hc-05.jpg

The HC-05 is a low cost bluetooth module popular for use with MCU boards such as Arduino, ESP32 (IoT), and Raspberry Pi Pico. I prefer these over the HC-06 since they can be configured to work as either master or slave, allowing them to be used to communicate between two MCUs. In addition, they are sometimes cheaper than the HC-06.

There are several resources explaining commands available in the AT mode, such as this one describing HC-05 Commands. I had some trouble establishing the AT command mode. This instructable provides a brief overview of how to get into the AT command mode.

Supplies

HC-05 module.

USB to Serial converter, or Arduino.

Wiring

img_5e0abed51c731.png
  1. Jumper Vcc and ground from your USB-serial converter, or Arduino running a script equivalent to a USB-serial converter.
  2. Jumper Rx on HC-05 to Tx on serial converter.
  3. Jumper Tx on HC-05 to Rx on serial converter.
  4. If your HC-05 does not have a Key/EN button, jumper Key/EN to Vcc

Power Up

If you did not hardwire the Key/EN pin, hold down the button when you power up the HC-05. It should blink slowly, with a two second period. This indicates that you are in AT mode.

If it is blinking rapidly, half-second period, it is NOT in AT mode. Try to power down and power up with Key pressed or pulled high again.

Connect

Connect to your serial converter with a terminal program. I like the Arduino IDE for this purpose. It sends commands a line at a time, as needed, and it is straightforward to set BAUD and line endings.

The HC-05 default rate is 38400 BAUD, 0-stop bits, 0-parity, using both carriage return and new line ending (\r\n). Note that the HC-06 uses NO line ending, but has a very short lived timeout. These modules are often mislabeled. Try no line ending if \r\n does not work.

If you connected correctly you should get an "OK" response to to the "AT" command. If you get no response, try "AT+VERSION". If you have a mislabeled JDY-31 class Bluetooth module, they respond to AT+VERSION, but not AT.

Try other baud rates if 38400 does not work. 9600 might be the next most common. Try with or without \r\n in case your unit was mislabeled.

Enter Configuration Commands

The commands I use most are:

  • AT+NAME=toyrobot1 to set the name of the device to toyrobot1 when scanning bluetooth.
  • AT+PSWD=3141 to set an alternate PIN for the device, (default usually 1234)
  • AT+UART=115200,0,0 to set data at 115200 rate, default is usually 9600
  • AT+ROLE=1 to set into Master role, where default is 0==slave

I believe that most HC-05s in AT mode remain at 38400 BAUD regardless of the data rate

Reboot

Reboot with key/en disabled and your HC-05 should be runnnig with the new settings.