MuntyScruntfundle
Posts: 223
Joined: Fri Oct 27, 2017 11:14 pm

2 x pi sending signal.

Thu Jan 03, 2019 12:00 pm

Hi there.

If I had two pis that need to send a signal to a relay, can I connect both sending pins together? Or is sending voltage down an 'out' pin not such good idea? I could see why this wouldn't be such a great thing.

If I can't do this, what is the simplest, smallest OR gate I could put in between?

Many thanks.

User avatar
rpdom
Posts: 14987
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: 2 x pi sending signal.

Thu Jan 03, 2019 12:21 pm

Connecting two output pins together is definitely a bad idea (unless they are open collector outputs, which the GPIOs are not).

The simplest OR gate is just two diodes and a resistor. One diode from each output and a pull-down resistor. The only thing you might need to watch out for is the voltage drop across the diodes.

User avatar
rpiMike
Posts: 852
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: 2 x pi sending signal.

Thu Jan 03, 2019 12:31 pm

How about connecting Pi 1 to the relay, then use software to send a signal from Pi 2 to Pi 1 when Pi 2 needs to switch the relay?

MuntyScruntfundle
Posts: 223
Joined: Fri Oct 27, 2017 11:14 pm

Re: 2 x pi sending signal.

Thu Jan 03, 2019 12:39 pm

Yeah, there could actually be 8 pis sending a signal to turn a fan on. I currently have a serial loop which sends command around the network in a token ring fashion, the one designated pi then sends the signal to turn on the fan. This is working perfectly well, I was just wondering if there was a simpler option, but I think I'm already using it.

Thanks for your feedback.

User avatar
rpiMike
Posts: 852
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: 2 x pi sending signal.

Thu Jan 03, 2019 12:47 pm

I use MQTT (Mosquitto) for sending messages between Pi's across my home network.

MarkTF
Posts: 297
Joined: Tue Mar 03, 2015 4:59 pm

Re: 2 x pi sending signal.

Thu Jan 03, 2019 3:20 pm

You won't damage GPIO pins connected together if they are inputs (duh?) or if any that are outputs are set to the same logic level. Thus you can emulate "open collector" (open drain) outputs on a RPi by setting the GPIO Pin to be an input when it is inactive and setting the GPIO Pin to be an output set to "0" in the active state. As long as all sources in the network honor this convention it should work without damaging GPIO.

With open collector outputs an "or" function can be formed with a single pullup resistor (0 V is "active" state):

Image

Likewise a 3.3V "active" state can be formed by using a pulldown resistor and setting the GPIO pin(s) to "1" in the active state and input in the inactive state.

This scheme is what is done to interface with "one wire" sensors like the DHT11/22 and DS18B20 which have two signal potential signal sources on the same wire.

Return to “General discussion”