First, I love your site, tutorials and courses!
I have a project for which I’d like to use the UART2 peripheral on an ESP32 DOIT DEVKIT V1 board but I cannot seem to get the hardware serial port to work. I’ve included #include <HardwareSerial.h> (but shouldn’t have to as the Serial2 class is already recognized). I initialize in Setup with Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);, where RXD2 = 16 & TXD2 = 17.
Executing Serial2.write(comBuffer, ComBufferSize); produces no output on GPIO17, either to a serial monitor or watching the pin with an oscilloscope.
I thought I remembered an RNT tutorial covering use of multiple serial ports on the ESP32 but I haven’t been able to locate it. Would you kindly point me to one if one exists and/or suggest what I might be missing?
Thanks,
Mitchell
I got this working by declaring a new HardwareSerial instance:
HardwareSerial HostPCSerialPort(2);
and initializing:
HostPCSerialPort.begin(460800, SERIAL_8N1, 27, 14);
It seems odd that no errors resulted when I used the pre-defined “Serial2”, but I learned a lot in the process of figuring this out 🙂