Terug
Verbind VCC en GND,
pin 6 aan de TXD en pin 7 aan RXD van de Bluetooth-module
Laad de volgende
sketch
-------------------------
#include
<SoftwareSerial.h>
SoftwareSerial
BTSerial(6,
7); // RX | TX
void setup()
{
pinMode(9,
OUTPUT); // this pin will pull the HC-05
pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9,
HIGH);
Serial.begin(9600);
Serial.println("Enter
AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
//
Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
//
Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
---------------------------------
Ontkoppel de Arduino
van de USB-kabel
Leg een draadje tussen
de 5V van de Arduino en pin 34, rechtsboven in de Bluetooth-module als de
pinnen naar beneden wijzen.
Sluit de Arduino weer
op de PC aan en open de serial monitor.
De rode LED op de
Bluetooth-module gaat nu langzaam 2sec aan, 2 sec uit, knipperen
Tik in:
AT à OK
AT+NAME=ED-KLOK
AT+RESET
Here is an important note, if the key pin is not high, i.e. not connected to Vcc while receiving AT commands(if you did not solder the wire and released it after the module entered AT mode), it will not show the default name even after giving right command. But you can still change the name by the command mentioned above. To verify if the name has really changed, search the device from your pc/mobile. The changed name will appear. To change baud rate, type AT+UART=desired baud rate. Exit by sending AT+RESET command.
Most useful AT commands are
AT : Check the connection.
AT+NAME : See default name
AT+ADDR : see default address
AT+VERSION : See version
AT+UART : See baud rate
AT+ROLE: See role of bt module(1=master/0=slave)
AT+RESET : Reset and exit AT mode
AT+ORGL : Restore factory settings
AT+PSWD: see default password