Adding a 12v trigger

Many traditional Hi-Fi amps include a 12v trigger allowing them to be switched on by a control device - eg a pre-amp tells a power amp to switch on or perhaps a sub etc.

What I’d really like to do is to have a pi send a 12v trigger signal somehow to power up a Rotel amplifier whenever music is playing and then perhaps close the signal a minute or two after the activity stops.

I am starting from zero here but should this be possible in a balenasound build?

1 Like

The Pi cannot handle a 12 volt source directly. However you can do this by using a GPIO pin to drive an open collector transistor that closes a relay to switch the 12 volt signal to the amp.

There’s a number of circuits already published that show how to do this.

One additional tip:
Don’t forget to place a reverse biased diode across the relay’s coil to absorb the high voltage “kick” generated by the relay when it is turned off.

Exactly how to programmatically control a GPIO pin within Balina OS is a separate question that I don’t yet know how to do.

Thanks for the response - i figured it might be something along those lines but I wouldn’t have known about the diode tip. Will add that to my reading list and continue to pursue the control element.

1 Like

You’re not the only one who hasn’t heard about it. :wink:

Some designers place the diode across the active circuit element, (transistor/FET), to protect it - but that simply places the inductive spike across the entire VCC supply. :crazy_face::face_with_symbols_over_mouth:

Some advocate a small capacitive filter along with the diode, but you probably won’t need to get that complicated.

I hope someone steps up with an answer to the question about how to program the GPIO pins. Enquiring minds want to know!

Hello,

First, regarding triggering the 12V circuit from the raspberry Pi, as Jim suggests, you can use a 5V relay module. You should be able to use a gpio library of your choice to trigger the raspberry pi’s pin on/off and achieve your desired outcome. You can find a nodejs example here: https://github.com/balena-io-playground/balena-rpi-nodejs-basic-gpio which you can adapt for your use case

Secondly, regarding using this functionality with balenaSound, you will have to modify the project to be able to get this going. Once you have validated the above works, you can edit the balenaSound project source code and add the service - you will need to copy your files and also edit the docker-compose file to add the service and necessary settings. Then you can deploy you application.

Hope this helps. Always be careful when using higher rated voltage supply
Kind regards
Rahul

1 Like

Hi everyone, balenaSound maintainer here :wave:

Just want to add to what my colleague explained above. balenaSound 2.x versions actually have some sort of support for this use case in the form of “bluetooth scripts”.
Basically balenaSound allows you to run user-provided scripts on connect/disconnect bluetooth events. You can read on how to enable this here and we have sample scripts that toggle GPIO pins here. This is ofc limited to bluetooth playback (spotify/airplay/upnp won’t work with this feature).

A quick notice on this feature though. balenaSound v2.4.10 is the last version where this will be available. I’m planning on releasing balenaSound v3.0 tomorrow hopefully and this feature will not be implemented in there. An upcoming update to 3.x will include the ability to run this type of scripts regardless of the audio source that’s currently streaming, but that won’t be ready for 3.0. I created a GH issue to track progress on this: https://github.com/balenalabs/balena-sound/issues/282

Finally, my last advise is to be extra safe and careful when working with this types of projects. Be sure to read on and test stuff properly before actually putting everything together to avoid potentially damaging expensive audio equipment!

3 Likes

Thanks all for the additional info - I think I have a bit of learning ahead of me!

1 Like

Just to check, as I read it, this product would cover that diode requirement as it has “freewheeling diode protection”?

So far I found this video really helpful in demystifying the physical setup for me as a beginner. I think the software side might take me a little longer!

1 Like

It absolutely would. However, for your application, it is probably overkill.

If you look around on the 'net for relay circuits for the Pi, you should find something suitable.

This is great news! I have been hoping for something along these lines - currently i issue a series of commands to my voice assistant to turn on speakers via a smart plug, connect to bluetooth and then play some audio stream. It would be great if the speakers could be powered up automatically on connect events. I guess I could do this via the smart plug local connection, it’s cloud connectivity or over ifttt or similar. Thanks for the headsup!