Amplifier Switch Plugin

Anyone, anything :question:

I would keep the functionality that you are trying to achieve external from this plugin. Either use a hardware based solution, or run a script to toggle the GPIO directly.

As for UI, it should be drawn up by professionals only unless you don’t have any plans for further promotion of your project. Here’s a list of perfect examples mobile design. Check it.

Hi,

this plugin seems to be great but it does not work for my constellation (RaspiB+, IQAudio Pi-DigiAmp+, actual Volumio 2.526.) or maybe I have misunderstood its benefit: I assume, that the Amplifier Switch Plugin will mute the amp when volumio does not play ?

According to the IQAudio documentation the amp on the DigiAmp+ can be switch by GPIO22. If I select channel 22 in the AmpSwitch (version 0.1.1.) configuration and press the save button. I get the message “Port not accessible”.

But It works to (un)mute the amp with:
gpio mode 3 out
gpio write 3 1 (for unmute)
gpio write 3 0 (for mute)

Using GPIO3 in the AmpSwitch configuration the DigiAmp does not give any more sounds; even after rebooting.
The mute LED is not changing depending play/stop state.

Do you have an advice how to get this to work ?

Thanks & best regards
Ralf

The plugin is actually meant to switch on/off your amplifier via a relay connected to a GPIO pin, but as all it does is flip some GPIOs no reason you can’t use it to mute your amp instead.

The error means that port22 was not accessible via the sysfs interface that the plugin utilises to toggle GPIOs.
Are you able to manually toggle via sysfs?

$ sudo sh -c "echo 22 > /sys/class/gpio/export" 
$ sudo sh -c "echo out >/sys/class/gpio/gpio22/direction" 
# Mute
$ sudo sh -c "echo 1 >/sys/class/gpio/gpio22/value" 
# Unmute
$ sudo sh -c "echo 0 >/sys/class/gpio/gpio22/value" 

# Cleanup
$ sudo sh -c "echo 22 > /sys/class/gpio/unexport

Any reason why you don’t use the auto_mute_amp overlay for your DigiAmp+? It should automatically mute/unmute the amp based on the alsa playback state.

Thank you for your hint

In the meantime I have figured out that the dtoverlay=iqaudio-dacplus,auto_mute_amp
must be adjusted in the file /boot/config.txt

With this the mute state is automatically toggled.

Hello,

I am trying now for about 4 hours to get the plugin working with this relay board hellasdigital.gr/electronic … bot/?sl=en

connected vss to 5v, gnd to gnd and In1 to GPIO4 / Pin 7

When i set the output to pin 4 the led on the board will flash and stays on no matter what i do, if i click on save it just blinks for one time and will stay on again.

any ideas what i am doing wrong?

thanks
felix

Probably needs to be inverted? Are you able to manually get the relay module working directly via sysfs (scroll up a few posts and adjust the code for your GPOI)

Hello!
I can only turn it on in sysfs but cant turn it of, I/O error appears which i dont understand, even tried it with a second installation of volumio on another sd card…

when i select the desired gpio and submit it will turn on but wont turn off again, when i change the gpio to any other, the light will go off again if that helps troubleshoot the problem? no matter if the status at /dev is on play, pause or stop

any ideas?

felix

If you are using a pi, then GPIO4 is the default pin for onewire driver (w1-gpio). pinout.xyz/pinout/1_wire#
You should probably disable it, or use a different pin.

Hello,
I tried almost all gpios and have the same problem no matter what pin i use…

Dont know how to solve this :unamused:

What board are you using and what Volumio version is it running, and what is the I/O error you get?

EDIT: I just looked at the relay board - you posted hellasdigital.gr/electronic … bot/?sl=en
It’s a 5v board - the pi is 3.3v, you would need a logic level convertor. A simple transistor(2N2222 for e.g) would also do the trick.
If you want to get a new board - then the same web shop has a SSR based board that should work.

That seemed to be the Problem!

Thanks, works now like a charm which is weired because I used the same relais with another project without any troubles but as long as it works i am happy.

thanks,
Felix

Hi all,

I want to share my solution for switching my Yamaha AVR (RX-V473) on and off by Volumio. Since I have no skills in writing a volumio plugin I decided to do it on an other way, by writing a batch script working together with the Amplifier Switch plugin.

  • SSH on volumio
  • #sudo apt-get update
  • #sudo apt-get install netcat
  • create a file “avr_switch.sh”
  • edit the file to get this code:

[code]#!/bin/bash

while true
do
while [ 0 = $(gpio -g read 17) ]
do
sleep 0.1;
done
echo “switch on”
printf “@MAIN:PWR=On\r\n” | nc -q 1 RX-V473 50000
printf “@MAIN:INP=AV1\r\n” | nc -q 1 RX-V473 50000

while [ 1 = $(gpio -g read 17) ]
do
    sleep 0.1;
done
echo "switch off"
printf "@MAIN:PWR=Standby\r\n" | nc -q 1 RX-V473 50000

done[/code]

  • make this file executable
  • edit the file /etc/rc.local and insert this line before “exit 0”:

sh /home/volumio/avr_switch.sh&

  • reboot volumio
  • in the volumio settings / Plugins / Amplifier Switch set the Output to 17

This works perfect for me! There is no need to make modifications at the hardware, since the by “Amplifier Switch” selected GPIO can be read by the batch script.

Have fun!

This is the script for my PIONEER AVR:

[code] #!/bin/bash

while true
do
    while [ 0 = $(gpio -g read 17) ]
    do
        sleep 0.1;
    done
    echo "switch on"
    printf "PO\r\n" | nc -q 1 192.168.178.37 8102
    sleep 1
    printf "04FN\r\n" | nc -q 1 192.168.178.37 8102
    sleep 1
    printf "081VL\r\n" | nc -q 1 192.168.178.37 8102

    while [ 1 = $(gpio -g read 17) ]
    do
        sleep 0.1;
    done
    echo "switch off"
    printf "PF\r\n" | nc -q 1 192.168.178.37 8102
done[/code]

Hello,

I have an old integrated amp Kenwood A-91 that I would like to be able to switch on/off from the RPi. Hence my interest in AmpSwitch.
I read in this thread:

(1) What would be the pros/cons of a transistor/mosfet vs. a relay in my case?

(2) Below is the schematic of my amp’s power supply chip. I guess the relay should hook the phase straight after the plug (i.e. point numbered 17 or 18 on the scheme), am I correct?

(3) Could the on/off cycles trigerred by AmpSwitch via a relay as per (2) - thus bypassing the standby mode of the amp I believe - add excessive wear to my amp?

(4) I read about transistor/mosfet and saw they could be used as electronical switch, which I guess is the use referred to in this thread. However I can’t get where it should be located in my “circuit” (base = signal from GPIO; collector = should it bear high voltage? emitter = ?).

Any help would be much appreciated.

Best,
Dtog

Amp power supply chip.png

Can you tell me how to navigate on ssh in order to delete ampswitch

Hi - I use the plugin to switch off my amplifier whenever the player state is “stopped”, which works great. However, when listening to webradio and changing stream, the amp switches from on to off, and then on again.

I reckon that plugin just reflects the Volumio state (playing - stop - playing) when changing stream. Is it possible to have a delayed off option? So that the plugin waits x seconds after detecting stopped player state before changing the GPIO to 0.

Hope it makes sense.

It is indeed! There is already a delay feature (implemented back in ~2017 IIRC) - do you not see it in your version of the plugin?

Yeah, it’s there, but it’s working as a delayed on rather than a delayed off.