Power off button on RPI2

Discuss about Hardware diy and tweaks

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.

Power off button on RPI2

Postby francescoUK » Sun Feb 12 2017 11:24

Hi all,

it might sound a simple and silly question, but does anybody have a solution to power off a RPI2 running volumio with a simple button that is not the main power switch one?

A lot of times the web ui gets shut down before even thinking to use the shut down button, so you are left with a running volumio that you would just want to switch off with a button.
Random avatar
francescoUK
Fresh off the boat
Fresh off the boat
 
Posts: 8
Joined: Sun Feb 12 2017 11:05

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.


Power off button on RPI2

Postby macmpi » Fri Feb 24 2017 07:43

You can do that with GPIO pins and GPIO Buttons plugin.
For instance, if your setup does not use GPIO 3 (pin #5), you can wire a push button (not a ON/OFF switch!) between pins 5 and 6 (GND) and use Shutdown action with GPIO Buttons. Good thing is that the same button will also power-up the device (benefit of using GPIO 3).
Last edited by macmpi on Sat Dec 09 2017 09:17, edited 1 time in total.
New User? Welcome! Please allow 8mn for first boot, and while the wait, be sure to carefully read Quick-start instructions and FAQ ;)
Question? please use search form first, and if posting for a problem, submit logs.
User avatar
macmpi
Objectivist
Objectivist
 
Posts: 397
Joined: Tue Jan 12 2016 11:19


Power off button on RPI2

Postby calvin » Tue Feb 28 2017 12:38

I am using a Pi 3 and a HiFiberry DAC+. Does anyone know if I can use GPIO 3, as described above. I currently am using the plug-in but have the power-down switch connected to another GPIO. It would be nice to be able to take advantage of the power-up feature offered by GPIO 3 as well as the power-down.

Per the WiFiberry website "GPIO2-3 (pins 3 and 5) are used by our products for configuration. If you are experienced with I2C, you might add other slave devices. If you are a novice, we don’t recommend this at all."
Random avatar
calvin
Sunday DIYer
Sunday DIYer
 
Posts: 34
Joined: Sat Nov 26 2016 16:02


Power off button on RPI2

Postby macmpi » Thu Mar 02 2017 12:34

calvin wrote:Per the WiFiberry website "GPIO2-3 (pins 3 and 5) are used by our products for configuration.
i2c uses GPIO3/2 (clock & data). My take on this is: at boot certain software may use i2c to detect and configure boards (automated devicetree detection thanks to EEPROM read for instance), but that's at a time where, if you connect a push-button, that part of the wire will be "up in the air", and not shorted to GND by the button. So I do not anticipate this may cause any trouble (but I take no responsibility if it does of course).

Volumio does have it's own (more complex) DAC auto-detect procedure which does use i2c too, and interaction with such use of GPIO3 is discussed here.
The discussed case is different: unwanted error messages happen when no HAT are connected to the Pi. I do not think the same (non-critical) thing will happen in your case because HifiBerry board does connect GPIO3 (hence no clock stretching phenomena).
In any case, should auto-detections even fail, you may set audio-out device with UI and save config, so it should not adversely impact your setup I guess.

Your call, but if you decide to try, thanks for posting your feedback.
New User? Welcome! Please allow 8mn for first boot, and while the wait, be sure to carefully read Quick-start instructions and FAQ ;)
Question? please use search form first, and if posting for a problem, submit logs.
User avatar
macmpi
Objectivist
Objectivist
 
Posts: 397
Joined: Tue Jan 12 2016 11:19


Power off button on RPI2

Postby calvin » Thu Mar 02 2017 18:25

Well I tried it but unfortunately I could not get any sound out of the DAC so I guess it's a no-go. Maybe there are some other things that could be done to get it to work but I'm a programming idiot. It did turn the unit on and off but seemed to take the DAC out of the equation.

I do appreciate you taking the time to respond to my question.
Random avatar
calvin
Sunday DIYer
Sunday DIYer
 
Posts: 34
Joined: Sat Nov 26 2016 16:02


Power off button on RPI2

Postby macmpi » Thu Mar 02 2017 22:49

Just a question: did you manually set and saved the Audio preference on your DAC settings (even if they are shown correct)?

Well..and another one: are you using a real push-button that does not stay in "pushed" position?
New User? Welcome! Please allow 8mn for first boot, and while the wait, be sure to carefully read Quick-start instructions and FAQ ;)
Question? please use search form first, and if posting for a problem, submit logs.
User avatar
macmpi
Objectivist
Objectivist
 
Posts: 397
Joined: Tue Jan 12 2016 11:19


Power off button on RPI2

