Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


power off switch / accessing GPIOs
#4
(01-26-2022, 04:48 PM)KHB49 Wrote: did some reading on the internet and did some changes…
-> chmod
-> put the line before exit in rc.local

on startup it says no module gpiozero… when it reads rc.local

pi@moode:~ $ ls -l /home/pi
total 12
drwx------ 2 pi   pi   4096 Dec 29 18:57 Downloads
-rwxr-xr-x 1 root root 1546 Jun 12  2019 piano.sh
-rwxr-xr-x 1 root root  117 Dec 29 19:24 shutdown-press-simple.py

pi@moode:~ $ cat /home/pi/shutdown-press-simple.py
#!/usr/bin/env python3
from gpiozero import Button
import os
Button(26).wait_for_press()
os.system("sudo poweroff")

pi@moode:~ $ cat /etc/rc.local
#!/bin/sh -e

SQLDB=/var/local/www/db/moode-sqlite3.db

# set cpu govenor
RESULT=$(sqlite3 $SQLDB "select value from cfg_system where param='cpugov'")
echo "$RESULT" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

/usr/bin/udisks-glue > /dev/null 2>&1
/var/www/command/worker.php > /dev/null 2>&1
/home/pi/shutdown-press-simple.py &

exit 0
Reply


Messages In This Thread
power off switch / accessing GPIOs - by KHB49 - 01-26-2022, 01:12 PM
RE: power off switch / accessing GPIOs - by KHB49 - 01-26-2022, 04:48 PM
RE: power off switch / accessing GPIOs - by KHB49 - 01-26-2022, 06:30 PM
RE: power off switch / accessing GPIOs - by KHB49 - 01-26-2022, 06:57 PM
RE: power off switch / accessing GPIOs - by KHB49 - 01-26-2022, 07:35 PM
RE: power off switch / accessing GPIOs - by KHB49 - 01-27-2022, 02:40 PM

Forum Jump: