Demo 2 How To Use Multiple Serial Ports On Arduino ESP32
Demo 2 How To Use Multiple Serial Ports On Arduino ESP32
Demo 2 How To Use Multiple Serial Ports On Arduino ESP32
Arduino ESP32
Tech It Yourself 7:19 AM ESP32,
1. Introduction
Arduino ESP32 use Serial port to flash software and print information on Terminal. ESP32 supports 3
Serial ports so you need not to use SoftwareSerial as in general Arduino. In this tutorial we only care
about using How to use multiple Serial port on Arduino ESP32 to print the debug information to
Terminal.
2. Hardware
You do not need any extra hardware. Just connect RX pin G16 with TX pin G17.
3. Software
We use "HardwareSerial" class for Serial communication. It has some important interfaces:
- HardwareSerial(int uart_nr): this is the constructor of HardwareSerial where uart_nr is 0, 1 or 2 so
we have maximum 3 Serial ports.
- void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-
1): initialize Serial port with baudrate, Serial mode (default is SERIAL_8N1), rxPin and txPin (if you
leave these parameters empty library will use default pins).