Git Product home page Git Product logo

raspberry-pi-safe-off-switch's People

Contributors

tonylhansen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raspberry-pi-safe-off-switch's Issues

shutdown-led-simple.py kills wifi

On a Zero W running Buster I could get this working but it killed my wifi.
Changing the rc.local line of "~pi/shutdown-led-simple.py" to "python /home/pi/shutdown-led-simple.py &" is what it took to get it working again.

Article links to your repo and provides incorrect instructions

I know this is not directly related to your code. Your repo works brilliantly and I have it running on my pi, thank you. However, I initially followed this article by Christian Crawley (2019) which gives the following incorrect instructions:

To ensure this works following a reboot, append /etc/rc.local:
sudo nano /etc/rc.local
In the final line before the exit statement, add:
echo '~pi/shutdown-press-simple.py'
Save and exit as before, then try the button out.

As your repo correctly details, a line should be added to /etc/rc.local before the exit 0 line and this line should be:
~pi/shutdown-press-simple.py &

Non-ASCII character

In the progressive blinking sample, there are some character not recognized as ASCII (½ and ¼) that gives the following error
SyntaxError: Non-ASCII character '\xc2' in file test.py on line 17, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

I would write just "a half second" and "one fourth".

Off and back On with Toggle switch help.

Hi @TonyLHansen, using one of your scripts I was able to turn off my Pi 5 in an Arcade cabinet using a toggle switch across pins 5 and 6 but as yet I cannot figure out how to turn it back ok using the same switch (In the opposite direction).

Would you know if this is even possible please?

I realise the Pi 5 now has a power button but as I am moving from a Pi 4 all the hardware is already in place and I was hoping to be able to migrate from the working RPi.GPIO to gpiozero but so far not got it working.

Many thanks.

rc.local

"
Then add a line to the end of /etc/rc.local to run it at boot time:

$ sudo su

echo '~pi/shutdown-press-simple.py' >> /etc/rc.local

"

I think in the rc.local there should be something like this:

python3 /home/pi/shutdown-press-simple.py &

Because:

  • it is python;
  • and you must fork the command with "&" because rc.local can't exit ever with "0"

shutdown-press-simple.py not working

I have installed according to instructions, but the Raspberry does not shut down after pressing the button.

Tried to shorten the button pins. No reaction.

shutdown-press-simple.py
Raspberry Pi 3+
2022-09-22-raspios-bullseye-armhf-lite

~ $ ls -l
total 4
-rwxr-xr-x 1 root root 121 Jan 28 11:15 shutdown-press-simple.py

pi@aqua:~ $ python shutdown-press-simple.py
Failed to set wall message, ignoring: Interactive authentication required.
Failed to power off system via logind: Interactive authentication required.
Failed to open initctl fifo: Permission denied
Failed to talk to init daemon.

What could it be?...

sudo python shutdown-press-simple.py

... did the "trick". - Which tells us it is a permissions problem. Must have created the file with sudo in front.

Just changing to create the script without sudo first, did not solve the problem entirely.

Here what works (for me):

´´´
pi@aqua:~ $ ls -l
total 4
-rwxr-xr-x 1 pi pi 124 Jan 28 13:30 shutdown-press-simple.py
´´´

And for me it needs to have "sudo shotdown now" as command for shutting down.

´´´
#!/usr/bin/env python3

from gpiozero import Button

import os

Button(21).wait_for_press()

os.system("sudo shutdown now")

´´´

Segmentation Fault Error

Hi, I am trying to use your program on ubuntu mate 18.04 with a raspberry pi 3 b. I got the program installed, and when I run the program, and press the button, it says segmentation fault. I am not sure how to fix this. Thanks!

read.me gpizero package

The read.me sould be updated with:
sudo apt install python3-gpiozero
beacuse "headless" image does not contain this package by default.

Clarify rc.local editing

I know that this tripped me up, and searching around the internet shows I'm not the only one.
The section on editing rc.local is giving terminal commands. NOT the lines that we should be adding to rc.local.

I entered these 2 lines into rc.local and it did not go well.
$ sudo su

echo '~pi/shutdown-press-simple.py' >> /etc/rc.local

does it work on pi3b?

Tony,

I've downloaded all of your shutdown scripts and none of them work on a pi3b running raspbian jessi.
Have you been able to get this to work? when I try to run I ge tthe following output:

/shutdown-led-simple.py
Traceback (most recent call last):
File "./shutdown-led-simple.py", line 22, in
btn = Button(offGPIO, hold_time=holdTime)
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in call
self = super(GPIOMeta, cls).call(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 292, in init
pin, pull_up, bounce_time, pin_factory=pin_factory
File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 338, in init
super(HoldMixin, self).init(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 95, in init
self.pin.when_changed = self._fire_events
File "/usr/lib/python3/dist-packages/gpiozero/pins/init.py", line 388, in
lambda self, value: self._set_when_changed(value),
File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 289, in _set_when_changed
self._enable_event_detect()
File "/usr/lib/python3/dist-packages/gpiozero/pins/rpigpio.py", line 219, in _enable_event_detect
bouncetime=self._bounce)
RuntimeError: Failed to add edge detection

thanks

Reboot/shutdown

Hello! Great information thank you! I wrote my script to look at PIN 3 and my button properly "shutsdown" but reboots the system. I'm hoping to use my button like an on/off where a second button press brings the Pi back to life. Is this possible?

Thanks in advance for your help.

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.