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?
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.