Simples and safest way to send signal from Arduino A to Arduino B

Hey folks,

I'v read a bunch of "how to connect two Arduinos" threads now, yet I still don't know how to do this the easiest and safest way.

All I need is a short Signal from Arduino A (transmitter) to Arduino B (receiver).
While the receiving Arduino will be powered first, the transmitting Arduino will be powered at a later point, read a bunch of sensors and eventually send a signal. Both are connected to the same Powersupply, and I would also connect the GNDs.

I tried the following:
A) I tried using the internal pullups on the receiving side, but I couldn't get the transmitting pin on Arduino A to be LOW / connecte to GND.
B) I connected 1 Output Pin on Arduino A to 1 Input Pin on Arduino B, and also connected it to GND via a 10k pulldown resistor. (See attachment)

B) seemed to work, but I'm still not sure if this is a safe way of doing it.

Any suggestions would be greatly appreciated!

Hi there!

It seems like this is a great way to connect two Arduinos. The first is acting like an SPST (single-pole-single-throw) switch like a button or something, and the second is receiving that voltage. The resistor to ground is also an excellent addition as it allows a path for the current to travel so that it won't harm the second Arduino board.

For the communication, are you simply trying to send a high/low signal to indicate status, or do you want to send variable values and such?

I'm not stating fact, I haven't actually performed an analysis. The statements below are my belief based on reading other posts and vague observations.

With the common ground, the pins of the first arduino are feeding the second arduino while it is powered down. The common ground combined with the direct connection of the arduino I/O pins is the problem.

Since you state you are using a single power supply, I'm not sure how you are controlling the power individually to each arduino. Whether one power supply or two won't matter much.

I would propose the use optoisolators on the I/O pins. The TX arduino connected to the LED, and the RX connected to the transistor. The transistor pull-up resistor will be connected to power of the RX arduino, which is powered off. Secondly, if you use two power supplies, it will isolate the circuits entirely.

Use pseudo-open-collector mode to write the line, i.e.:

void setup()
{
  pinMode (TXpin, OUTPUT);  // default low, same as unpowered
}

void tx(bool state)
{
  pinMode (TXpin, state ? INPUT_PULLUP ? OUTPUT) ;  // open-collector style, either driven low or pulled up high
}

This avoids ever driving the pin high, so cannot damage the receiver if unpowered. An external 10k
pullup resistor to Vcc can be added for improved robustness in the face of noise/interference. Too low
a value pull-up resistor risks phantom-powering the receiver if its unpowered though.

Hi,
Why do you want to connect two UNOs?
Can one UNO do all the work, whatever it is?
Can you explain the application, if both UNOs are running off same supply, how far apart are they positioned.

OPs pic;

Tom.... :slight_smile:

Thanks for your inputs!
The transmitting Arduino is cut off via a relay at first and will get powered at a later point. I just need to send a HIGH/LOW signal at a certain point to tell Arduino B to do stuff.

@adwsystems
I like the idea of having the two circuits isolated. I'll look into optoisolators, since I didn't really understand anything you said yet XD Can you control the signal at any point, eg. set it to HIGH and LOW whenever you want?

@MarkT
Is the pseudo-open-collector mode different from just setting the Pin to HIGH / LOW?
From what I understood, this is a way to really pull the pin to GND, and it's basiacally a solution for the above stated A) – crrect?
Would I place the 10k pullup resistor between the RX pin and Vcc on the RX arduino? Is the internal pullup resistor not enough? And would you reckon, 10k is enough to keep the TX arduino from being phantom-powered?

@TomGeorge
I'm building an Escape Room Box with a bunch of puzzles. The receiving Arduino (B) is supposed to handle the soundtrack of the game. At certain points it should receive a signal to play the next track. My problem is that I have 3 additional Arduinos that each have to send a signal to the Audio Arduino at some point. I'm just lost as to how to do this the safe way withut damaging any of the Arduinos involved.

Arduino (A) is a radio prop with another mp3 shield and thus only has a few I/O pins available.
They are about 1,5 meters apart.

An optoisolator contains an LED and a phototransistor.

opto.jpg

The output connects to the LED via a current limiting resistor that you provide.

The input connects to the transistor with a pull-up resistor.

The simple implementation typically results in inverting the signal because 1 output lights the LED which turns on the transistor and connects the pull-up to ground. So 1 in = 0 out.

For full isolation, the LED is connected to the TX Arduino and its power supply ground. The transistor, pull-up resistor, and its ground is connected to the RX Arduino and its separate power supply.

To just isolate the pins to circumvent the problem I think you have, then using one power supply and connecting the grounds will provide a break in the power flowing between the TX Arduino output pin and the RX Arduino input pin.

Datasheet for the CEL PS2501, my go to optoisolator.

The direct connection works if you simply leave all Arduinos powered up. No need to keep it switched off - just program it so it won't do anything before the signal is received. Much easier, no problems with parasitic powering and so.

The only problem is, that the Transmitter would be switched off at the beginning. I'd need an additional signal then, just to "turn on" the Transmitter, which then would send a signal back to the Receiver.

Since I have 1 Mega which acts as audio control and 3 additional Arduinos (that need to tell the Mega to play another track), I'm starting to wonder if serial communication would be easier than running 3 seperate signal wires...

gandarufu:
The only problem is, that the Transmitter would be switched off at the beginning. I'd need an additional signal then, just to "turn on" the Transmitter, which then would send a signal back to the Receiver.

Both are connected to the same Powersupply, and I would also connect the GNDs.

If your power supply is at the Rx end, then just get the Rx UNO to control the positive supply wire to the Tx UNO, you don't need to send a "wakeup" signal.
Tom.. :slight_smile:

TomGeorge:
If your power supply is at the Rx end, then just get the Rx UNO to control the positive supply wire to the Tx UNO, you don't need to send a "wakeup" signal.
Tom.. :slight_smile:

Great idea :smiley: Were you thinking by just running a wire from an I/O pin on Rx into the 5v pin on the Tx?

gandarufu:
Great idea :smiley: Were you thinking by just running a wire from an I/O pin on Rx into the 5v pin on the Tx?

No, the output pin will not be able to supply the current needed.

Don't forget a gnd wire between the two as well.
Tom.. :slight_smile:

gandarufu:
Hey folks,

I'v read a bunch of "how to connect two Arduinos" threads now, yet I still don't know how to do this the easiest and safest way.

All I need is a short Signal from Arduino A (transmitter) to Arduino B (receiver).

Do you want wired connection/wired communications, or wireless communications?

Southpark:
Do you want wired connection/wired communications, or wireless communications?

I was just going for wired communication, since it's really only a "trigger" signal for each arduino.

Hi,
If you have A-Tx and B-Rx.

  • B-Rx switches ON A-Tx.
  • A-Tx then sends DATA to B-Rx?
  • A-Tx is then switched OFF

This can be done because both UNOs are powered from the B-Rx end.

I was just going for wired communication, since it's really only a "trigger" signal for each arduino.

What does A-Tx send back to B-Rx?

If data why not use Sofware Serial in both UNOs.
Connect A-Tx Software Serial Tx pin to B-Rx Sofware Serial RX pin.

Tom... :slight_smile:

Thanks for your input, Tom!
Software Serial would be a great solution, but since it's only a trigger signal I now went for the simplest solution and ran a wire from each arduino Tx to my Rx board.

I used MarkT's pseudo-open-collector with Tx, OUTPUT / LOW & Tx, INPUT_PULLUP.
I don't know why it never worked before, but right now this is working like a charm :slight_smile:

This 3 day old video by Ben Eater shows you everything you need to do: