无法从 HM10 读取消息,正在写入作品。 (通过蓝牙接收和发送数据)

Cannot read message from HM10, writing works. (receiving and sending data by bluetooth)

我目前正在尝试创建使用蓝牙通信 (HM10) 的基于 Arduino 的设备。 我已经通过 SoftwareSerial.h 将 HM10 连接到 arduino,并且我已经通过 USB 将 Arduino 连接到 PC,我正在使用串行监视器在板和 pc 之间进行通信。

想法很简单: 该板应该只是从串行连接 "A" 读取一条消息,然后通过另一个串行连接 "B" 将其传递给 HM 10。然后 HM10 通过蓝牙将消息发送到连接的设备。它还应该通过串行连接 "B" 从 HM10 接收一条消息,并通过串行连接 "A"

将其传递到我的电脑

在我的移动设备上,我使用 MSMBle 应用程序通过蓝牙连接到 HM10 并与之通信。

将 arduino 连接到 pc 后,打开串行监视器并通过此应用程序将我的 phone 连接到 HM10 我可以通过串行监视器将 ASCII 文本从我的 PC 发送到 arduino 并且我的 phone 确实收到它,我在手机上看到它 phone。但是当我通过蓝牙向 HM10 发送一些消息时,arduino 没有收到它。

HM10 确实收到了:如果我将 HM10 直接连接到我的 PC,我就可以使用我的串行监视器接收和发送消息。因此 HM10 正在接收消息并通过串行(TR,TX)将其传递给 Arduino,但 Arduino 出于某种原因并未读取它。

我正在使用这个教程:enter link description here

这是代码:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(8, 9); // RX, TX  
// Connect HM10      Arduino Uno
//     Pin 1/TXD          Pin 7
//     Pin 2/RXD          Pin 8

void setup() {  
  Serial.begin(9600);
  // If the baudrate of the HM-10 module has been updated,
  // you may need to change 9600 by another value
  // Once you have found the correct baudrate,
  // you can update it using AT+BAUDx command 
  // e.g. AT+BAUD0 for 9600 bauds
  mySerial.begin(9600);
  mySerial.print("AT+NAMEnazwak2");
  Serial.print("serial_ok");
}

void loop() {  
  //Serial.print("test");
  char c;
  if (Serial.available()) {

    c = Serial.read();

    mySerial.print(c);
  }
  if (mySerial.available()) {
    c = mySerial.read();
    Serial.print("ok");
    Serial.print(c);    
  }
}

请帮帮我,我做错了什么?

这只是一个奇怪的硬件问题。在其他板上运行良好