Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

GPIO Power button and LED indicator - AddOn (v0.1)

videotecaCNSUvideotecaCNSU Posts: 279Validating, Plex Pass Plex Pass

0.1 tested on build 1.6.2.123

I hate I don't have a physical power button to turn on and off my rasplex without dealing with physical addons or having to unplug and plug again to restart my rasplex. Things that I thought that could be easily be solved with a push button.

I also added a power button to power a LED so I can know If rasplex is up and running as the default green and red led indicates other things like SD access and if it has power.

For all this Im adding the python GPIO support to rasplex which isn´t available on normal setups

To install

Extract the content inside "/.plexht/addons/packages/" so you get a gpio folder

if you dont know how to uncompress in linux its
tar xf gpio.0.1.tar.gz

Edit or create autostart.sh (default location at "/.config") with

#!/bin/sh
(PYTHONPATH="${PYTHONPATH}:/storage/.plexht/addons/packages/gpio/lib";
export PYTHONPATH;
sleep 10s;
python ~/.plexht/addons/packages/gpio/bin/shutdown.py;) &

and reboot

Features

  • Press the power button to turn Rasplex on
  • Press the power button for 3 seconds to securely turn off Rasplex
  • Lights a LED connected to PIN 10 to indicate if the unit is running

Wiring

For this I'm connecting ping 5 to ground ping 6 with a pushbutton
Pin 10 goes to the LED circuit back to ground pin 9
So your setup should look something like this.

I wont explain LEDs and resistors here but you cant connect a LED directly to your Rpi, you need to use a resistor and anything over 15 Ohms should do the trick with LEDs of 20 mA. Just add a bigger resistor if you want it dimmer.

If you notice my script it only takes care of shutting down the system, as Pin 5 its the default Pin for powering on any Raspberry from standby. So its nice to use the same pin for shutting it off.

I also like to use pin 6 and 9 as my ground pins as they are next to the others.

Hope you find it useful for your setups, its specially useful if you are building your own case

