Moode Forum
[PROBLEM] IR HAT power on/off - configuration - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [PROBLEM] IR HAT power on/off - configuration (/showthread.php?tid=5210)

Pages: 1 2


IR HAT power on/off - configuration - arczar - 11-21-2022

I bought this HAT: https://wiki.52pi.com/index.php?title=EP-0077

I used this script: 
Code:
#!/bin/bash
echo -e "\e[32;40mInstall package's for script. \e[0m"
sudo apt-get install -y -qq wiringpi
sudo sh -c " curl -sSL https://raw.githubusercontent.com/geeekpi/RPB-HAT/master/remoteswitch > /bin/remoteswitch "
sudo chmod a+x /bin/remoteswitch
sudo sed -i '$i sudo remoteswitch &' /etc/rc.local
echo -e '"\e[32:40m Reboot your raspberry and try to press the power button, reboot button and test it.\e[0m"'
for i in 5 4 3 2 1
do
 echo -e "\e[32;40m $i second...\e[0m"
 sleep 1
done
sudo sync
sudo shutdown -r now


Remote on and off works. Unfortunately, when I use the power off button in the moode interface, the system shuts down, but hat does not turn off the raspberry's power. The LEDs are on. I then have to press the button on the remote control again and only then everything goes out. After that, turning on the remote is OK. What to do to make the effect the same when:
- I press the button on the remote control
- press power off in moode

?


RE: IR HAT power on/off - configuration - TheOldPresbyope - 11-21-2022

(11-21-2022, 07:46 PM)arczar Wrote: I bought this HAT: https://wiki.52pi.com/index.php?title=EP-0077

I used this script: [deleted]

Remote on and off works. Unfortunately, when I use the power off button in the moode interface, the system shuts down, but hat does not turn off the raspberry's power. The LEDs are on. I then have to press the button on the remote control again and only then everything goes out. After that, turning on the remote is OK. What to do to make the effect the same when:
- I press the button on the remote control
- press power off in moode

?

Basically, you can't. 

Both the moOde power shutdown button and the script supplied by your board vendor cause the Pi to stop running but only your board actually turns off the DC supply.

You would need some way to communicate back to the board that moOde is shutting down so the board would turn off the power and I don't see an obvious way to do that.

Regards,
Kent


RE: IR HAT power on/off - configuration - Nutul - 11-21-2022

(11-21-2022, 08:40 PM)TheOldPresbyope Wrote:
(11-21-2022, 07:46 PM)arczar Wrote: I bought this HAT: https://wiki.52pi.com/index.php?title=EP-0077

I used this script: [deleted]

Remote on and off works. Unfortunately, when I use the power off button in the moode interface, the system shuts down, but hat does not turn off the raspberry's power. The LEDs are on. I then have to press the button on the remote control again and only then everything goes out. After that, turning on the remote is OK. What to do to make the effect the same when:
- I press the button on the remote control
- press power off in moode

?

Basically, you can't. 

Both the moOde power shutdown button and the script supplied by your board vendor cause the Pi to stop running but only your board actually turns off the DC supply.

You would need some way to communicate back to the board that moOde is shutting down so the board would turn off the power and I don't see an obvious way to do that.

Regards,
Kent

Hi all,

the only thing I was able to see is the following:

shutdown_signal_pin=5
...
shutdown_STATS=[color=var(--color-prettylights-syntax-string)]`gpio [color=var(--color-prettylights-syntax-constant)]read[/color] [color=var(--color-prettylights-syntax-storage-modifier-import)]${shutdown_signal_pin}[/color]`
[/color]
then... what happens? The board is monitoring at HW level if (somehow) the same gpio input goes down again, and then turns the DC off?

Just out of curiosity, cheers, Al.


RE: IR HAT power on/off - configuration - TheOldPresbyope - 11-21-2022

The vendor Wiki has neither schematic nor logic diagram for this board that I could find. That's what I mean by "I don't see an obvious way...." It could be as simple as a time-out circuit (likely) or something as complicated as a handshake-driven state machine (doubt it). Someone who has one will have to experiment.

Regards,
Kent


RE: IR HAT power on/off - configuration - Nutul - 11-21-2022

