Controlling Power
  • Curious what people do to control power to their Pi / Monitor / backlight? I'd like to have 1 switch to shut everything down.

    My thought was to have a button to shutdown the pi (software wise). Then a switch that controlled power to a power strip where everything was plugged in. I found this:

    http://www.amazon.com/Belkin-F7C016q-Conserve-Power-Switch/dp/B005MYN3OO/ref=sr_1_2?s=electronics&ie=UTF8&qid=1417310466&sr=1-2&keywords=outlet+with+switch

    But was curious if there was a better simpler type of switch I could use.
  • There is something in the FAQ about that. Have you checked it out?
  • From what I saw the FAQ is just about shutting down the Pi, not powering it off/on.
  • You could try that Belkin one. If you wanted to, you could crack it open and rewire the switch to a more accessible location. I would probably use an Arduino for something like this (see http://forum.arduino.cc/index.php?topic=10624.0)
  • I use menu to shut down the pi in a software way and a general power switch to shut down everything.
  • I wired up the Pi to turn my tv on and off. Let me know if you are interested in how I did this. Total cost was less than a dollar. So I turn on my pi and everything else is automatic.
  • Always interested in learning something new (especially something that costs a dollar).
  • I got the RasPi to turn my TV on and off by using a npn 2n3904 transistor.
    I got the transistor in a pack at radioshack (3 different transistors 5 of each for about $4) the other transistors that come with it are similar and could be used for the same purpose.

    Collector is connected to the 5v end of the tv power button,
    Emitter is connected to ground of the tv.
    Base is connected to pin 17 on the RasPi

    I have a file with my code called pushbutton.py
    This is what the code looks like:
    #!/usr/bin/python
    import time
    import RPi.GPIO as GPIO
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(17,GPIO.OUT)
    #button pressed
    GPIO.output(17,GPIO.HIGH)
    time.sleep(1)
    #button released
    GPIO.output(17,GPIO.LOW)
    GPIO.cleanup

    then all I have to do is call the code like this
    sudo /exact/location/of/code/pushbutton.py

    I implemented the code right before the boot animation, and as part of the shutdown script so now the tv automatically turns on and off.
  • Got my pi and monitor on an extension cable, software shutdown then switch off
  • I use the ATXRaspi add on board and then a main power switch to turn everything else off. The cool thing about the ATXRaspi is it have a header for a status LED. I wired that to a set of LEDs that are under the track ball on my cabinet. Looks pretty cool when it's shutting down.

    http://lowpowerlab.com/atxraspi/
  • Great product Dave, thanks for the info... but you can do quite the same with a general switch and the my retrogame program : 1 button to shutdown properly the pi : see https://github.com/ian57/Raspicade-Retrogame-2Player-BPlus/wiki. I added an input on GPIO 15 tu make a sudo halt.
  • @ian57 That is impressive. When I was looking at rebuilding my MAME system around the Pi I looked for a way to use the GPIO pins like what you have done. At the time there weren't enough GPIOs and i had no idea how to go about it, so i used the J-PAC harness I already had.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!