PiSupply / Pi-Supply-Switch

Pi Supply Switch On/Off Switch for Raspberry Pi
https://www.pi-supply.com/product/pi-supply-raspberry-pi-power-switch/
Other
58 stars 17 forks source link

power off after two minutes #22

Open naturenergy opened 2 years ago

naturenergy commented 2 years ago

Hello!

I have an issue where the Pi (Arm 6 Model A rev2) using Dietpi 8.02 OS which I understand is based on Bullseye Debian.

Switch LED doesn't light up when Pi fully booted, then powers off after about 2 minutes (sudden off no gentle shutdown - so risk of card corruption).

I installed the code and switch as per instructions and it has worked fine previously on raspberry OS lite (headless)

Keen to use DietPi however, and like its functionality.

I used the default pins 7 and 11, and tried again changing to pins 11,15 (editing the script) same result. Also tried changing the power lead and have a good 2A supply which is ample for model A.

Ran the service status diagnostic (with switch attached) :-

● piswitch.service - Starts softshut for Pi Switch Loaded: loaded (/etc/systemd/system/piswitch.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2022-01-23 09:32:20 GMT; 3min 34s ago Process: 182 ExecStart=/opt/piswitch/softshut.py (code=exited, status=127) Main PID: 182 (code=exited, status=127) CPU: 33ms

Jan 23 09:32:19 RPi1PV systemd[1]: Started Starts softshut for Pi Switch. Jan 23 09:32:20 RPi1PV softshut.py[182]: /usr/bin/env: ‘python’: No such file or directory Jan 23 09:32:20 RPi1PV systemd[1]: piswitch.service: Main process exited, code=exited, status=127/n/a Jan 23 09:32:20 RPi1PV systemd[1]: piswitch.service: Failed with result 'exit-code'.

Then I tested it without the switch and the OS remains stable and on for a long time.

Looking at above - perhaps python hasn't been installed correctly by default in Dietpi? Any ideas? Thanks!

tvoverbeek commented 2 years ago

I have no experience with DietPi, but from your status output it is obvious that the 'python' command is not defined. In a terminal window (with switch not attached) try to run the command python which will most likely fail. I guess only python3 is installed. To check this, try to run the command python3 in the terminal window. If that works change the first line in softshut.py to /usr/bin/env python3. If that does not work you will have to install python (preferably python3, since python2 is not maintained any more).