Power Switch Part 3 - WyrmTech

Go to content

Power Switch Part 3

Pi Bits > Power Switch
The Software

As is stated on the github page: Remember to install the code before connecting the switch to the Raspberry Pi.

I'm just going to reiterate the GPIO pins used in the Volumio Player build (as much for my own memory as anything else).

Use
GPIO
Physical Pin
Comment
NanoSoundGPIO0203OLED Display D1
NanoSound
GPIO0305OLED Display D0
NanoSoundGPIO0407NanoSound Power Switch Off Trigger - Not Used
NanoSound
GPIO09
21NanoSound Input Button 4 - VOL -
NanoSound
GPIO10
19
NanoSound Input Button 1 - VOL +
NanoSound
GPIO11
23
NanoSound Input Button 5 - SKIP -
NanoSound
GPIO12
32
NanoSound Input Button 2 - SKIP +
NanoSound
GPIO13
33
NanoSound Input Button 6 - Play / Pause
NanoSoundGPIO1408
NanoSound Power Switch Detection of power - Not Used
NanoSound
GPIO1636
NanoSound Input Button 3 - Not Used
Speaker BonnetGPIO1812DAC BCLK
Speaker Bonnet
GPIO1935DAC LRCLK
Speaker Bonnet
GPIO2140DAC DIN
Power BoardGPIO2316Soft Off switch Input to Power Board J4
Power BoardGPIO24183.3V Power out to Power Board J3

Go to the following link https://github.com/PiSupply/Pi-Supply-Switch and follow the installation instructions.

Once installed the RasPi will shutdown. Remove power and jumper pin 7 to pin 9, this will trick the script into behaving as though the Power Switch is connected, then power back up.

I then edited the file /opt/piswitch/softshut.py ( sudo nano /opt/piswitch/softshut.py ) and changed the pins from
PinSeven = 7
PinEight = 11
to
PinSeven = 16
PinEight = 18

GPIO.setup(PinSeven, GPIO.IN)                     # Set up PinSeven as an input
GPIO.setup(PinEight, GPIO.OUT, initial=1)  # Set up PinEight as an output

This means that pin J3 from the Pi Switch goes to pin 18 (GPIO23) on the RasPi and that pin J4 from the Pi Switch goes to pin 16 (GPIO24) on the RasPi.

You can then shutdown the RasPi and connect up the power switch.

Using the switch

  • Press the On button to power on the Raspberry Pi.
  • Press the Off button to remove power to the Raspberry Pi. This is not a graceful shutdown!
  • Press briefly the Soft button to gracefully shutdown the operating system. After 2 minutes the power is also cut off.
  • Press the Soft button and keep pressed for a reboot.
  • Also selecting shutdown from the desktop or doing a shutdown from a terminal session will act in the same way as the Soft off button and remove power after 2 minutes.

Obviously the same trick of jumpering pin 16 to GND will work if you need to run without the switch and don't want to uninstall the software.
Visitor Number:
Back to content