ac1n0nyx
Posts: 3
Joined: Fri Jan 24, 2020 6:18 pm

Control multiple Raspberry Pi with one button (GPIO)

Fri Jan 24, 2020 7:46 pm

Hi, everyone!

I would be grateful for a solution for a phantom button presses issue I am facing.

Background
I have used following video to construct a scheme attached to the post
https://www.youtube.com/watch?v=NAl-ULEattw

It works fine with one exception:

one of the Pies is having constant phantom presses.

I have reduced length of the "orange" part of wires from 4 to 0,5 to factor out EMR - no luck.

Since one of the Pies is working fine, I suspect it might be something in the scheme I botched up.

Thanks for the feedback!

P.S. If there are any other solutions to trigger a script with a button press on multiple Pies, I am open for suggestions
Attachments
scheme_800.jpg
connections
scheme_800.jpg (159.82 KiB) Viewed 215 times

User avatar
Burngate
Posts: 6182
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Control multiple Raspberry Pi with one button (GPIO)

Sat Jan 25, 2020 9:54 am

You haven't connected the grounds of the two Pis together.

The top Pi, supplying the 3v3, "knows" whether its GPIOs are at 3v3 or at ground.
The bottom one just sees a floating GPIO, which could be anywhere between its ground and 3v3 (hopefully not outside that range, but you can't be sure)

You could achieve the same result by joining the 3v3 of the two Pis together instead, but not at the same time as the grounds - the two supplies would fight, and one could lose.

Depending on what else is going on, it might be better to have the switch pulling the GPIOs to ground instead of to 3v3

ac1n0nyx
Posts: 3
Joined: Fri Jan 24, 2020 6:18 pm

Re: Control multiple Raspberry Pi with one button (GPIO)

Wed Jan 29, 2020 7:34 pm

Thanks do much for your input!

I am completely new to this - this has been driving me nuts.
Burngate wrote: You haven't connected the grounds of the two Pis together.
following 5 wires are connected together:
Out of the button
Pi1 pin 16 GPIO
Pi1 pin 20 GND
Pi2 pin 16 GPIO
Pi2 pin 20 GND
Burngate wrote: The top Pi, supplying the 3v3, "knows" whether its GPIOs are at 3v3 or at ground.
The bottom one just sees a floating GPIO, which could be anywhere between its ground and 3v3 (hopefully not outside that range, but you can't be sure)

You could achieve the same result by joining the 3v3 of the two Pis together instead, but not at the same time as the grounds - the two supplies would fight, and one could lose.
Do I understand you right - GPIOs are like 3v3 - have something going on in them?
Burngate wrote: Depending on what else is going on, it might be better to have the switch pulling the GPIOs to ground instead of to 3v3
So, in the code I change PULL UP to PULL DOWN and switch the wires around - i.e.:
one one side of the button I connect:
Pi1 pin 20 GND
Pi2 pin 20 GND

one the other side:
Pi1 pin 16 GPIO
Pi1 pin 1 3,3v
Pi2 pin 16 GPIO

This way I can connect as many Pis as I like (I need up to 30) and the system will do what it has to:
simultaneously start a script on every Pi?

User avatar
davidcoton
Posts: 4533
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Control multiple Raspberry Pi with one button (GPIO)

Wed Jan 29, 2020 10:38 pm

NO!
on one side of the button I connect:
Pi1 pin 20 GND

on the other side:
Pi1 pin 1 3,3v
That will just short out Pi1's 3V3 supply, instantly crashing it and possibly destroying the 3V3 regulator.

Connect a GND form each Pi to one side,
Connect a GPIO input through a 1K resistor to the other, also a 10K resistor to ONE 3V3 supply.
Do not select any PULL-UP or PULL-DOWN on the GPIOs.

The 1K resistors will prevent any damage if you accidentally make any of the connected GPIOs an output, and will help in the event of any wiring faults.

3V3 through 10K will hold all the inputs high until the button is pushed.

This will work as long as the Pis are close together, tidily wired with short cable runs. Longer runs of cable are prone to RF interference, and will need further measures -- but get the simple system working first.
Signature retired

ac1n0nyx
Posts: 3
Joined: Fri Jan 24, 2020 6:18 pm

Re: Control multiple Raspberry Pi with one button (GPIO)

Thu Jan 30, 2020 3:28 am

davidcoton wrote:
Wed Jan 29, 2020 10:38 pm
3V3 through 10K will hold all the inputs high until the button is pushed.

This will work as long as the Pis are close together, tidily wired with short cable runs. Longer runs of cable are prone to RF interference, and will need further measures -- but get the simple system working first.
Roger that!
Will test it 👍🏻

Could you kindly clarify one part:
davidcoton wrote:
Wed Jan 29, 2020 10:38 pm
Do not select any PULL-UP or PULL-DOWN on the GPIOs.
Does this mean I have to alter the 7th line of my code "GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)":
import subprocess
from subprocess import PIPE
import RPi.GPIO as GPIO
import datetime
from time import sleep

GPIO.setmode(GPIO.BOARD)
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
isRecord=False

try:

while True:

sleep(0.3)
input_state = GPIO.input(16)

if input_state == 1 and isRecord==False:

User avatar
davidcoton
Posts: 4533
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Control multiple Raspberry Pi with one button (GPIO)

Thu Jan 30, 2020 10:41 am

Yes.
Signature retired

Return to “Beginners”