On some projects, I want a power indicator and a reset switch. Adafruit's Rugged Metal On/Off Switch with Blue LED contains both of these features.
My first, second and third attempts were way too complicated. This version makes things much simpler, and uses the correct push button. No soldering is required.
For Raspberry Pis used by my family, the push button allows them to reboot in an orderly manner, and reboot without my assistance. Kodi will lock up at times, and a reboot fixes most problems.
For this guide, I am using a Raspberry Pi-based media center running Kodi on OSMC.
I've tried several different momentary switches. Adafruit's Rugged Metal On/Off Switch with Blue LED is very cool. Any push button can be used.
This is one of two guides for a Kodi/OSMC hat for the Raspberry Pi. The final hat will have a fan, this push button and an Infrared (IR) Receiver.
Random comments:
Adafruit has some excellent "instructables", but I they are difficult to find. In google, try:
♣search-terms♣ inurl:https://learn.adafruit.com/
rugged led ring inurl:https://learn.adafruit.com/
Fritzing is an amazing tool for breadboarding
Step 1. Ada Fruit Ring LED
I use the ring LED is a power indicator. If the raspberry pi is powered and running then the Ring LED should be lit (or blue). If there is no power or the raspberry pi is shut down, then the ring LED should be off.
Step 2. Ring LED Connections
A breadboard allows me to experiment with the circuit until it works. Male-to-female jumper wires and connecting wires that come with breadboards make this process easier. Male-to-female jumper wires connect the breadboard to the raspberry pi.
The two outer connections on the Ring Push button control the Ring LED. The ground terminal is connected to the Raspberry Pi ground. Ground is (-). And GPIO 24 will be connected to the positive terminal (+).
With 3 yellow and 1 white female-to-female jumper wires, cut off one of the two headers from each cable.
When using colored wire, I try to use white for ground, black for power and Y/R/B/G for GPIO pins
Strip 1/4" inch from the cut end of the wire.
Insert each wire into an opening on the appropriate pin on the Rugged Push Button. The white wire goes into the minus (-) pin. One yellow wire goes into NO1, and the other yellow pin goes into the positive terminal (+)
Solder the wires to the Rugged Push Button.
Connect + of Rugged Push Button to GPIO 24
Connect NO1 to Rugged Push Button to GPIO 23
Connect NC1 to Rugged Push Button to GPIO 25
Connect - to Rugged Push Button Ground
Step 3. Utility software for python
On OSMC, the Ring LED software requires the rpi.gpio package. rpio.gpio is installed by default on raspbian.
The following commands download, build and install rpi.gpio
$ sudo apt-get update
$ sudo apt-get install python-pip python-dev gcc
$ sudo pip install rpi.gpio
Step 4. Get Push Button Script
Open a terminal and log into the Raspberry Pi
In the terminal window, get the LED and PushButton script on the Raspberry Pi
$ wget https://raw.githubusercontent.com/dumbo25/momentary-reset/master/onOff.py
Change the permissions on the filea
$ sudo chmod 755 onOff.py
$ sudo chown osmc:osmc onOff.py
Step 5. Start the script on boot
Get systemd services to start the script on boot:
$ wget https://raw.githubusercontent.com/dumbo25/momentary-reset/master/onOff.service
Copy the script to the right directory:
$ sudo cp pushButton.service /lib/systemd/system/.
$ sudo systemctl daemon-reload
$ sudo systemctl enable onOff.service
$ sudo reboot
The Ring LED should light up!
Push the button twice in 2 seconds to reboot, push twice about 10 second apart and the system will shutdown