Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By WanaGo
#17740 Hello,

Is Serial2 missing from the Arduino IDE for the ESP8266?

I can see Serial and Serial1, but no Serial2.

I am using a NodeMCU 0.9
Serial is for the USB
Serial1 appears to be TX only on pin D4 (GPIO2)
Serial2 should be on D7 and D8 (GPIO13 and GPIO15)

I had a quick look in the core files and I see Serial and Serial1, but no Serial2

Any ideas?

I need this 2nd serial port for my application to talk to a display.

Thanks
User avatar
By Dhruv Acharya
#58559 Actually I am using this Serial.swap() for "clean UART". But found problem:

Problem Description
This is the original post where this thing started. I want to use Serial.swap() and send-receive my application data on D15-D13 after boot-up in binary form. But after Serial.swap(), it can not send 0x00 data on UART. I have tried two sketches, which involves cases of not using and using of "Serial.swap()". I tried to send 0x00 0x01 0x02 in loop in both cases. I am using Serial.swap() after having the need of connecting other MCU on UART with ESP. I have searched this page and this thread. which suggest me that actually I can use this Serial.swap() which will avoid the startup dump and programming problem with UART0 and use this out of box UART0 for data communication.

Hardware
Hardware: ESP-12E
Core Version: 2.3.0

Settings in IDE
Module: Generic ESP8266 Module (ESP-12E)
Flash Size: 4MB/1MB
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 80Mhz
Upload Using: SERIAL
Reset Method: nodemcu

System Setup
I am using ESP-12E, a separate power supply and programing it with Serial to TTL in Arduino Eclipse Plug-in called Sloeber. I am using terminal.exe as my Serial Monitor. I have connected second Serial To TTL on D15-D13, for Serial.swap() UART.

Codes and Outputs are as follows:

Sketch 1 (successful)
Code: Select all//The setup function is called once at startup of the sketch
void setup()
{
   Serial.begin(115200);
}

// The loop function is called in an endless loop
void loop()
{
   for(uint8_t i=0;i<3;i++)
   {
      Serial.write(i);
      delay(1000);
   }
}


Output at terminal.exe in HEX mode
Code: Select all00 01 02 00 01 02 00 01 02 00 01 02


Sketch 2 (problem)
Code: Select all//The setup function is called once at startup of the sketch
void setup()
{
   Serial.begin(115200);

   // Swap serial port to continue on other uart.
   Serial.swap();
}

// The loop function is called in an endless loop
void loop()
{
   for(uint8_t i=0;i<3;i++)
   {
      Serial.write(i);
      delay(1000);
   }
}


Output 2 in terminal.exe in Hex mode
Code: Select all01 02 01 02 01 02 01 02


The problem is when I use Serial.swap() it does not send the 0x00 data on UART. Am I missing something?

Original thread is here
I have also tired Software Serial, but with the same problem and result. Original discussion I have posted here.
I have also raised the issue with github.
Please have a look and help.