【问题标题】:Serial Communication of Sony Spresense with ESP8266 E12Sony Spresense 与 ESP8266 E12 的串行通信
【发布时间】:2019-01-06 14:17:59
【问题描述】:

我正在尝试在我的 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 作为 Sender 和 Spresense 作为 Receiver,反之亦然。

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

我是否必须以某种方式启用 Spresense 的 RX/TX 引脚?我已经直接尝试了开发板和小板上的引脚。有什么建议吗?

【问题讨论】:

标签: esp8266 spresense


【解决方案1】:

我对此进行了快速浏览,我的最佳猜测或检查代码后的提示是在 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();
}

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

【讨论】:

【解决方案2】:

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

Spresense Hardware Documents

在标记为 - 2. Spresense 和 Arduino Uno 之间的差异的部分中:

它有一个小表格显示比较和解释。

位于表格底部,可以看到用于 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 通信的人提供一些清晰的信息。

【讨论】:

    猜你喜欢
    • 2017-07-19
    • 1970-01-01
    • 2019-07-06
    • 1970-01-01
    • 2016-06-11
    • 2020-03-04
    • 1970-01-01
    • 2017-07-16
    • 1970-01-01
    相关资源
    最近更新 更多