Speaker Bonnet - Adding volume control?

tl;dr: Can I wire in a pot to act as a volume control?

I love my Pi Zeros, especially the one I’ve set up with RetroPie, but it’s a pain to get audio from directly (cheap monitor has no audio, buyer’s regret) so I’m excited about the Speaker Bonnet.

But I’d like a physical volume control. Could I do that? Is it possible to add in a Pot somewhere?

Short answer: Absolutely!

But you’ll need some sort of analogue to digital converter to read the pot.

You might be able to successfully read a rotary encoder directly from the Pi’s GPIO pins to achieve the same effect. Or, even simpler; just two buttons- one for vol up, one for vol down.

I’m not sure how the Speaker Bonnet is set up, but you will no doubt have to make configuration changes on your Pi to support volume control, too.

Checking into it, the Speaker bonnet uses the same kernel driver as the phatdac and Picade HAT (in fact Adafruit’s setup script is a clone of ours, which they happily acknowledge and credit), so you should be able to use the config we supply for picade-hat:

you can then achieve software volume control in a similar manner as we supply (again) for picade-hat, using a pair of buttons (but it would work with a pot too):

if it then just a question of triggering the mixvolume script when actuating your buttons or pot. You can find an example as part of the picade-hat input daemon:

of course there are other ways to do this but I thought I’d give you pointers on a possible way to achive this, based on a solution that I have first hand experience (and could help you with if you ran into trouble).

… I hope that helps!

1 Like

Wow, thanks for the great advice. It’s definitely a bit more complicated than I imagined :o

It’d be a fun project, but I think time limits me to just putting on a PhatDac, and being very grateful!

The sound issue is my own fault, I thought I was clever by getting cheap monitors and installing Kano OS on my own for my two boys. The monitors have no audio output so I made a set of speakers and mini-amp with volume-pot for each Pi as a little intro-to-electronics project.

Then I set up a Zero with RetroPie and a Zero4u to introduce them to games but without audio (HDMI audio is pointless with no monitor speakers) it isn’t the same. PhatDac works but RetroPie bugs audio output to constant 100%. The little Anker speaker I have available doesn’t do volume down (?!) so I thought I could rig the bonnet as a simple hardware-only cure.

I’d need a custom box/case/thingy to stop little fingers breaking buttons, I’d like to create a console with them but perhaps I’ll wait until someone has blazed the trail and worked out all the gremlins.

I’m pretty sure you can control volume from emulationstation i.e before you start a game. You need the asound.conf file I linked to above, and that’s it.

… I’ll check it through but I’m fairly sure it would work, and while not as convenient as being able to control volume while in game it might still be a better option than being blasted by your speakers if you have no external volume control.

I’m very interested in doing this as well. I just got the bonnet up and running, but the two laptop speakers I have hooked up to it just aren’t loud enough. When you say

are you saying that a pair of physical buttons can be soldered to the board? Where at?

Hello,

I am struggling with adding volume control in retropi as well.

RogueM- As you mentioned I used Adafruit’s install script based on yours and the audio works great, it’s just too loud. I want to get the volume control within emulation station to work and Adafruit support said it ‘should’ work fine with their install script. It doesn’t. The code they have in their asound.conf is much shorter than yours:

pcm.!default {
type hw card 0
}
ctl.!default {
type hw card 0
}

I’ve changed my asound.conf to match the file you linked in this thread and now instead of loud audio, I’m not getting any audio.

Any recommendations for how I could get that emulation station volume slider to work would be greatly appreciated.

the asound file we provide with Picade HAT will make sure the software object used by ALSA is called ‘PCM’… I can’t see why that wouldn’t work with any DAC.

… but obviously you need to retain the rest of their setup, to make sure that the correct hardware driver is loaded. You also need to check that the ALSA volume is not at 0, otherwise the sound will be muted.

I went through everything, made sure it was all correct, and restarted. No change. A day later turned the whole thing off and back on… now the volume control works great. No idea exactly what happened or changed… but worked great so I’m happy!

Thanks!!