Sony Spresense与ESP8266 E12串口通信

Serial Communication of Sony Spresense with ESP8266 E12

我正在尝试在我的 ESP8266 E12 和 Sony Spresense 之间创建一个简单的串行通信。我已将 Spre.RX 与 ESP.TX、Spre.TX 与 ESP.RX 以及 Spre.GND 与 ESP.GND 连接。

接收者:

byte rcvByte;

void setup() {
  Serial.begin(9600);
  while (!Serial) {;}
  Serial.println("Receiving");
}

void loop() {
  if (Serial.available()) {
    rcvByte = Serial.read();
    if (rcvByte == 'H') {
      Serial.println("High");
    }
    if (rcvByte == 'L') {
      Serial.println("Low");
    }
  }
}

发件人:

void setup() {
  Serial.begin(9600);
  while (!Serial) {;}
  Serial.println("Sending");
}

void loop() {
  Serial.print('H');
  delay(1000);
  Serial.print('L');
  delay(1000);
  Serial.println();
}

不幸的是,没有任何反应。我都试过了,ESP 作为发送者,Spresense 作为接收者,反之亦然。

当我以两种方式连接我的 ESP 和 Arudino Uno 时,它就像一个魅力。

我是否必须以某种方式使用 Spresense 启用 RX/TX 引脚?开发板上的插脚我都试过了,小板上的插脚也直接试过了。有什么建议吗?

我快速查看了一下,我的最佳猜测是,检查代码后的提示是在 Spresense 端尝试以下操作:

只需将 Serial 更改为 Serial2.

void setup() {
  Serial2.begin(9600);
  while (!Serial2) {;}
  Serial2.println("Sending");
}

void loop() {
  Serial2.print('H');
  delay(1000);
  Serial2.print('L');
  delay(1000);
  Serial2.println();
}

我还没有测试过,如果可以的话请做。

我注意到以下位置提供的硬件数据表中的一个小细节:

Spresense Hardware Documents

在标记为 - 2. Spresense 和 Arduino Uno 的区别的部分:

它有一个小 table 显示与解释的比较。

位于 table 底部,可以看到用于 UART 串​​行通信的框。

注意 spresense 板上有两个串行输出。 Spresense 主板(更小的 nano)有一个串行 UART rx/tx 对,语法变量 -> "serial" 但除此之外,Spresense 扩展板还有第二个 UART RX/TX 对,语法 - > "serial2"

"The Spresense main board and extension board have UART terminals.

It is not possible to use the UART on both the main board and the extension board at the same time.

The extension board is configured to have the UART enabled when it is shipped. To use the UART pins on the main board when attached to the extension board, a 2.54mm pitch jumper have to be connected to pin 1 and 2 on JP10 of the extension board to disable the extension board UART. No jumper is supplied with the Spresense boards so this has to be purchased separately.

When the extension board UART is activated, the UART pins (D00, D01, D27 and D28) of the main board cannot be used as GPIO."

在我意识到查看文档提供了人们可能需要的所有答案之前,我最终花了大约三天时间拔掉头发..

杀手就在这一个的细节中。

这应该让其他在尝试使用扩展板时尝试在 spresense 产品之间进行 UART 通信的人清楚一些。