(11-21-2022, 09:43 PM)TheOldPresbyope Wrote: The vendor Wiki has neither schematic nor logic diagram for this board that I could find. That's what I mean by "I don't see an obvious way...." It could be as simple as a time-out circuit (likely) or something as complicated as a handshake-driven state machine (doubt it). Someone who has one will have to experiment.

Regards,
Kent

Hi Kent,

yes, I was just wandering around with my brains... I think the IR turns the pin 5 on, then everything begins... can we give it a try, say, using some "gpio write(5, 1)" or similar from command line? (if there is such a call, of course)... I mean, just for fun's sake :-)

Cheers, Al.


RE: IR HAT power on/off - configuration - arczar - 11-21-2022

There used to be an overlay that could do that: https://www.msldigital.com/pages/shutdown-scripts-for-moode-audio

Nutul, How to apply your instructions? I can try, but I need to know what to type in the SSH TERMINAL.


RE: IR HAT power on/off - configuration - Nutul - 11-21-2022

(11-21-2022, 09:57 PM)arczar Wrote: There used to be an overlay that could do that: https://www.msldigital.com/pages/shutdown-scripts-for-moode-audio

Nutul, How to apply your instructions? I can try, but I need to know what to type in the SSH TERMINAL.

Since I see the sh script is basically doing a gpio "read" on pin 5 for it to be "1", by "gpio read ${shutdown_signal_pin}" (shutdown_signal_pin being 5, as seen here: https://github.com/geeekpi/RPB-HAT/blob/master/remoteswitch) I was just thinking that maybe, may-be, we can just do a:


gpio write ${shutdown_signal_pin} 1


or, simply from a shell prompt

gpio  write  5  1

and see what happens.



Cheers, Al.


RE: IR HAT power on/off - configuration - TheOldPresbyope - 11-22-2022

Ummm. 

This pin #5 is apparently in INPUT mode since the script is reading its state (and because the table in the script’s header says the pin is “IN”). I don’t know squat about wiringpi but I’d be surprised if the gpio command automagically forces a change in a pin’s mode when you write to it.

Secondly, if pin #5 is in INPUT mode, then the HAT must be driving it, not sensing it. Not so sure I’d want to be experimenting driving in reverse using my Pi’s GPIO pins. 

I was thinking of experimenting in terms of using a breadboard with switches and current-limiting resistors to see what other pins do (like that mysterious “disk status” pin called out in the parameters table in the HAT’s Wiki entry). But I’ve become cautious that way—I’m too old to be doing smoke tests like I used to.

Just my 2-cents worth. If I’m wrong, it wouldn’t be the first time Tongue

Regards,
Kent


RE: IR HAT power on/off - configuration - DRONE7 - 11-22-2022

Quote:I’m too old to be doing smoke tests like I used to.
 Kent, I thought it was legal in most states now :-)


RE: IR HAT power on/off - configuration - Nutul - 11-22-2022

(11-22-2022, 05:26 AM)TheOldPresbyope Wrote: Ummm. 

This pin #5 is apparently in INPUT mode since the script is reading its state (and because the table in the script’s header says the pin is “IN”). I don’t know squat about wiringpi but I’d be surprised if the gpio command automagically forces a change in a pin’s mode when you write to it.

Secondly, if pin #5 is in INPUT mode, then the HAT must be driving it, not sensing it. Not so sure I’d want to be experimenting driving in reverse using my Pi’s GPIO pins. 

I was thinking of experimenting in terms of using a breadboard with switches and current-limiting resistors to see what other pins do (like that mysterious “disk status” pin called out in the parameters table in the HAT’s Wiki entry). But I’ve become cautious that way—I’m too old to be doing smoke tests like I used to.

Just my 2-cents worth. If I’m wrong, it wouldn’t be the first time Tongue

Regards,
Kent

This is what I have been looking into, too... but my lack of understanding HOW gpio pins got their status changed forced my (old 'n' grumpy) neurons to suggest some naughty "shit" and see what could happen.

But then again, if the power enters the hat board, and through it reaches the PI... well, indeed we might be extremely out-of-luck.


Cheers, Al.