Accessing through Serial Monitor a device connected to UART1/2/3 on Mega

Hi everyone! I'm new to Arduino and electronics in general, and to posting on forums too, so please be indulgent if this sounds an obvious question, or if this topic should be in another section.

I have a Mega 2560, to which I've connected an ESP8266 on UART3 (pins 14 & 15) and I'd like so send and read (the result of) AT-Commands to it via the Serial Monitor. I know my PC is connected via UART0 and that I can write or read to/from it with the SM.

Can I use the SM to send and read commands to a device connected to UART1/2/3 directly with some kind of prefixe or I'll have to write code reading from UART0 (Serial) to redirect it to another UARTx (Serialx), and read from the later to redirect on UART0?

Thank you for reading! (and for answering!)

#define BAUD 115200L

void setup() {

void loop() {
  while (Serial.available()) {
  while (Serial1.available()) {

Thanks Juraj for your reply!

So, in SM window, if I type AT+RST then click send, the command will be sent to every initialized serial port, right?

Sorry, I can't try it now since I'm at my work place, but I'd like to get your (or someone else's) confirmation on that.


no. the version I posted bridges to Serial1. change it to port you need

Thanks a bunch! I didn't scroll down the code you posted so I've just saw the setup function :-[ It makes more sense with the part in the loop