How to configure the Bluetooth
HC-06 module with AT commands, using Bolt 18F2550 system, through
the serial port.
Background:
In
a previous project described
here, an expansion
card with a
Bluetooth module
HC-06 and a serial
interface RS232-
DB9 connector was
developed. The card
is inserted into the
serial port of
any microcontroller system.
The company sells a product
based on this design:
Bluetooth HC-06 module with serial port
Description:
In the particular
case of this project,
the
Bolt
18F2550
system was used, as shown in
the following photos,
to transmit the AT
commands, through the serial port of the HC-06
Bluetooth module.
It is important to note that the 5 volt
@40 ma. supply needed for the Bluetooth expansion module shown
below, is fed from the Bolt board through the pin 7 of the DB9 connector.
3
different programs were developed in ANSI C to test
each of the AT commands, as shown in the table below.
To test
each of the AT commands, connect devices as shown in
photos below.
PCB VERSION OF
BLUETOOTH MODULE WITH SERIAL PORT:
SYSTEM TO CONFIGURE HC-06
MODULE WITH AT COMMANDS:
AT COMMANDS FORMAT:
All AT commands are strings of ASCII codes. According to the manufacturer's specification, the entire command
(without enter CR/LF),
should be transmitted from the microcontroller board to the
HC-06 Bluetooth in a single
time, at 9600 bps (which is the default rate).
For this purpose, using the
Bolt 18F2550 system, three
ANSI C programs were developed to send some of the commands, and
display the responses of the HC-06 module in the system LCD.
AT COMMANDS
TESTING:
To do testing of the
commands, you have to load the corresponding .hex file to the
Bolt system and see the response in the LCD, according to the
table below. You may also modify the .c source file according to
your needs, to
change the parameters.
**In this particular command, the user will see the new name only
when pairing the Bluetooth HC-06 device to a PC computer with a
master Bluetooth module as shown below for a Windows 8 machine.
In this example, name was modified to "BlueBolt".
-For a preliminary testing of AT commands. Command:
'AT'
Response: OK
Use the following program: C18-BOLT-BLUETOOTH-AT.zip
-To obtain
the firmware version of
HC-06. Command: 'AT+VERSION' Response: OKLinvorV1.8 Use the following
program:
C18-BOLT-BLUETOOTH-VERSION.zip
-To change
the device name. Command:
'AT+NAMEBlueBolt'
Response:
OKsetname
This example program changes the name of the HC-06
module to
"BlueBolt". Use the following program:
C18-BOLT-BLUETOOTH-BLUEBOLT.zip User may use another name modifying
the .c program, compiling and loading the resulting .hex file to Bolt system.
-To change the
baud rate:
AT+BAUD4
(the default
value is 9600).
-To
change the password (pin number) for
pairing:
AT+PIN1234 (default
is 1234).
Please note that,
as factory settings, the module has
a configuration of
9600 bps, pin
= 1234 and
name = HC-06
(some models have 'Linvor' as factory name)
Summary of AT Commands:
-
-
No action is taken by the
Bluetooth, it simply
acknowledges with “OK”
letting you know
communication was successful.
-
-
-
-
Sets the Bluetooth UART baud
rate. Baud rate is set by an
hexadecimal index from '1'
to 'C'.
-
Indexes are: 1:1200, 2:2400,
3:4800, 4:9600, 5:19200,
6:38400, 7:57600, 8:115200,
9:230400, A:460800,
B:921600, C:1382400
-
-
-
Set
Bluetooth Device Name
-
Sets Bluetooth Device Name
-
Send:
AT+NAME<device
name>
-
-
-
Sets the security code
needed to connect to the
device.
-
Send:
AT+PIN<4
digit code>
-
Response: OK<4 digit code>
-
-
Get The Firmware Revision
Number.
-
-
Examples:
AT
OK
AT+VERSION
OKLinvorV1.8
AT+BAUD4
OK9600
AT+PIN1234
OK1234
AT+NAMEBlueBolt
OKsetname
|