5

I am working on a project that involves a raspberry pi acting as an internet radio client which the public can access by plugging their own headphones into a 3.5mm (1/8”) jack. They will have access to volume control and nothing else. The project’s constrains are:

  • the plug has to be robust, and panel-mountable
  • the sound quality must be good
  • the raspberry pi must know when someone has plugged in.

I am using a usb soundcard connected to a headphone amp to give me volume control, and higher quality sound. for the robust plug and sensing capability, the headphone out is connected to a breadboard which connects to a high quality 3 conductor 4 pin barrel jack and contains a circuit that interfaces with the RPi’s GPIO.

The jack contains a switch which is normally closed, and is opened when a plug is in the jack. I’ve attached a link to the circuit on the breadboard.

The circuit behaves properly when the headphone amp is not turned on, or when the sound source is ungrounded, such as a smart-phone, but when the soundcard out is used, or the headphone amp is on, the GPIO digital pin remains high.

I think it is an issue with the relative grounds of the RPi and the headphone amp. I found the circuit I'm using here. I’m not very savvy with electronics, so I'm not sure what changes to make to get the proper behaviour, but it feels like I'm so close. Is there a simple solution?

Here's the circuit I'm using:

R1=100k, R2=50k, R3=10k, C1=0.1uF

fritzing circuit schematic

1

I've found a workaround, but would still love to hear an explanation for the behavour exhibited above..

After a bit of experimenting, I found that eliminating R3 got the voltages within bounds of the GPIO threshold states. When the switch was open, V at GPIO was 2.85, when closed, V was 0. The problem was that every time I connected my headphones, I would hear the loud pop from the high dc offset which is somehow created by the interaction of the headphone amp and gpio pins. Not good for ears or headphones; I don't know what it might do to the life-expectancy of the Pi.

I've decided to keep R3, but bypass the headphone amp, and use a 1k log pot to give volume control. Sound quality is still quite high, and there are no noises when connecting or disconnecting.

I would still love to hear any solutions or explanations for the behaviour exhibited by the circuit with the headphone amp, but for anyone else who wants to have a headphone sensing jack for their Raspberry Pi, here's an updated diagram. The kind of jack I'm using is 3 conductor 4 contact, like this one. and I'm using a 1k dual gang log pot, such as this one.

Here is my final circuit, same values as before, but with the added 1k pot. The switches just represent the behaviour of the headphone jack.enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.