ErriezSerialTerminal
ErriezSerialTerminal copied to clipboard
Using Serial1 or Serial2, or multiple serial ports.
I'm running on an ESP32 and I need a console to be on two serial port, both Serial and Serial1. Would this be possible? The trick here is that Serial is the normal serial that the boot loader etc uses, this port is used by a user to connect to the board and read/write settings. Serial1 is connected to a Nextion LCD that will write commands and poll for data. Having the same console interface on both serial port makes it all a lot easier.
Serial2 is used for modbus communication.
Hi @Ghuru42, Thanks for your request!
This library currently uses the Serial object which is hardcoded. It is possible to add a new Stream *serial in the constructor and replace all Serial calls via this pointer. I implemented this in my MH-Z19B CO2 sensor library: https://github.com/Erriez/ErriezMHZ19B/blob/master/src/ErriezMHZ19B.h, so it should be possible to do it for this library as well.
@Ghuru42 Can you check if this branch works for you? https://github.com/Erriez/ErriezSerialTerminal/tree/add-serial-port
Now the hardware serial port can be selected in the constructor, for example:
SerialTerminal term1(newlineChar, delimiterChar, &Serial);
SerialTerminal term2(newlineChar, delimiterChar, &Serial1);
Then I'll update the documentation and add this to master. Note: I've tested this on an Arduino UNO which has only one hardware serial port...
Thanks!