Serial Communication of Sony Spresense with ESP8266 E12

549 Views Asked by At

I'm trying to create a simple serial communication between my ESP8266 E12 and a Sony Spresense. I have connected the Spre.RX with ESP.TX, the Spre.TX with ESP.RX and Spre.GND with ESP.GND.

Receiver:

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");
    }
  }
}

Sender:

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

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

Unfortunately, nothing happens. I tried both, ESP as Sender and Spresense as Receiver and vice versa.

It works like a charm when I connect my ESP and a Arudino Uno, in both ways.

Do I have to enable the RX/TX pins with the Spresense somehow? I have tried the pins on the developer board as well as the small board directly. Any suggestions?

2

There are 2 best solutions below

1
KarlSONY On BEST ANSWER

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.

0
Furt_Tech On

I noticed a small detail in the hardware datasheet provided at:

Spresense Hardware Documents

In the section labeled - 2. Differences between Spresense and Arduino Uno:

It has a small table showing the comparison with explanations.

Located at the bottom of the table one can see the boxes for UART Serial communication.

Note the existence of two serial outputs on the spresense board. The Spresense Main board (smaller nano like) has a serial UART rx/tx pair with syntax variable -> "serial" but in addition the Spresense expansion shield also has a second UART RX/TX pair with syntax -> "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."

I ended up spending about three days pulling my hair out before i realized looking at documentation provides all the answers one could need..

The killer is in the details on this one.

This should provide some clarity to others experimenting with UART communication between spresense products while attempting utilize the expansion board.