Hello everyone............
For basic info and communication
mode of HC – 05 Bluetooth module visit Tutorial 1
HC-05 AT command mode:
Follow the given steps to drive the
Bluetooth module into AT mode.
1.
Power OFF the module
i.e., disconnect supply voltage
2.
Connect
KEY pin to HIGH.
3.
After
a small delay (~100 ms), Power ON the module i.e., apply 5V supply
Now your module will enter into AT
command mode. Only if you again re-power
the module with KEY pin LOW, your module will return to communication mode.
Please follow the steps correctly
because most of the users face problems in entering AT mode.
After entering into AT mode, the
module will be automatically set to 38400 by default (whetever be the baud rate
in Communication mode). Hence the baud rate of serial communication should be
set to 38400 (refer code).
Need for a relay circuit:
For
entering into AT mode, we need to cotrol the 5V supply voltage to the module. For
this purpose I used a relay circuit board that I prepared myself. See this link
for DIY simple relay circuit board.
Circuit Diagram:
Testing:
If
you send ‘AT‘, then you should receive ‘OK‘.
In AT mode you can configure the module settings
such as name, baud rate (for communication mode), master/slave mode, change
password, etc.
Example:
Code:
#include
<rxduino.h>
#include<iodefine_gcc63n.h>
int
main()
{
Serial.begin(38400);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
digitalWrite(3, 0); // switch off power supply to module
digitalWrite(2, 0); // KEY pin of module LOW
delay(1000);
digitalWrite(2, 1); // KEY pin of module turned HIGH
delay(100); // a small delay
digitalWrite(3, 1); // Switch ON Power supply to module
delay(8000);
Serial.println("Enter AT
commands:");
Serial1.begin(38400,SCI_SCI0P2x); // pin20 and pin21 of sakura
delay(100);
while(1)
{
if (Serial.available())
{
Serial1.write(Serial.read());
}
if (Serial1.available())
{
Serial.write(Serial1.read());
}
}
}
Download the attached file for AT commands - HC-05 AT commands.
No comments:
Post a Comment