每天一点单片机知识单片机学习

ARDUINO&HC-05蓝牙模块AT模式

2019-05-26  本文已影响1人  Houwing

为了使用蓝牙模块传送一些数据来完成我的功能,需要先调试蓝牙模块。HC-05包含两种模式

使用材料

连接电路

hc-05_link_board.png

arduino code

#include <SoftwareSerial.h>
SoftwareSerial BT(3,2);//RX TX on the board
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);//这里应该和你的模块通信波特率一致
       delay(100);
       Serial.println("Arduino is ready.");
       BT.begin(38400);
       Serial.println("Bluetooth is ready.");
}

void loop() {
  // put your main code here, to run repeatedly:
    if(Serial.available())
    BT.write(Serial.read());
  //把hc-05的串口输出的字符 输出到电脑串口中
  if(BT.available())
    Serial.write(BT.read());
}

操作方法

其他的AT指令

To return HC-05 to mfg. default settings: "AT+ORGL"

To get version of your HC-05 enter: "AT+VERSION?"

To change device name from the default HC-05 to let's say MYBLUE enter: "AT+NAME=MYBLUE"

To change default security code from 1234 to 2987 enter: "AT+PSWD=2987"

To change HC-05 baud rate from default 9600 to 115200, 1 stop bit, 0 parity enter: "AT+UART=115200,1,0"

参考链接

https://www.instructables.com/id/AT-Commands-for-Bluetooth-Module-HC-05-W-EN-Pin-an/
https://www.arduino.cn/forum.php?mod=viewthread&tid=2961&page=1

上一篇 下一篇

猜你喜欢

热点阅读