Comments

  • c0b4ltc0b4lt Posts: 1Members, Plex Pass Plex Pass

    Thanks for this. Going to give it a try later this coming week.

  • wavrunrxwavrunrx Posts: 6Members Plex Pass

    "Press the power button for 3 seconds to securely turn off Rasplex"

    and by 'securely' you mean gracefully shutdown ? or.. ?

  • videotecaCNSUvideotecaCNSU Posts: 279Validating, Plex Pass Plex Pass
    edited December 2016

    @wavrunrx said:
    "Press the power button for 3 seconds to securely turn off Rasplex"

    and by 'securely' you mean gracefully shutdown ? or.. ?

    Yes, it will send a shutdown command and preserve the SD from any corruption.

    Its exactly the same state as if you shut it down from the menu and leave the power cord connected, but pin 5 works as a wake up to power it up with the touch of a button.

    Think of it as a stand by state on any other device

  • guywithabeardguywithabeard Posts: 21Members, Plex Pass Plex Pass

    Thanks!

    I've been looking for a pre-built RPi.GPIO version for almost 6 hours, none of them worked, or links were dead or led to shady places... Should have checked here first ;)

    Now I can finally finish my dualboot Rasplex/RetroPie machine by adding my momentary latching button to it, so the gf can easily shut it down after using it.

  • compoticompoti Posts: 67Members, Plex Pass Plex Pass

    And yesterday I have soldered cable to the "Run" pins of the RP3 to connect a start button. I could have really easier :D

    My Plex Server
    Local Storage: 9TBs WD Red, stored in a Fractal Define R5 housing
    Server: AMD FX6300 (6x3.5 GHz) - ASUS M5A 78L-M Plus - 8GB DDR3 RAM
    OS: Windows Server 2016 Essentials
    Media Devices
    Raspberry Pi2, Raspberry Pi3, Microsoft Surface 3, iPad mini, Lumia 930, OnePlus 3, FireTV, custom Desktop PC, XBox One, XBox 360, Telekom Puls Tablet
    Additionally installed
    Booksonic Server, Emby Media Server

  • videotecaCNSUvideotecaCNSU Posts: 279Validating, Plex Pass Plex Pass
    edited February 13

    @compoti said:
    And yesterday I have soldered cable to the "Run" pins of the RP3 to connect a start button. I could have really easier :D

    Well to be fair, those pins are for something different as it will do a hard reset so you don´t really want to accidentally press it and corrupt your SD so it might be a dangerous option for powering on a Pi.

    Make sure your button doesn´t pop out of your case to avoid any accident.

  • compoticompoti Posts: 67Members, Plex Pass Plex Pass

    My Raspberry will shutdown after 60 minutes in idle and the Button is only for a cold start. But I think I want to change to your GPIO start button. It just looks much more meaningful. Apart from that, I would also like a working light.

    My Plex Server
    Local Storage: 9TBs WD Red, stored in a Fractal Define R5 housing
    Server: AMD FX6300 (6x3.5 GHz) - ASUS M5A 78L-M Plus - 8GB DDR3 RAM
    OS: Windows Server 2016 Essentials
    Media Devices
    Raspberry Pi2, Raspberry Pi3, Microsoft Surface 3, iPad mini, Lumia 930, OnePlus 3, FireTV, custom Desktop PC, XBox One, XBox 360, Telekom Puls Tablet
    Additionally installed
    Booksonic Server, Emby Media Server

  • compoticompoti Posts: 67Members, Plex Pass Plex Pass

    Yesterday I have upgraded my Raspberry in the child room with your GPIO start button. It's work great, thanks for the addon :-bd

    My Plex Server
    Local Storage: 9TBs WD Red, stored in a Fractal Define R5 housing
    Server: AMD FX6300 (6x3.5 GHz) - ASUS M5A 78L-M Plus - 8GB DDR3 RAM
    OS: Windows Server 2016 Essentials
    Media Devices
    Raspberry Pi2, Raspberry Pi3, Microsoft Surface 3, iPad mini, Lumia 930, OnePlus 3, FireTV, custom Desktop PC, XBox One, XBox 360, Telekom Puls Tablet
    Additionally installed
    Booksonic Server, Emby Media Server

  • videotecaCNSUvideotecaCNSU Posts: 279Validating, Plex Pass Plex Pass

    @compoti said:
    Yesterday I have upgraded my Raspberry in the child room with your GPIO start button. It's work great, thanks for the addon :-bd

    Good to know its of some use

    on the next update, once I have some free time, I think I will make the countdown half long and place a GUI notice to let you know you are shutting down the system

  • One Bit WonderOne Bit Wonder Posts: 12Members, Plex Pass Plex Pass

    Hello, thank you for this feature.

    I have unzipped all the files installed in the correct location as well as creating the autostart.sh in the /.config directory. However, it is not working and I don't know how to troubleshoot.

    When I press and hold the button it shuts the pi down after about 10 seconds and I need to power cycle to get it running again. I get the feeling that the autostart file is not doing what it should.

    I am not new to electronics but I don't do any programming and python is new to me. It took me forever to figure out how to ssh into the pi and navigate around. Very willing to learn, though.

    Thanks

  • videotecaCNSUvideotecaCNSU Posts: 279Validating, Plex Pass Plex Pass

    @One Bit Wonder said:
    Hello, thank you for this feature.

    I have unzipped all the files installed in the correct location as well as creating the autostart.sh in the /.config directory. However, it is not working and I don't know how to troubleshoot.

    When I press and hold the button it shuts the pi down after about 10 seconds and I need to power cycle to get it running again. I get the feeling that the autostart file is not doing what it should.

    I am not new to electronics but I don't do any programming and python is new to me. It took me forever to figure out how to ssh into the pi and navigate around. Very willing to learn, though.

    Thanks

    Hi @One Bit Wonder
    The script itself just takes care of the safe shutdown process, to power it up you need to close the circuit of ping 5 and ground. Its just a feature that its just build on the Pi itself. And thats the main reason why Im using the ping 5 for the power.

    Also make sure that you are using a push button

  • One Bit WonderOne Bit Wonder Posts: 12Members, Plex Pass Plex Pass
    edited September 14

    I am using a momentary button to short the gpio3 to ground. The Pi does not sleep after 3 seconds, nothing happens after 3 seconds. If I hold for close to 10 it shuts the pi down and I have to reboot.

    I have wired a led and current limiting resistor from gpio 15 to gnd and that works.

    You say the script takes care of the shutdown, so it seems the script is not being executed. Suggestions on how to troubleshoot this?

  • videotecaCNSUvideotecaCNSU Posts: 279Validating, Plex Pass Plex Pass

    @One Bit Wonder said:
    I am using a momentary button to short the gpio3 to ground. The Pi does not sleep after 3 seconds, nothing happens after 3 seconds. If I hold for close to 10 it shuts the pi down and I have to reboot.

    I have wired a led and current limiting resistor from gpio 15 to gnd and that works.

    You say the script takes care of the shutdown, so it seems the script is not being executed. Suggestions on how to troubleshoot this?

    If the Pi shutsdown after X number of seconds, then the script its working correctly

    The reason it takes more time its that the circuit you are building with the push button circuit isnt good enough for the script to read a stable signal without interruptions for 3 continuos seconds. This might have to do with some radio interferences, a bad button or things like that. Im shure that the circuit could be made better but I havent bothered as it just works for me.

    If you find it hard to shut down just make the time value smaller

Sign In or Register to comment.