Go Down

Topic: Bridging two arduino's (Read 263 times) previous topic - next topic


Jun 22, 2018, 05:36 pm Last Edit: Jun 22, 2018, 05:43 pm by Mike_Malaysia
   |                                   |        |                                   |
   |                                   |        |                                   |
   ~~~~~~~~~~~~         ~~~~~~~~~~~~~

I'd like a controlling device to send a 1/0 to one of the arduino's (and a complementary logic level
to the other arduino)  which, if 1, will set that Arduino's RX/TX line active so that arduino can
RX/TX with the controlling device.
I am trying to make an I/O expanded (using arduino's only), but I don't know do to swtich on/off Serial.begin(speed).
Can this be done and how?
I should say the ControllingDevice only has one RX/TX line hence I need some switching method to turn one arduino while 'sleeping' the other.


The part you are looking for is a multiplexer
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.


I think it can be done. You must be careful with the TX output of the two Arduinos; if the one sends a logical 1 and the other one a logical 0, it's quite unhealthy.

The device that is not sending needs to place its TX in tristate (pinMode INPUT). Next the other device can do a Serial.begin() and transmit.

The device (Arduino) code could look something like below. No idea if it works and use at own risk; it would be something that I would try though if it was my requirement not to add any additional hardware.
Code: [Select]
void loop()
  static bool serialEnabled = false;

  // if we had the serial connection and the request pin is low
  if (requested == false && serialEnabled == true)
    // flush remaining data and stop
    // tx pin tristate
    pinMode(1, INPUT);

    // indicate we no longer have the serial connection
    serialEnabled = false;

  // if we did not have the serial connection and the request pin is high
  if(requested == true && serialEnabled == false)
    // setup serial connection

    // indicate that we have the serial connection
    serialEnabled = true;

  // if we have the serial connection
  if(serialEnabled == true)
    // send data

The better way though would be a multiplexer (as mentioned) or use RS485. The latter is a bus and takes care of the tristate condition (if implemented correctly).
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.


Jun 23, 2018, 12:19 pm Last Edit: Jun 23, 2018, 12:20 pm by PaulRB
There are simpler and more sensible ways to increase the i/o of an Arduino than using multiple Arduinos.

First step: post your schematic. There are often ways to reduce the i/o pins needed by selecting the right components, e.g. i2c backpacks for LCD displays or arranging buttons or LEDs into matrices.

If the number of i/o cannot be easily reduced, there are several types of i/o expansion chips available, depending on what type of i/o are needed.

Go Up