ESP8266 E12与Sony Spresense的串行通信

时间:2019-01-06 14:17:59

标签: esp8266 spresense

我正在尝试在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引脚?我已经尝试过直接在开发板上以及小板上的引脚。有什么建议吗?

2 个答案:

答案 0 :(得分:1)

I took a quick look into this and my best guess, or tip after checking the code is to try the following on the Spresense side:

Simply change Serial to 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();
}

I have not tested so please do if you can.

答案 1 :(得分:0)

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

Spresense Hardware Documents

在标为-2的部分中。Spresense和Arduino Uno之间的区别:

它有一张小桌子,上面有比较说明。

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

请注意,弹簧板上有两个串行输出。 Spresense主板(较小的纳米级)具有一个串行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通信的人提供一些清晰度。