I was trying to write a program which can take input from button. Here is the code:

from gpiozero import Button
btn = Button(4)
while True:
    print('You pressed me')
    print('You released me')

Whenever I am pressing the button, my ssh connection gets freezes for a few seconds and gets terminated with the following error message.

"ssh packet_write_wait broken pipe" Please help!

I am on Raspbian stretch, Pi model 1 B+.

Connection is as follows:

ground pin ---> button ---> pin 4 [BCM]

I can see every time when I press button, the red system LED shuts down for that period.


1 Answer 1


If you are connecting pin 4 (5v) to ground pressing the button is shorting your power supply.

The power supply will then shutdown and cut power to the Pi -- killing your ssh connection.

Then it reboots after you release the button and you can repeat the process.

If you want GPIO 4 I think that is pin 7.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.