Nav

How to make a power switch for the Raspberry Pi

Learn how to create a power switch for the Raspberry Pi

To turn the Raspberry Pi on and off, you first need to log in or SSH into the Pi. A benefit of the Pi Cap, however, is that it includes an on/off button which works as a power switch for the Raspberry Pi. All you need to do is edit a file and include one of our example codes. For this tutorial, we SSH into the Pi to set up the power switch, but if you don’t want to use SSH and the terminal, you can also use a monitor, keyboard and mouse connected to your Raspberry Pi.

Find out how to use the LED on the Pi Cap

How to use the LED on the Pi Cap

Learn how to the run Pi Cap script at start-up

How to run Pi Cap script at start-up

Learn how to use Raspberry Pi projection mapping to turn a simple graphic into an augmented reality super-wall, activated by touch

Raspberry Pi Projection Mapping using a Pi Cap

Step 1

Set-up the Pi Cap

If you haven’t set up your Pi Cap then make sure to complete one of our set up tutorials first:

Setting up your Pi Cap on the Raspberry Pi 1, 2 or 3

Setting up your Pi Cap on the Raspberry Pi Zero

Links

Step 2

Edit a file

Once you have SSH’d into the Pi, enter “sudo nano /etc/rc.local” into the Terminal window and hit enter. At the bottom of the file, add “bash /home/pi/PiCapExamples/cpp/picap-button-utility-cpp/run &” in-between “fi” and “exit 0”. If you now press CTRL + X, then Y, then enter, it will save the recent edits in the file.

Links

Step 3

Restart the Pi

If you now reboot the Pi with “sync && sudo reboot”, the Pi will launch with the power switch in place. If you double press the switch, it will reboot the Pi, if you press and hold the switch down it will turn the Pi off.

We’d love to see your creations! Feel free to send us an email at info@bareconductive or contact us via Instagram or Twitter.

Links
power switch for the Raspberry Pi using the Pi Cap

Suggested Tutorials

Find out how to use the LED on the Pi Cap

How to use the LED on the Pi Cap

Learn how to the run Pi Cap script at start-up

How to run Pi Cap script at start-up

Learn how to use Raspberry Pi projection mapping to turn a simple graphic into an augmented reality super-wall, activated by touch

Raspberry Pi Projection Mapping using a Pi Cap

Categories

Bare Conductive

Instructions

Pi Cap

Date Posted

2018/09/13

Rating

0.00 avg. rating (0% score) - 0 votes