Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Power button and relay
#1
Hi

I've Moode Audio running on a Raspberry Pi 3 B with a HifiBerry DAC+ Pro

To turn off properly the Pi, I have to use the shutdown menu on Moode Audio web interface

I want to wire a "off" button to the Pi in the GPIO pins, and also, I need the Pi send a pulse or a level to tells an external circuit that's it's OK to disconnect supply from 230V (with a relay)

So, when user push the "off" button, the Pi will shut down and then disconnect from 230V.

(To turn "on" again, the user should switch on the relay to connect power supply - I know how to do that)

Is it possible with Moode Audio ?

Also, I have to select GPIO pins not already used by HifiBerry DAC+ Pro

I find it strange that Raspberry Pi don't give this feature, it's an electronic device without on/off switch

Regards
Reply
#2
(03-21-2021, 08:15 PM)electroremy Wrote: Hi

I've Moode Audio running on a Raspberry Pi 3 B with a HifiBerry DAC+ Pro

To turn off properly the Pi, I have to use the shutdown menu on Moode Audio web interface

I want to wire a "off" button to the Pi in the GPIO pins, and also, I need the Pi send a pulse or a level to tells an external circuit that's it's OK to disconnect supply from 230V (with a relay)

So, when user push the "off" button, the Pi will shut down and then disconnect from 230V.

(To turn "on" again, the user should switch on the relay to connect power supply - I know how to do that)

Is it possible with Moode Audio ?

Also, I have to select GPIO pins not already used by HifiBerry DAC+ Pro

I find it strange that Raspberry Pi don't give this feature, it's an electronic device without on/off switch

Regards

The standard Raspberry overlays provides both functions. Requires manual editing of config.txt in the boot partition.
Reply
#3
Wink 
Hi,

I can do the first part (wire a "off" push button)  Smile

Here is a GPIO map - We can use pins that are not marked with a red dot :

[Image: rpi_hiffiberrydac_gpio.jpg]
Please mind that other Hifi DAC can use differents GPIO pins !

Then, turn Raspberry Pi ON

Connect to the PI with SSH :
- Run PuTTY on your computer
- login "pi"
- password "moodeaudio"

Then, open and edit /boot/config.txt (https://www.makeuseof.com/tag/edit-boot-...pberry-pi/)
- enter "cd /"
- enter "ls"
- enter "cd /boot"
- enter "sudo nano config.txt"
- add a line "dtoverlay=gpio_shutdown,gpio_pin=23"
(I use GPIO 23 that is pin 16 to connect my "off" push button)
NB: verr num key may not work... so that to type numbers and "-" use keys on top of QWERTY
- enter CTRL+X to save
- enter "exit" to close PuTTY

Then shut down the PI with the shutdown menu of the Moode Audio web interface

Thus, you can plug the "off" push button between the pin 16 and ground

When I turn on again the PI, the push button makes the PI shutdown properly
It works also when Moode Audio is playing music.

The first part is done  Smile

I have to do the next part : find or generate an electronic signal to said PI is ready to power down - I don't know how to do that...  Blush

Regards
Reply
#4
Hi,

I find the solution

You juste have to add an other line in the setup.txt file as explained before :

"dtoverlay=gpio-poweroff,gpiopin=25"

Here, I choose the GPIO 25 (connected to pin 22)

Thus, the RPI boot with GPIO 25 set to 0V state
An when shutdown is finished, GPIO 25 is set to 3,3V state

You can connect GPIO 25 to a NPN transistor base with a 10K resistor, to drive a bistable relay reset coil to cut power supply

So to manage power, don't use complex power hat with add-on software
Just add two lines in setup.txt and use a few simple electronic components.

[Image: rpi_hiffiberrydac_configtxt.jpg]

[Image: rpi_hiffiberrydac_gpio.jpg]
Regards
Reply
#5
Hi everybody

I notice that the GPIO "poweroff" pin behavior is a little bit more complex

This is the diagram of my wiring, it's works fine ("BP" are push buttons)

[Image: rpi_on_off_circuit.jpg]

Hope that can helps other people

Regards
Reply
#6
Great solution! moOde icw with Pi is a great platform to tinker with  Big Grin.

I use a little variation on this theme; Raspberry Soft Power off  in combination with small pcb with a Solid State relay Hereby an led also indicates if the Pi is booting, is booted or is shutting down.
Reply
#7
Hi,

Maybe this is not helping a lot, as you seem to want to build your device from scratch (which is perfectly fine), but being a bit of a debutant in the raspberry pi world, and wanting a robust solution for daily use at home, I went for completely built power management HAT; Here is what I tried:

I first used the MSL Digital RemotePi board, which offered also IR remote support for on/off, as well as a pushbutton, and passed lirc commands to the rbp4.
That one worked ok with Moode and a HiFiBerry DAC2 HD.
But something was conflicting or undervoltaged when I added the DSP add-on board (rbpi never booted when I stacked everything, ethernet leds blinking very fast and impossible to ssh on the rbpi).

So I searched and went for the WittyPi3 board, which offers RTC as well as a power pushbutton, but offers also complex ON/OFF schedule rules. This one works perfectly with Moode and the HifiBerry DAC2 HD and DSP add-on. Now I have everything set up and the rbp4 is booting alone at 7AM and shuts down at 23PM everyday (I didn't experiment more complex schedule, but one could have this during five working days, then different for weekends, and even have a week different than the next one, the schedule script is quite robust for this).

On another setup used for osmc, I use an Argon On Fan Hat in combination with an X-862 for Sata SSD and a HiFiBerry DAC+ DSP. This Fan HAT also has a power pushbutton, aswell as a fan that one can set up the speeds / t° curve or configuration. Very handy too, but this one just manage to initiate a soft shutdown, a reboot and a boot up, but does not completely cuts power (PWR red led constantly on after power off).

Hope that this can help you, or someone seeking such solution and have no clue, at least this is my feedback :-)

All the best,

Greg
Reply
#8
Quote: Very handy too, but this one just manage to initiate a soft shutdown, a reboot and a boot up, but does not completely cuts power (PWR red led constantly on after power off).

Greg.....If you then hold the power button down for the count of three  or more on the rear of the Argon-One case the power is cut completely and the Led is no longer lit.
----------
bob
Reply
#9
Hi Drone7,

Thanks for the advice. I'll try this.
But I don't have the Argon-one case, just the fan HAT (https://www.argon40.com/argon-fan-hat-fo...i-3-b.html), which has its own button. Anyway, thanks :-).

btw, I wonder why they did put a female GPIO terminal on both sides of the hat, this lengthen uselessly the connection to the next hat (in my case HiFiBerry DAC+ DSP); not a big deal, but wonder why this is so...

All the best,

Greg
Reply
#10
Seems the fan-hat and Argon-one case use the same power scripts...:-)

and as for the gpio length this might explain it....(from their site)


Quote:Provides enough space for a heat sink to be used on the chips of the Raspberry Pi board
and presumably any further stacked HAT's ?

cheers,
Bob
----------
bob
Reply


Forum Jump: