Skip to content

The CSB503HTA includes a power switch on its volume knob, and circuitry to allow the Pi to shutdown gracefully when the switch is clicked off. This Python script sets up the proper GPIOs to enable this behavior.

Notifications You must be signed in to change notification settings

Pi2Design/PowerCtl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

PowerCtl

The CSB503HTA includes a power switch on its volume knob, and circuitry to allow the Pi to shutdown gracefully when the switch is clicked off. This Python script sets up the proper GPIOs to enable this behavior. BCM GPIO 22 is used to hold the power on and BCM GPIO 24 is used to sense the power switch. This script has been tested on PI2 running Volumio.

Clone this repository to your home directory and test it by running

sudo python PowerCtl/PowerCtl.py

When the volume knob is turned to the power off position, the Pi should initiate a software shutdown and stay powered until the shutdown is complete.

Some systems may not include the python RPi.GPIO library by default.

To install you can try: sudo apt-get update sudo apt-get install python-dev python-rpi.gpio If that fails then try: sudo apt-get install python-dev python-pip sudo bash pip install RPi.GPIO

Once everything works then edit /etc/rc.local to run the file on boot by adding:

/usr/bin/python /home/YOUR_USERNAME/PowerCtl/PowerCtl.py &

before exit 0. YOUR_USERNAME will be the user into whose home directory the script has been cloned. It may be pi for raspbian, volumio for volumio, or a user name you have added. The ampersand at the end of the line is very important. It allows this script to run in the background. If it is not there, the login prompt may be blocked.

About

The CSB503HTA includes a power switch on its volume knob, and circuitry to allow the Pi to shutdown gracefully when the switch is clicked off. This Python script sets up the proper GPIOs to enable this behavior.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages