3

I'm trying to build a Raspberry Pi into an old toy phone and use the GPIO pins to read the numeric pad (this part is working) and attaching the RPi's output to the built-in speaker. The speaker says "8 Ohm" / "0.25 W" on its back.

For interfacing with the keypad matrix (and "off the hook" switch), I'm using these GPIO pins: 15, 13, 16, 11, 12, 18, 22, 8, 19, I'm also using pin 1 (3.3V) and pin 17 (3.3V) for the switch-style connectors.

The audio output so far is working using the built-in ALSA device, but the output volume from the 3.5mm headphone jack is too low. I've researched a bit on the web, and there were some suggestions of amplifier boards or something. Is there an easy way to amplify the headphone output for the speaker in question (8 Ohm, 0.25 W) and can I power this amplification from e.g. the 5V output of the RPi or what would be the best way to get good volume out of the speaker (the quality isn't as important, it's a speakerphone style speaker of a toy). Or would outputting PWM over a GPIO pin and connecting that directly to the speaker be preferable to the 3.5mm headphone jack? I can switch from the Pi 1B that I'm using at the moment to a Pi Zero, if that makes things easier?

3
  • 2
    Wrt an "easy way to amplify the headphone output...", I just happened to have run across this "amp on a chip" product a few days ago. It's an old Unitrode design, now mfd by Atmel. What struck me was how close its description matches with your application: the U4083B is labeled as "Low-power Audio Amplifier for Telephone Applications". There's an AppNote in the spec sheet with a schematic that might work for your application, and no doubt there will be other AppNotes floating around
    – Seamus
    Dec 27, 2018 at 18:48
  • 2
    Welcome to Raspberry Pi! w.r.t PWM on GPIO pin, you'll not gain anything but added complexity this way... after all the analogue out is just doing that for you.
    – Ghanima
    Dec 27, 2018 at 18:53
  • Welcome. If you can't figure out what is okay based on your own research (I think this is nailed down enough now to make it easy enough), or you want to double check your conclusions, the best place to explore this is Electrical Engineering. Presuming you are using the 3.5mm jack, the pi isn't all that relevant, except for power consideration: If you aren't powering it from the pi, you may need a ground noise isolater. You might as well wait and see about that though.
    – goldilocks
    Dec 28, 2018 at 15:11

2 Answers 2

4

This is the solution I ended up with:

  • Raspberry Pi 1 + 3.5mm headphone jack out
  • Adafruit PAM8302A ("Mono 2.5W Class D Audio Amplifier")
  • Power supply to PAM8302A from RPi Pin 4 ("5V Power")
  • Ground to PAM8302A from RPi Pin 6 ("Ground")
  • 3.5mm cable cut off (plug goes into RPi, one mono pair goes into PAM8302A)
  • Output pins from PAM8302A go to speaker
  • The PAM8302A has a screwdriver adjustment for the volume

This is loud enough for my use case (there's still some headroom, but I don't need it THAT loud) and it works nicely off a battery pack as well.

Raspberry Pi + PAM8302A setup

Here's how I soldered the female jumper wires to the 3.5mm headphone jack cable, so it can be connected to the amplifier's pin headers:

Female jumper wires for 3.5mm cable

1
  • 1
    For those wanting to use a later RPi the 3.5mm output is now a 4-pole (tip-ring1-ring2-sleeve) connection and you will want to connect either the tip (left audio output) or ring1 (right audio output) and ring2 (ground) to your amplifier input - this compares to the original 3-pole (tip-ring-sleeve) where the sleeve is the ground contact. The unused sleeve on the four pole connector is the comp. video output on modern RPis - this does mean that it is not ideal to plug in a stereo headphone or the lead that @Thomas has used here into a modern RPi because it will short the video o/p to ground!
    – SlySven
    Jan 22, 2019 at 13:02
2

I've researched a bit on the web, and there were some suggestions of amplifier boards or something.

Yes, this is how wired audio generally works (i.e., it is not a Pi issue), although for young people in the age of bluetooth that may be arcane.

Wired audio sources (e.g., your smartphone) output low level signals into an amplifier, and the amplifier outputs a (much amplified signal) to speakers. This is why if you plug your smartphone into that speaker, you won't get an acceptable volume either. The speaker needs an amp; either there was a primitive circuit for such in the toy or the source was sufficient.

A good reason for this separation is that the amplifier must match the speaker (bad matches can destroy equipment), whereas the audio source does not, therefore you can use the same CD player/phone/TV box, etc. with any amplifier/speaker combo.1

Bluetooth speakers, TV bar style soundsystems, and subwoofer combos all include an internal amplifier, which is why you don't need an external one for those.

Traditional sound systems often have a "receiver/amplifier" which includes a radio, a bunch of cable inputs, a dial to select an input, a dial for the volume, and a digital display. The speakers they are wired to are like the one you are dealing with -- no internal amplifier.

Anyway, all-in-one stereos ("ghetto blasters", etc.) often also have an extra AUX input you can use. If you find one, try plugging the pi into that instead until you decide what to do with your little speaker.


  1. Which is something you'll have to research if you want to get an amp.
17
  • 1
    You are at risk of straying into the area of Electronics SE! Basically a speaker is a low impedance (sort of like resistance) device (in this case a perfectly normal 8 ohms) and it needs a power amplifier to drive it which can provide both the volts and the current to drive an alternative signal through it. (In most electronic circuits it is only voltages - which represent the instantaneous sound pressure level - that are in the picture and which get amplified and manipulated - but in a transducer situation, like a speaker, it is energy...
    – SlySven
    Dec 28, 2018 at 2:20
  • 1
    ... that is involved which has some extra things to be considered) That being the case I have used a TDA8222 Stereo headphone/low power speaker amplifier for this sort of application (but that was over 20 years ago...)
    – SlySven
    Dec 28, 2018 at 2:31
  • 1
    @SlySven Thanks! With regard to 1.5 W output on the amp vs 0.25 W input on the speaker, I found electronics.stackexchange.com/questions/87928/…, which seems to suggest that it will be okay. I've ordered the component now, let's see how well they work together :) Dec 28, 2018 at 11:02
  • 1
    I received the Adafruit PAM8302A component today, it works very well using the built-in audio output of the Raspberry Pi. Here's how I connected it: 1.) 5V + GND from RPi pins 4 and 6 2.) Audio IN from 3.5mm audio out of RPi 3.) Output pins to speakers The Adafruit board also has a little screw that can be used to adjust the volume (and of course one can also adjust the volume with alsamixer to a certain degree). Jan 2, 2019 at 12:36
  • 1
    Since there is a bit of a Pi focus here along the lines of "how can I use this with that", I've reopened this -- if you have time, please add the details of your solution into an answer here (and feel free to move the acceptance tick).
    – goldilocks
    Jan 2, 2019 at 14:15

Your Answer

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

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