How can I communicate full duplex using UART on Arduino Mega

Hi,

I will not use ISR and I can use 2 or 3 UART ports to communicate. I will send a message to one board then this board will send to another board simultaneously then I will see what I sent on another monitor. Additionally, I can send a message via the last monitor. How can I do this? Which pins can be used?

I will send a message to one board then this board will send to another board simultaneously then I will see what I sent on another monitor.

is that what you have in mind ?

board A ==> board B ===> board C  ===> monitor

what do you mean by "simultaneously" ? do you want the board B to do anything (like receive a byte and forward the byte to C) or do you mean the signal from A has also to arrive to C at the same time it arrives to B.

Same question on C. Do you want the data from A to show up on the monitor without C being involved or is it OK for C to receive a byte and send it to the monitor?

from serial monitor ==> to board a == to board b ==> to another serial monitor

All of the Mega's UARTs work full duplex.

The Mega has to receive a message before it can transmit it to something else so it can't be simultaneous.

If you want several devices to receive the message at exactly the same time then you need to connect the master's Tx line to the Rx of all the slaves.

You can also connect several slave Tx lines to the master Rx if you use diodes to isolate each Tx from the others. But that arrangement can only work full-duplex for one slave at any one time. The master has to indicate to a slave when it is appropriate for it to talk.

It will be very much easier to help you if you provide an overall description of the project you want to create.

...R

On a Mega you can use Serial1, Serial2, or Serial3 between the two Arduinos.

void setup()
{
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop()
{
  if (Serial.available())
    Serial1.write(Serial.read());
  if (Serial1.available())
    Serial.write(Serial1.read());
}