1

我目前正在开发使用 Pro Micro 微控制器、HM10 ble 模块(我检查过,这不是 BLE-CC41A)和几个 Android 设备的设备。我的问题是Android和HM10之间的连接。几天前,这两者之间的连接运行良好,我可以在这两者之间发送和接收消息。现在 Android 可以看到 HM10 模块,但由于某种原因无法连接。我已经尝试了几个应用程序,例如“nRF Connect”、“BLE Scanner”和“MSMBle”,但都没有结果。

在 Pro Micro 方面,一切似乎都很好。使用我正在使用的代码,我可以向 HM10 发送 AT 命令。如果您想知道我为 pro micro 使用了什么代码:

#include <SoftwareSerial.h>

SoftwareSerial bluetooth(9, 8); //RX|TX

void setup(){
  Serial.begin(9600);
  bluetooth.begin(9600); // default baud rate
  Serial.println("AT commands: ");
}

void loop(){
  bluetoothCommunication();
  serialCommunication();
}

void serialCommunication() {
  if(Serial.available() >0){ //read from the Serial and print to the HM-10
    bluetooth.write(Serial.read());
  }
}

void bluetoothCommunication(){
  String readStr; //expect a string like wer,qwe rty,123 456,hyre kjhg, or like hello world,who are you?,bye!, 
  while (bluetooth.available() > 0) { //read from the HM-10 and print in the Serial
    delay(10);  //small delay to allow input buffer to fill
    char inChar  = bluetooth.read();  //gets one byte from serial buffer
    readStr += inChar ;  //makes the string readString
  }
  if (readStr.length() >0) {
    Serial.println(readStr); //prints string to serial port out
  }
}

关于 BLE HM10 模块,我几乎使用默认设置,但更改了名称和密码。我还想指出,我用三个 HM10 模块进行了测试,没有一个可以连接到 Android 设备。

有没有人有同样的问题?Android 是否进行了使 HM10 模块无法使用的更新?

4

0 回答 0