10

I'm doing an audio installation where multiple headphone jacks are on a wall and the user will plug into the jacks and each jack plays an mp3 that starts playing from the beginning when it gets plugged in. Is this possible with an RPi? What is the best approach?

3
  • You can use a system with two IR LEDs (Tx and Rx and using the GPIO pins) to check the presence of the cable ... just an idea because it seems that the raspberry can't detect the presence of headphones.
    – Ephemeral
    Dec 29, 2019 at 5:45
  • 11
    why are you not asking how to detect the insertion of the headphone plug? ... it is pointless to ask about playing mp3 files until you can do that
    – jsotola
    Dec 29, 2019 at 6:58
  • 2
    This should be pretty easy, as most panel mounted jacks provide at least one normally closed (NC) contact, which opens when a plug is inserted. You just have to wire this to GPIO pins of the Pi to detect which jack is in use. If the Pi is dedicated to this purpose, then you should be able to get up to 28 inputs without resorting to anything fancy.
    – Glen Yates
    Dec 30, 2019 at 22:29

4 Answers 4

12

Use custom jack socket with plug detection. Hook the audio pins to Pi jack and the detect pin to GPIO. Make sure the detect pin works against ground (most of them do, but there always is a possibility of some exotic configuration).

You pretty much can't use the Pi jack directly anyway, as doing so would put the power port toward the customer.

Depending on how many jacks you need, possibly at some point it would be cheaper to use a PC with N cheap USB soundcards than N Pis. Researching which cards work would be a real pain, I guess.

1
  • 3
    Or a Pi with a bunch of cheap USB soundcards.
    – user253751
    Dec 30, 2019 at 12:40
9

The Pi has only 1 "headphone jack" but no way of detecting if anything is actually connected to it, so you are out of luck unless you are designing your own hardware.

0
7

EDIT:

I have found this digikey paper : a deep dive into audio jack switches and configurations where switch concept is explain.

enter image description here

2
  • 1
    OP mentions having multiple jacks, not multiple headphones.
    – Glen Yates
    Dec 30, 2019 at 22:19
  • @GlenYates, true!, misunderstanding
    – Ephemeral
    Dec 31, 2019 at 16:46
3

You can listen for ACPI events and act on them. You can use acpid directly or a client called acpi_listen that comes bundled with acpid.

acpi_listen works as following:

# acpi_listen                                            
jack/headphone HEADPHONE plug
jack/headphone HEADPHONE unplug
2
  • 6
    Does the raspi support this though, I didn't think it had the right hardware? Dec 29, 2019 at 18:39
  • @djsmiley2kindarkness that's surprising for me, actually. given how little you need to do to do it. Dec 30, 2019 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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