GithubHelp home page GithubHelp logo

johnpeart / raspberrypi-safeshutdown Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 7 KB

A script for initiating a safe shutdown on a Raspberry Pi when a button, attached to GPIO pins, is pressed.

Python 100.00%
raspberry-pi raspberrypi gpio gpiozero

raspberrypi-safeshutdown's Introduction

raspberrypi-safeshutdown

A script for initiating a safe shutdown on a Raspberry Pi when a button, attached to GPIO pins, is pressed.

Installing the script

  1. Get the git repository:
    git clone https://github.com/johnpeart/raspberrypi-safeshutdown
  2. Change the permissions as the super-user such that you can execute the files:
    sudo chmod 777 /home/pi/raspberrypi-safeshutdown
  3. Open rc.local in the text editor as the super-user:
    sudo nano /etc/rc.local
  4. Add the following command before the exit 0 at the end of rc.local:
    sudo python /home/pi/raspberrypi-safeshutdown/safe-shutdown.py &
  5. Reboot the Raspberry Pi:
    sudo reboot

NOTE: It is very important that you add the code in step 4 before the exit 0. If you don't, you'll cause terminal havoc.

Adding the hardware button

You will need an "Normally Open" ("NO") switch and some wire. You should:

  1. attach a wire to each of the terminals on the button
  2. attach the other ends of the wire to GPIO 3 and a GND pin (e.g. physical pins 5 and 6)

The benefit of using GPIO 3 is that it will also power on the Raspberry Pi when shorted to a GND pin.

Acknowledgments

Based on tutorial from Core Electronics

raspberrypi-safeshutdown's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.