首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >索尼Spresense与ESP8266 E12的串行通信

索尼Spresense与ESP8266 E12的串行通信
EN

Stack Overflow用户
提问于 2019-01-06 14:17:59
回答 2查看 410关注 0票数 0

我试图在我的ESP8266 E12和索尼Spresense之间创建一个简单的串行通信。我把Spre.RX和ESP.TX连接起来,Spre.TX连接到ESP.RX,Spre.GND连接到ESP.GND。

接受者:

代码语言:javascript
复制
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");
    }
  }
}

发件人:

代码语言:javascript
复制
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引脚吗?我曾经直接尝试过开发板和小板上的引脚。有什么建议吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-01-07 13:22:51

我对此进行了快速的研究,我最好的猜测,或者在检查代码之后的提示是在Spresense方面尝试以下内容:

只需将串行更改为Serial2即可。

代码语言:javascript
复制
void setup() {
  Serial2.begin(9600);
  while (!Serial2) {;}
  Serial2.println("Sending");
}

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

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

票数 3
EN

Stack Overflow用户

发布于 2020-06-18 22:57:53

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

Spresense硬件文档

在标有- 2. Spresense和Arduino Uno之间的区别:

它有一张小表格,显示了与解释的比较。

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

注意,在spresense板上存在两个串行输出。Spresense主板(较小的nano样)有一个具有语法变量->“串行”的串行UART /TX对,但是除了Spresense扩展屏蔽还有第二个UART /TX对(语法为-> "serial2“)。

代码语言:javascript
复制
"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通信的人提供一些清晰的信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54062404

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档