Pimoroni onoff shim Pi2 or only pi3? also bash how to use

Hi brains trust.
I have put together the shim and fitted it to my RPi2 running Openelec kodi type software. First question is it compatible with Raspberry Pi2 as well as the 3 series?

Second and probably more important is how to run the small bit of script, as a total newbie to anything to do with codes I dont think I am doing it correctly.
I have opened a terminial using Putty via SSH to the Pi , easy enough and i have cut and pasted the code
curl https://get.pimoroni.com/onoffshim | bash
into it via SSH and got a few error messages, so I dont know if there is a special way to put the ‘bash’ command in , ie do I leave it as is and get the error messages or do i use different spaces or / or \ or what thats where i get stumped.

Anyway it sort of works. It will power the Pi up once!
It will not power it down, and it will not subsequently repower it up I have to disconnect power and then reconnect it and then push button to power it up.
Hope that all makes sense.

Hi Ross,

Could you provide us with what the error messages are as this may help us point you to a solution.

Hi clinton I think I have worked through part of it. Openelec is read only so I cant write anything to it. I dont know if tha would change if I could put the file in config.txt file???
Anyway I have installed it on my other RPI3 using the volumio music server program and it install ok.
However it will once again only start the pi not shut it down. I have gone to this site. https://github.com/pimoroni/clean-shutdown
and run this one first and allocated pins 17 and 4 respectively and then run the shim package, it will start the pi 3 just not switch it off defeating the whole purpose of it.thanks

I suspect that you may be having a permission issue if you try running the
sudo curl https://get.pimoroni.com/onoffshim | bash
You may have more success.

Thanks I tried that first no luck. It turns on but not off but I can switch it off via the volumio program which is a compromise that I will have to work with. Can I ask another question on a different subject here or would you prefer i started another topic?

ok I will put it here as it is related to the shim. I use an i2c enabled LCD screen with my pi and it works fine but now that the shim is on the board those i2c pins are covered. Are there other pins I can use for i2c or do you think that I can solder my screen wires to the top of the shim to get that to work too? thanks for listening to me about the original question I am near retirement and all this code stuff annoys me. cheers

hey it works it needed a reboot again and it switches on and off thanks

1 Like

There is a reason turning it off and back on again is always the IT slogan :). Don’t worry too much code annoys even those of us that love it. There is a second I2C channel on the Pi that you can use SparkFun have a guide on how to use it.

Well I tried to piggie back off the shim to use the SDA and SCL of the i2c because as far as I could work out they were not necessary for the shim to work, but the LCD was not getting any data through so what I am in the process of doing now is the reinstall the whole shebang and then only use the basic script for the shim to see if that ‘shutdown’ part I tried was interfering with it.

And it looks like it was, now it boots and shuts down from external LED momentary switch which yay lights up as long as it has power. and the LCD works as it should. thanks for your help.

Now the next thing I use a little program call pydpiper to get song info from the NAS and display it on the screen, it is housed in a ‘docker’ anyway after a few minutes the screen is corrupted as a second version of the docker starts and upsets everything. However if I log in via SSH and send the command ‘sudo systemctl restart docker’ it works till next time the whole thing is restarted. The author admits there is an issue and until he gets around to updating things that may not change. I was wondering if there is a simple way to put that reboot script somewhere so that it will auto run after say a minute or two delay after startup? If so I would need someone who knows their way around code, hint hint, to write down the steps for me. I have 2 machines using this music program and it works fine except the authors I think get bored and move on to fancier things.

So is such a thing possible as I have asked on the volumio forums if someone knows how to do this and it has been viewed by literally several hundred people but no one answers.
Please let me know what you think about restarting dockers.

Hi Ross,

There is a tool built into the Raspberry Pi OS call cron that may let you do what you want, You can schedule tasks to start and stop at set intervals.

Thanks i will have a look at that, I wonder if it works inside programs too like volumio or pydpiper i will investigate. thanks for the input today now to listen to some music and open a red.

If the script needs to be run on startup/shutdown, then the correct place to put it is in the /etc/rc structure.

Check /etc/rc.local and /etc/rc.d (directory)

man is your friend.

Hi Robin not exactly sure what you mean, but what it needs to do is to be delayed till the program starts and then 1-2 minutes later reboot the docker. The Cron link is not quite what I need as it wants to do things on a regular basis, like every 30 minutes not just once after a set time. Man might be your friend but he can confuse when he knows the jargon and I dont. thanks

Programs to run on startup / shutdown normally reside in /etc/rc?.d/ or in the script file /etc/rc.local The “?” is a number from 0 to 6.

“man” is the *nix command to interrogate manual pages, the documentation on commands, files, functions and other things of interest.

E.g. man rc.local will tell you about the rc.local file, usually containing a “see also” section.

Ok so I have a different question. I have attached a rotary encoder to my rpi3b and it controls volume, what I want to know is how to wire the button switch so it does something. What does it do? I have it set in the UI via plugin to shutdown the pi with a long press but it doesn’t work. I have tried to set it up visaThanks

Hi Ross,

Could you please provide more information about the setup? What is the exact encoder, how have you tried to connect it, and what is the plugin that you are using?

Hi Stephen
Thanks for replying, I have a rotary encoder with breakout board attached like this one.

and using this plugin to dedicate certain pins to certain tasks. The rotary volume control works fine, that was straight forward, however I was under the belief that I could use GPIO pins to initiate another action to occur either a shutdown via long press or pause/play action etc. On my RPI3, it may not be possible or maybe I have to use different pins. what can you tell me about these devices, most websites use them just for volume, nothing else. pity.

I don’t know if you have changed the configuration from the default, but the shutdown on long press is configured on the 2nd rotary encoder. It does say it is a dual rotary encoder plugin.

That is also available as a dropdown option on the first encoder

1 Like

Go back to basics and eliminate the hardware as far as possible. I.e. just use a jumper lead to simulate the switch on the encoder. Attach one end to the appropriate gpio pin, and then short to ground/vcc as required.

This should tell you if it is hardware or software and then you know where to concentrate your efforts