1

I currently have my Raspberry Pi set up such that it's connected to this assembled Adafruit PiTFT - 320x240 2.8" TFT+Touchscreen for Raspberry Pi. I am also powering the Raspberry Pi with a USB Battery pack which I also got from Adafruit.

I am having trouble shutting down the Raspberry Pi. When I run sudo shutdown -h now it turns off but then immediately turns back on again.

Also, Adafruit sells tactile switches that you can attach, which will work as a power button. However, when I attached one of these tactile switches, it did the same thing. Turned it off briefly and then automatically turned the RPi back on.

How can I effectively turn off my Raspberry Pi?

  • 1
    How is the battery pack connected to the Pi? – Steve Robillard Mar 5 '15 at 0:40
  • 1
    Running sudo shutdown -h nowshould halt the Pi. Why do you think it is running? Does it continue to respond to keyboard etc. There are a few things which can cause a restart e.g. pulling pin 5 low. Do you have anything other than the 26 wire cable connected? NOTE you cannot power the Pi off without adding some additional hardware. I don't know if any such is included or suggested by Adafruit. – Milliways Mar 5 '15 at 6:39
1

A switch will work but you need a locking switch. Most tactile switches are momentary. So you press it and it disconnects the power, but it reconnects when you release it. Something like this would work. Assuming your battery pack is connected to the Pi via the usb port you could also try this.

I had assumed you had a switch between the battery and the Pi. After looking at the code you mentioned from adafruit the issue is not so much one of button type, but that the battery pack continues to supply power to the Pi. You may want to try using the -p flag instead of the -h flag with your shutdown command:

sudo shutdown -p now 

If that does not work you can add a switch between the battery and Pi to prevent restarting. You need to be careful with this because it introduces a race condition. You don't want to kill the power until it halts to avoid corruption to the SD Card. But also want to do it before the Pi restarts. Basically you will have a very small window to actually switch the power off after the system halts and before it restarts. Most of the solutions to this problem (sensing power on the 5 volt rail and disconnecting the power when it is absent) are probably impractical for a portable device (which I am assuming you are building based on the use of the battery pack).

  • Well, with the tactile buttons from Adafruit, I think they added a module that will let you turn any GPIO into a power button. (learn.adafruit.com/…). I am using a switch now (a rocker switch from radioshack). Does that work well in terms of shutting down the system properly? – Marina H. Mar 5 '15 at 0:12
  • Most rockers are locking switches and so should work fine. The GPIO as power button is a good idea, the problem is that you have a battery pack connected so it does the shutdown, but then sees power on the input and reboots. – Steve Robillard Mar 5 '15 at 0:16
  • Note that even if the Pi is powered down it will still be drawing about 125 mA at 5V from the battery. You need a switch on the battery feed to prevent this power loss. If the attached battery is a LiPo the current drain will kill the cells once they drop below about 3V. – joan Mar 5 '15 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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