Thank you for your donation!


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


How to set-up GPIO output status
#1
Hello,
I kindly ask your help to try a function I'd like to activate on Raspberry, possibly using MoodeAudio.
I need to set a GPIO pin or Raspberry 3B as "System Startup Event" so that one GPIO pin status goes ON at startup and OFF at shutdown.
This because I need to set 2 LEDs On and Off when Moode is On and Off, the status of that Pin (GPIO 17) is read by an auxiliary board and drives the LEDs
The producer of the board suggest a way but only using Volumio (see the attachment).



Can someone kindly suggest me if it's possible using MoodAudio (I've not found such a function) or a different way to set GPIO pin as System Startup Event ?

Thank you very much !!
Enrico


Attached Files Thumbnail(s)
   
Enrico
Reply
#2
Hello,
I've done it by writing the following code in /boot/config.txt:

dtoverlay=gpio-poweroff,gpiopin=17,active_low

If someone has some comments about that or there is a better way to reach the result, please let me know.
Thank you very much for your upcoming suggestion.
Enrico
Reply
#3
You could try a little hacking.

Add these 3 echo lines to the beginning of /var/www/daemon/watchdog.sh like below.
Code:
.
.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
echo "17" >/sys/class/gpio/export
echo "out" >/sys/class/gpio/gpio17/direction
echo "1" >/sys/class/gpio/gpio17/value
.
.

Add these 3 echo  lines to the beginning of the if block in /var/local/www/commandw/restart.sh
Code:
.
.
if [[ $1 = "poweroff" ]]; then
   echo "17" >/sys/class/gpio/export
   echo "out" >/sys/class/gpio/gpio17/direction
   echo "0" >/sys/class/gpio/gpio17/value
.
.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#4
Thank you Tim,
I'll try shortly and give a feedback.
Enrico
Reply
#5
Hi Tim, your code works very good, better than my solution.
Thank you.

My solution worked well but there is a problem: after shutdown, I'm not able to use other GPIO pin as input (for example the restart function). I don't know why but at the moment I have no time to investigate and also you provided a perfect solution.
Moreover, with your code, GPIO 17 turns ON just when MoodeAudio gests ready for music, and not before... perfect.

Thanks again.
Enrico
Enrico
Reply


Forum Jump: