如何从返回奇数字符中修复HM-10 BLE模块



我试图通过MacOS设备通过HM-10模块(BLE)将数据发送到Arduino,并遵循本指南。对于我的接线,我做了以下操作:我的HM-10上有RX PIN挂在Arduino上的TX上;HM-10上的TX引脚到Arduino上的RX;HM-10上的VCC至Arduino上的3.3V;HM-10上的GND到Arduino上的GND。

我正在使用以下代码:

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(0, 1); //RX|TX
void setup(){
  Serial.begin(9600);
  BTSerial.begin(9600); // default baud rate
  Serial.println("AT commands: ");
}
void loop(){
  //Read from the HM-10 and print in Serial Moniter
  if(BTSerial.available()) {
      Serial.write(BTSerial.read());
  }
  //Read from the Serial Moniter and print to the HM-10
  if(Serial.available()) {
      BTSerial.write(Serial.read());
  }
}

当我发送AT+NAME?时,我应该接收OK+NAME:HMSoft,但是我继续获得一串奇数字符:AV⸮5⸮。此外,这些命令似乎没有任何作用。

我做错了什么,我无法从计算机上与HM-10互动?

SoftwareSerial BTSerial(0, 1); //RX|TX

您正在使用硬件串行引脚进行软件串行。然后,您正在使用两者都会破坏数据。

将软件串行引脚移动到不同的销钉,例如2和3。

将引脚更改为2和3后,选择NL&amp; CR选项通过IDE将命令发送到Arduino。否则它将不起作用。

最新更新