Serial Communication between Arduino series , ESP32 , ESP8266 etc pin discussion

on the ESP32 U0UXD is used to communicate with the ESP32 for programming and during reset/boot. U1UXD and U2UXD hardware serial ports are available for user projects

At boot, ESP8266 Serial uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3 (RX).
UART1 is not easy to access so EspSoftwareSerial can be used, e.g. a simple program using EspSoftwareSerial

// ESP8266 EspSoftware Serial test

// At boot, Serial uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3 (RX).

// using library manager download and instal EspSoftwareSerial or instal ZIP
// https://github.com/plerup/espsoftwareserial

#include <SoftwareSerial.h>

// pins Rx GPIO14 (D5) and Tx GPIO 12 (D6) 
 SoftwareSerial swSer(14, 12);  

 // for loopback test connect pin D5 to pin D6

// for RS232 shield connect
// ESP8266 pin D6 TXD to TTL/RS232 Tx
// ESP8266 pin D5 RXD to TTL/RS232 Rx
// for loopback test connect 9-pin D_type connector pins 2 Tx to 3 Rx (pin 5 is GND)
// connect GND pins together and VCC to 5V

void setup() {
  Serial.begin(115200);   //Initialize hardware serial with baudrate of 115200
  swSer.begin(9600);      //Initialize software serial with baudrate of 9600
  Serial.println("\nESP8266 Software serial test started");
  Serial.println("-  for loopback test connect pin D5 to pin D6\n");
 }

void loop() {
  while (swSer.available() > 0) {  //wait for data at software serial
    Serial.write(swSer.read()); //Send data recived from software serial to hardware serial    
  }
  while (Serial.available() > 0) { //wait for data at hardware serial
    swSer.write(Serial.read());     //send data recived from hardware serial to software serial
  }
}

similar program for ESP32

// ESP32  Serial1 test - for loopback test connect pins RXD1 and TXD1

#define RXD1 16 // can map Serial1 and Serial2 to many ESP32 GPIO pins
#define TXD1 17 // check pin usage https://randomnerdtutorials.com/esp32-pinout-reference-gpios/

// for RS232 shield connect
// ESP32 RXD1 to TTL/RS232 Rx
// ESP32 TXD1 to TTL/RS232 Tx
// connect GND pins together and VCC to 3.3V on ESP32 5V on UNO ect
// for loopback test connect 9-pin D_type connector pins 2 Tx to 3 Rx (pin 5 is GND)

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  Serial1.begin(115200, SERIAL_8N1, RXD1, TXD1);
  Serial.printf("\n\nESP32 serial1  test RXD1 pin %d TXD1 pin %d\n", RXD1, TXD1);
  Serial.printf(" loopback test connect pin %d to pin %d\n", RXD1, TXD1);
  Serial.printf("RS232: ESP32 pin %d RXD1 to TTL/RS232 Rx and pin %d TXD1 to TTL/RS232 Tx\n", RXD1, TXD1);
  Serial.printf("RS232 - loopback connect 9-pin D-type pin 2 Tx to pin 3 Rx\n");
}

void loop() {
  // read from Serial1, send to Serial
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }
  // read from Serial, send to Serial1
  if (Serial.available()) {
    int inByte = Serial.read();
    //Serial.write(inByte);     // local echo if required
    Serial1.write(inByte);
  }
}

try connecting (make sure baudrates are identical)
ESP32 RXD1 pin 16 to ESP8266 Tx GPIO 12 (D6)
ESP32 TXD1 pin 17 to ESP8266 Rx GPIO14 (D5)

text entered on ESP32 serial monitor should appear on the ESP8266 display etc