0

Let's say I am trying to embed a Pi WH in my motorcycle helmet. I need thin speakers just by the ear to hear sounds (so, I don't need them to be too loud).
* by the way, piezo speakers won't do it in this project

Since Pi WH doesn't have a 3.5mm audio jack, I think my choices are

  1. use USB speakers
  2. use PWM + audio amplifier + speakers

I can certainly buy a set of USB speakers and just connect to it, but the size matters. so I am thinking #2 would only be my choice.

As far as I researched, I think this is the way to go.

  1. setup Option 1. Use Device Tree Overlay
    https://learn.adafruit.com/adding-basic-audio-ouput-to-raspberry-pi-zero/pi-zero-pwm-audio

  2. connect a LM386 audio amplifier to one of the PWM pins

    • RPi 5v pin -> VCC
    • RPi ground -> GND
    • RPi a PWM pin -> IN
    • RPi ground -> GND
  3. connect speakers like this to the audio amplifier

  4. remove noises by this config audio_pwm_mode=2

  5. play sounds by aplay command

Please let me know if any of the steps are wrong before I go ahead and buy all of the parts.


update:

I did the followings to just make sure a speaker without an amplifier would sound just enough.. but I hear nothing coming out of the speaker, not even a noise. It's complete silence. Anything I am missing or not doing right?

  1. add dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4 to /boot/config.txt
    dtparam=audio=on is not commented
  2. sudo raspi-config -> Advanced Options -> Audio -> Force 3.5mm ('headphone') jack
  3. reboot
  4. gpio readall shows
    ALT5 | GPIO. 1 | 1 | 18
    and
    | 13 | 23 | GPIO.23 | ALT0
  5. alsamixer and set the volume 100%
  6. hooked a speaker like this (PWM0 = stereo right channel?)
  7. aplay /usr/share/sounds/alsa/Rear_Center.wav or mpg321 some.mp3

enter image description here

1

For small speakers at low volumes, an audio amplifier may not be necessary. I've had success with PWM audio using the now-discontinued CHIP computer (which should be similar to the Pi) and these speakers from Adafruit without an amplifier in between. If you happen to have the right parts lying around, I would suggest trying this setup before ordering the amplifier.

Also, I would be wary of using an amplifier from AliExpress; you might be better off with this one from Adafruit. It uses less power, which could be useful for a project like yours. Also, it has both the L and R channel, so you could have stereo sound.

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.