[Tutorial] OnOff SHIM exposed - neat Powerswitch from Pimoroni
-
@cyperghost Interesting. Well, I finally picked up a Nespi case, so I am going to start doing mods to it over the next few days to get my mausberry connected. It looks like I have some choices to make.
-
@caver01 Well the Mausberry Switch is also a good choice imho ... the SHIM is just extremly cheap in priece. Good luck with your build and make some photos ;)
-
The SHIM is available again ;)
https://shop.pimoroni.de/products/onoff-shimBut it's now 7 GBP!
-
@cyperghost First of all thks for the Tutorial.
But it doesn't work fine for me ...
-
The
gpio-shutoff
script doesn't run when the Pi turns off ... (I make the script executable withsudo chmod +x /lib/systemd/system-shutdown/gpio-shutoff
command line but it's still not working) -
The
switch.sh
script is not running at the start ... However, I add linesudo /home/pi/RetroPie/scripts/switch.sh &
to/opt/retropie/configs/all/autostart.sh
and to/opt/retropie/configs/autostart.sh
scripts and it's not runnig. But if I usesudo /home/pi/RetroPie/scripts/switch.sh
in the terminal and test the switch, it's working ...
Thanks for helping.
-
-
@necsus I tried this on two builds. On a Raspberry 2 and a
Raspberry 3RPi0, both with Jessie image. The call togpio-shutoff
is hidden and you won't see a message. Can you check your wiring? The LED should blink 3 times but only if you wired it to PIN 1 (3,3V)So what happens if the Pie is shutdown? Can you repower it by pressing the switch button?
It's definitly
/opt/retropie/configs/all/autostart.sh
- thank youIt looks like
sudo /home/pi/RetroPie/scripts/switch.sh & mpg123 -Z /media/usb0/BGM/*.mp3 >/dev/null 2>&1 & emulationstation #auto
So the switch-script must be executed BEFORE emulationstation call!
I wasn't exact in this point - sorry!I've no clue why this does not work in your case ;) Give more information about your system - I think you are on a wrong system as the shutoff script is a rip of the original script from pimoroni.
-
@cyperghost Thks for your quick response !
I have a Raspberry Pi 3 with the Pre-made image RetroPie v4.3.
The modification of the
autostart.sh
script works fine !But when the Pie is shutdown I can't repower it by pressing the button ... The Red Power LED from the Pie and my switch LED (wired on the PIN 1) remain ON ...
I have check my wiring, and it's ok !
But I've find a new problem, in the folder/lib/systemd/system-shutdown/
I have 2 scripts :gpio-shutoff.save
andgpio-shutoff.sh
. I've test to delete withrm
or modify the script but I get the following message error :"Permission denied"
Did I do something wrong ?
-
@necsus use
sudo rm /lib/systemd/system-shutdown/gpio-shutoff.save
and remove the
.sh
file, toothen create the file exactly as I wrote in the tutorial .... WITHOUT .sh just
gpio-shutoff
and make it executable ;) ... that should do the trick. Seems your script wasn't made executable because of the extension. -
@cyperghost Thks for the help, I succeeded to delete the two files, create the
gpio-shutoff
script (I make it executable withsudo chmod +x
;) ).But it's still not working, I think the PCB has a problem. I will test if the script run by putting a LED on the GPIO 17 when the Pie shutoff.
-
@necsus Well... that's weird!
Try to install the official from Pimoroni
type
curl https://get.pimoroni.com/onoffshim | bash
But I really don't know why this is not working for you... see here
But seems you are not alone ... from runeaudio.com - I think I will dig deeper in this!
Hell! There is something going wrong here .... See the official Pimoroni-board - the guy is reporting the same as you! I will make a test on the new Stretch image - keep you updated. That's really strange now! -
@cyperghost It's very strange, because I install Raspbian Stretch Lite Kernel version: 4.9 on my pi zero w, and use
curl https://get.pimoroni.com/onoffshim | bash
command and it works ...
I buy 5 OnOff Shim board at the same time on Pimoroni.
Do you think the OnOff Shim board use on my Rpi 3 has a problem ? -
SOLVED! Proceed with Tutorial as descriped!
-
@cyperghost Ok that's very strange ! And thanks for the explaination.
I will do a test on the Pi3 with Raspbian OS on a new SD card, if it's working.Which OS can I test to help us understanding the problem ?
-
@necsus The RetroPie image is built on top of Raspbian, so you could keep using Raspbian to test things.
-
@mitu Yes that's right! Raspbian would be the first choice.
The reason why I ripped this out of the PIMORONI SHIM service is, that the installer will likely not work on systems like RECALBOX, LibreELEC or OSMC.But the two bash files and the explaination to setup them would likely work. I think I can test just on weekend so I would be glad if someone else could take over.
-
-
For whomever stumbles upon this topic trying to customize the On-Off Shim, please note that not all GPIO PINs are usable for this circuit.
This is an undocumented bug, which is quite important to know if you try to change the default pins on which the board is connected.
In fact, for the "poweroff pin", which is by default on GPIO 4, only GPIO pins from 0 to 8 can be used. If you use pins over 9, the raspberry will never turn on.
This is because the OnOff Shim relies (undocumented) on the "poweroff_pin" being "ON" all the time, since startup.
As documented on https://elinux.org/RPi_BCM2835_GPIOs the pins 0-8 are by default "pulled HIGH", while all the other pins are "pulled LOW".
There is no problem for the other pin "trigger" (or "status" as it is labeled on the circuit), which can be moved to any other GPIO pin.
Personally, I moved them to pins GPIO 6 (physical 31) and GPIO 16 (physical 36) so they do not interfere with any other attached circuit.
It took me a couple of hours to figure this out, I hope this could be of help to someone else.
-
@kzar said in [Tutorial] OnOff SHIM exposed - neat Powerswitch from Pimoroni:
For whomever stumbles upon this topic trying to customize the On-Off Shim, please note that not all GPIO PINs are usable for this circuit.
This is an undocumented bug, which is quite important to know if you try to change the default pins on which the board is connected.
In fact, for the "poweroff pin", which is by default on GPIO 4, only GPIO pins from 0 to 8 can be used. If you use pins over 9, the raspberry will never turn on.
This is because the OnOff Shim relies (undocumented) on the "poweroff_pin" being "ON" all the time, since startup.
As documented on https://elinux.org/RPi_BCM2835_GPIOs the pins 0-8 are by default "pulled HIGH", while all the other pins are "pulled LOW".
There is no problem for the other pin "trigger" (or "status" as it is labeled on the circuit), which can be moved to any other GPIO pin.
Personally, I moved them to pins GPIO 6 (physical 31) and GPIO 16 (physical 36) so they do not interfere with any other attached circuit.
It took me a couple of hours to figure this out, I hope this could be of help to someone else.
Kzar, would you know or quickly be able to see if the very oldest pi (the A, not A+) would be able to work with the on-off shim? The pinout for the 26 Pi looks very similar for pin 1-12, including GPIO4 but I am not an expert and Pimoroni only mentions they are compatible with 40 pin Pis? But from the pinout I do not understand why. Just checking as I have a pi-hole running great on this old Pi, but an on-off button would be amazing.
Many thanks for any thoughts on this.
-
@muze I have the shim running on a 1st generation Pi B 256Mb. Runs flawless even with 26 pin header.
And yes Pihole rules 😋😍
-
@cyperghost Do I need to modify your script if I am using a non momentary button? Right now, I followed your script and instructions press the button in the off position the pi shuts off immediately.
-
@cnoto The script in this posting does not need to be modified it supports both kind of switches
Momentary buttons and latching ones
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.