Multi Switch Shutdown Script!
-
@orehruoy The source is on github, link is in the 1st post - https://github.com/crcerror/ES-generic-shutdown.
-
@orehruoy You can modify the code of the script of course. But if you just want to glow a LED for power on/off control then use the UART port. A simple solution and no script needed.
-
@cyperghost said in Multi Switch Shutdown Script!:
@orehruoy You can modify the code of the script of course. But if you just want to glow a LED for power on/off control then use the UART port. A simple solution and no script needed.
I didn't know how to access your code in the pi. I will try that other method though seems simple. Thanks.
-
I finally try your script :)
Correct a problem for me because you install the script in/home/pi/Retropie/Scripts/
and this directory is on my USB drive.
I can't have good right to execute.sh
on USB drive with the auto-mount :p
I change to use it in/home/pi/Scripts/
and it's perfect, thanks a lot :)Only one question, when i want to quit RetroArch to ES i must clic 3 time on my reset button ... Is it normal ?
The power off button working fine every time. Using Reset in ES to restart ES is not working for me.
Your PID detection is impressive, it works with emulators and also OpenBOR :p -
@darknior said in Multi Switch Shutdown Script!:
Only one question, when i want to quit RetroArch to ES i must clic 3 time on my reset button ... Is it normal ?
The power off button working fine every time. Using Reset in ES to restart ES is not working for me.
Your PID detection is impressive, it works with emulators and also OpenBOR :pWell the detection of button press is just checked every 1 second. So you might press the button for a longer time.
The PID detection is introduced by runcommand script as entry point ;) And from this point I create PID array.
-
Ok thanks i understand better now :)
Your PID idea is cool and can maybe be used to improve other scripts?
I use this one, where we must make an array to list all the emulators and homebrews to stop music :(https://retropie.org.uk/forum/topic/16458/modified-background-music-script-with-added-overlays
I'm sure we can do it with your idea, or maybe just detect when runcommand launch something and mute the music.
-
@darknior That's is possible, too.
try the parameter
multi_switch.sh --es-emupid
If it returns 0 than there is no emulator called by runcommand. -
Hi there love this script and community I’m trying to implement this to a 12v relay that turns the pi on and off using NO port so it’s ether open or close depending on if the 12v trigger is on or off
Is it possible with the generic trigger in the script?
-
@mrfalk Yes, this should work with generic button script.
So 12V closes the relais and as long your car keeps running the relais stays close. You turn off the vehicle the relais turns to off-state and releases the circuit. -
Cool I was messing around with it yesterday but dident get it to work I’ll try again today after work.
And it’s not a car I’m using it’s a trigger signal from my projector that is normally used to tell screen go down when projector is on and hop when you turn the projector off.
But I guess it works the same.
And yes relay circuit is ether close or open depending in if the projector is on or off so same principle i guessOne question do I only install script and tell which button to use or do I need to mess with python commands?
-
One question do I only install script and tell which button to use or do I need to mess with python commands?
You download the script with wget command or insert the code with nano and make the script executable (chmod +x). By default GPIO3 (=Pin5) is used because this pin is the only one to wake the Raspberry from deep sleep. The shutdown function is independent from GPIOs but as I said only GPIO3 offers full shutdown/repower ability.
The just type./multi_switch.sh --generic
and follow intructions. It's very likely you need to install raspi-gpio withsudo apt install raspi-gpio
before but the script will tell you.Yes please report your progress. But why you want to use a relais? Opto-isolators are much cheaper and easier to use.
https://en.wikipedia.org/wiki/Opto-isolator -
couse im a newbie at the electronic/rasberry/ stuff but learning and relay was only thing i could think of and that i had laying around =)
when i do ./multi_switch.sh --generic nothing happens
im in /RetroPie/scripts & folder and when i type ./multi_switch.sh --generic nothing comes up or happensi do get it to wake up from sleep when i turn projector on and relay goes to close state.
but i doesent shut down when i turn projector off and relay goes to open stateand uhm what do i need to make it executable sorry for my noobishness =/
Edit
nvm found out how to do itEdit 2
but still cant get shutdown to work when the relay opens the circuit and the two pins get seperated (open/not shorted) nothing happensand when i do raspi-gpio set PIN# ip pu i get unknown GPIO PIN# im guessing PIN# is 3 then
-
Finally got it to work after few hours of bug searching
and reason was that I hade (boot to desktop auto login as pi) and change to (boot to text console auto login as pi) and Now everything workes perfectly exectly as I want it to at least hehe thx @cyperghost for all your hard work on this script was exactly what I was looking for and I would have never could have done something like this myself//peace
-
boot to text console auto login as pi
I think it is enough to just write
./multi_switch --generic &
to send the process to background. Then you avoid the second text console ;) -
It works great it boots in to EmulationStation and turns On/Off
But I encounter a problem it randomly starts it self when projector is still off and dont give out signal to relay wich means circut is open
-
@mrfalk Then there is a kind of "backstroke" somewhere. Maybe it's the relay coil itself, or the relais falls back in closed state somewhere.... Really have no idea why this is happening.
-
Yeah going to do some more bug searching I’ll get back if I’ll find what causes it //
-
@cyperghost First of all, thank you for this script. It works great with the RetroFlag SuperPi case. But I do have a feature request...
Would it be possible (and sensible?) to add fan control to this? What I mean is a way to disable the fan if the temperatures are below a certain threshold. If the temperature rises, enable the fan until the Pi has cooled down again.
I know the Kintaru Super Ursus 9000 has something like this. I don't know how they've done it, though. I looked at their installer, which executes two BaSh scripts and installs a DEB package:
- https://www.dropbox.com/s/gmziwqpipzpe38l/kintaroinstaller.sh (this script is executed first, it executes the next script)
- https://packagecloud.io/install/repositories/kintaro/pcb/script.deb.sh (seems to install some pre-requisites for the DEB package)
- last, the package
kintarosnes
is installed
I tried to control the fan via
raspi-gpio
but have not been successful, yet. What I was successful at is reading the CPU and GPU temperature and making the PowerLED switch on and off:#!/bin/bash function measureTemps () { local cpuTempC local gpuTempC # header printf "DATE\t\t\t\tCPU\t\tGPU\n" while [ true ] do if [[ -f "/sys/class/thermal/thermal_zone0/temp" ]] then cpuTempCINT=$(cat /sys/class/thermal/thermal_zone0/temp) cpuTempC="${cpuTempCINT:0:2}.${cpuTempCINT:2:1}" else cpuTempC="n/a" fi if [[ -f "/opt/vc/bin/vcgencmd" ]] then gpuTempC=$(/opt/vc/bin/vcgencmd measure_temp) gpuTempC=${gpuTempC:5:4} else gpuTempC="n/a" fi printf "$(date +%FT%T%:z):\t${cpuTempC}\t\t${gpuTempC}\n" sleep 5 done } measureTemps # RetroFlag SuperPi Case # PowerLED OFF # raspi-gpio set 14 op pn dl # PowerLED ON # raspi-gpio set 14 op pn dh
Is my request even possible? I know the fan is connected to the case's PCB, but so is the PowerLED and that can be controlled!
-
@jandalf81 said in Multi Switch Shutdown Script!:
Would it be possible (and sensible?) to add fan control to this?
Well the best solution would be a PWM fan control but I'm not very familar with such things. There are so much possibilities to control fans the easiest way to do this is due an opto-isolator. Then you add an additional GPIO to just power on/off the fan. This works same like the LED control.
But to add this in the script.... No I don't think so. Because you need additional hardware. But your function could be invoked to the loop and will check button action and output CPU temperature.
Sadly you can't control the fan directly through the case.... so as I wrote. You need always additional hardware and I would stay away to directly use GPIOs as power source. The 3,3V line is only capable of 100mA current. Enough for a few LEDs, microcontrollers ... but near the edge to power a 5V fan (imho)
I know the Kintaru Super Ursus 9000 has something like this. I don't know how they've done it, though. I looked at their installer, which executes two BaSh scripts and installs a DEB package:
Looks like PWM control... take a look here
Here someone did PWM control into NESPi caseIs my request even possible? I know the fan is connected to the case's PCB, but so is the PowerLED and that can be controlled!
After long reading here is the short answer: No!
Because:
The LED is directly connected to GPIO14 so this can be controlled
The fan is directly connected to main power.... Can only be controlled like the complete case -- Power Cut!But:
With additional hardware and some new wiring: Yes! -
Thank you very much for your reply! Although that's not the answer I had hoped for I appreciate your time and effort!
Well, I'll just turn the volume up, then... ;-)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.