Hi there! This is a short document/code to remind me what I have done with a HC-06 Bluetooth module and an arduino as it's not easy to collect the information I got here, it took me sometime.
Firstly, the module can be AT controlled and set some of the parameters as long as it's not paired with a device, so, we must first set the parameters and only afterwards play with devices. The password/pin of the device and name are not lost upon power off.
The AT available commands are:
- AT -> OK (shows status)
- AT+VERSION -> OKlinvorV1.8 (shows firmware version)
- AT+NAMEARDUINO -> OKsetname (sets broadcast name to 'ARDUINO', kept after powerdown)
- AT+PIN1303 -> OKsetPIN (sets PIN to '1303', kept after powerdown)
- AT+BAUD4 -> OK9600 (sets the baudrate @9600,
1---------1200
2---------2400
3---------4800
4---------9600
5---------19200
6---------38400
7---------57600
8---------115200 )
Now, knowing this, let's PLAY!! ;)
// HC-06 Possible commands, HC-05 are different!
// ATTENTION!!! THESE COMMANDS WORK ONLY IF THE BLUETOOH IS
// NOT PAIRED WITH ANY DEVICE:
// «AT Mode: Before paired, it is at AT mode.
// After paired it’s at transparent communication.»
// (case sensitive commands)
// AT -> OK (shows status)
// AT+VERSION -> OKlinvorV1.8 (shows firmware version)
// AT+NAMEARDUINO -> OKsetname (sets broadcast name to
// 'ARDUINO', kept after powerdown)
// AT+PIN1303 -> OKsetPIN (sets PIN to '1303', kept
// after powerdown)
// AT+BAUD4 -> OK9600 (sets the baudrate @9600,
// 1---------1200
// 2---------2400
// 3---------4800
// 4---------9600
// 5---------19200
// 6---------38400
// 7---------57600
// 8---------115200 )
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
BTSerial.begin(9600);
Serial.println("Enter your AT command:");
}
void loop() // run over and over
{
if (BTSerial.available())
Serial.write(BTSerial.read());
if (Serial.available())
BTSerial.write(Serial.read());
}
No comments:
Post a Comment