Postby calvin » Fri Mar 03 2017 10:33

Based on your response I revisited the situation. For several months I have been successfully using the plugin with the shutdown feature using GPIO 26. I then had to physically disconnect the power supply before I could restart. For this test I started up normally to ensure everything was working normally. I then changed the shutdown GPIO setting to GPIO 3 in the plugin and saved. Everything was playing normally. Based on your comment I went to the DAC settings which were displayed as expected and did a manual save which immediately killed the music. The GUI still showed that things were going normally (music was advancing, volume control worked in the GUI but no sound from the speakers). I then wired in the button to GPIO 3 and using it I initiated a shutdown; which, based on the flashing lights on the PI 3 generated a controlled shutdown and the GUI went to a state that would indicate that the unit was off. The green light on the DAC which normally would go out remained lit. I then pressed the button and, based on the flashing lights on the PI 3 generated a start up and in fact the GUI was reactivated but there was no sound. Going through all the settings everything appeared normal but there was no sound. When I reverted the system back to using GPIO 26 everything returned to normal. It appears that there is a conflict between the plugin and the DAC when using GPIO 3 in this configuration.

I am using a momentary contact push button.

As a FYI a question about this scenario was asked in the HiFiBerry forums back in November but never elicited a response. I was hoping somebody here might have successfully tried it.

Thanks again for your time.
Random avatar
calvin
Sunday DIYer
Sunday DIYer
 
Posts: 34
Joined: Sat Nov 26 2016 16:02


Power off button on RPI2

Postby macmpi » Fri Mar 03 2017 14:08

Any chance you could hook a HDMI display to the Pi to check if any error message kicks-in (and check shutdown/restart are real: the leds thing should be the same whatever GPIO used)?
Better: could you get a log file through SSH, with sudo journalctl > /tmp/logfile.txt and then download it with a SFTP client?

Could be that I2c auto detection plugin has not finished its work before GPIO_Buttons plugin kicks-in, and then registered interrupt function alters proper board config: that's one problem mentioned in the opened Github issue.
Log messages may help understanding.
New User? Welcome! Please allow 8mn for first boot, and while the wait, be sure to carefully read Quick-start instructions and FAQ ;)
Question? please use search form first, and if posting for a problem, submit logs.
User avatar
macmpi
Objectivist
Objectivist
 
Posts: 397
Joined: Tue Jan 12 2016 11:19


Power off button on RPI2

Postby macmpi » Sat Mar 04 2017 08:24

HifiBerry confirmed i2c communication happens at any time on DAC+, so GPIO3 can not be used for shutdown for this product (but should be OK for DAC+ Light for instance).

I may have another option to propose, based on this.
The idea is to use 2 different pins for ON and OFF, but with one single physical button.
ON stays on GPIO3, but OFF detection (the one that GPIO Button handles & "blocks") is then moved to another GPIO (GPIO 27 in the schematic for instance), hence freeing GPIO3 for normal i2c communication when needed (i.e; Hifiberry configuration).
From user's perspective it's only one button.

Wiring could be simpler, I think, in particular if one finds a dual push button (DPST-NO Momentary) with 2 separated entries in parallel: GPIO3 & GPIO27 on one side, GND for both on the other side.
Last edited by macmpi on Sun Mar 05 2017 08:57, edited 1 time in total.
New User? Welcome! Please allow 8mn for first boot, and while the wait, be sure to carefully read Quick-start instructions and FAQ ;)
Question? please use search form first, and if posting for a problem, submit logs.
User avatar
macmpi
Objectivist
Objectivist
 
Posts: 397
Joined: Tue Jan 12 2016 11:19


Power off button on RPI2

Postby calvin » Sat Mar 04 2017 12:48

I was just getting ready to try to get the info you requested when I saw your post. I've been sidetracked fighting another issue this morning. I updated from 2.014 to 2.114 to see if that had any affect on the issue and now I'm getting random pause in my playback which I guess other people are having similar problems with. Missed that post on the HiFiberry forums, glad you found it as it definitively answers the question. The post I found was never answered.

Your proposed solution sounds promising. I'm not sure I have the required switch handy, but I'll scrounge around in my junk drawer and see if I can find something that will work.

Thanks again for all your help ..... now if I can figure out how to use an i2C LCD display with Volumio ver 2.xxx I will be close to being able to put together my project (previous attempts seem to be using Volumio ver 1.55)
Random avatar
calvin
Sunday DIYer
Sunday DIYer
 
Posts: 34
Joined: Sat Nov 26 2016 16:02

Next

Return to Diy and Tweaks

Who is online

Users browsing this forum: No registered users and 0 guests