'ESP32 - SoftwareSerial Library

I have a ESP32 and I need to work with more serial ports, but I can't be using the Software Serial Library into ESP32, because the Arduino IDE don't recognize the library.

How could I be using it?

   #include <Arduino.h>
   #include <SoftwareSerial.h>

   SoftwareSerial SoftSerial(4, 5);

   void setup() 
   {
     Serial.begin(9600);
     SoftSerial.begin(115200); 
   }

   void loop() 
   {
     while (Serial.available())
     {
       SoftSerial.write("on");
     }
   }

Thank You



Solution 1:[1]

The ESP32 has 3 different Serial Ports (UART). You can just use one of them:

Serial0: RX0 on GPIO3, TX0 on GPIO1
Serial1: RX1 on GPIO9, TX1 on GPIO10 (+CTS1 and RTS1)
Serial2: RX2 on GPIO16, TX2 on GPIO17 (+CTS2 and RTS2)

You don't need the Software Serial Port, since the ESP32 can unconfigurate internally the Serial port pin to other pins.

To do that, you need to use the <HardwareSerial.h> - library

This library is already installed with your board:
https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/HardwareSerial.cpp

Edit: As said by Juraj, if you need more than 3 serial ports, you can use this library for the ESP:
https://github.com/plerup/espsoftwareserial

Solution 2:[2]

You may want to use EspSoftwareSerial library available in this repository.

If you are using the Arduino IDE, install the library by clicking the "Sketch" menu, "Include Library" and then "Manage Libraries".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Adriano
Solution 2 matheusrfd