Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Serial1 or Serial2, or multiple serial ports. #6

Open
Ghuru42 opened this issue May 31, 2021 · 2 comments
Open

Using Serial1 or Serial2, or multiple serial ports. #6

Ghuru42 opened this issue May 31, 2021 · 2 comments

Comments

@Ghuru42
Copy link

Ghuru42 commented May 31, 2021

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.

@Erriez
Copy link
Owner

Erriez commented May 31, 2021

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.

@Erriez
Copy link
Owner

Erriez commented May 31, 2021

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants