Give your Raspberry PI the power of Speech with Adafruit’s max98306

For a project I’m working on, one of the objectives is that the RPi be able to “speak” – just to have some fun.

The RPI can output audio through HDMI and the 3.5mm audio jack. Since I’m going to use the RPi for a small robot, the HDMI audio capabilities are of no interest. So, it only leaves the 3.5MM audio jack, but there’s a problem. The audio is not amplified. For some headphones it’s fine, but for a talking robot, the audio volume is just to low.

How to bypass that ?

Enter Adafruit’s MAX98306.

Requirements

  • 1x Raspberry PI
  • 1x Speaker ( small speaker from an old PC – 8 Ohms, 0.5 W )
  • 1x Adafruit’s MAX98306
  • 1x 3.5MM female jack (I’ve salvage one from an old CD-ROM drive)

Speaker

speaker1

speaker2

3.5MM female audio jack

jack1

MAX98306

Image from Adafruit

Wiring

Heres the wiring for the MAX98306.

sound1_bb

Connect an external power source (my case 4xAAA batteries) to the MAX98306 VDD and GND PINs

My 3.5MM audio jack only has 3 PINs. I’ve tried to search for the pinout, but I was unable to find anything. I tried several configurations and this one was the best. Since I’m only going to use one speaker, I’ve connected it to the right speaker PINs of the MAX98306.

Here’s the result

wiringSOUND

Left PIN (as the image goes) of the JACK connects to L+ and R-. Right PIN connects to R+

Connect the speaker to the right screw-terminal blocks.

sound5

Sound configuration

Note: The following section (sound modules and alsa mixer) can be skipped – just check if you already have sound output (connect a set of headphones and play something) or if the snd_bcm2835 module is loaded (ie: lsmodules). By default, the output is auto-detected

Prepare for sound

Reboot the PI and when it gets back online, just load the sound modules and set the output to the 3.5mm stereo jack

The amixer numid settings are:

0=auto
1=headphones
2=hdmi

Verify your mixer settings

alsamixer

NOTE: The Adafruit’s MAX98306 has a jumper where you can configure the gain.

Check the wiring of the speakers

If you’re wiring two speakers, you can head to Richard Farrar page to check if the speakers are wired correctly and if the RPI is sending the sound right.

He has some mp3 files that you can use to check the left, right and balance

http://www.richardfarrar.com/are-your-speakers-wired-correctly/

Give voice to your RPI

Now it’s time to make your RPi speak. We’re going to use espeak. It is simple to use and it it has Python modules that you can use in your programming.

Install a CLI audio player

Play something

And you should have audio playing !

References

https://jeffskinnerbox.wordpress.com/2012/11/15/getting-audio-out-working-on-the-raspberry-pi/

 

2 thoughts on “Give your Raspberry PI the power of Speech with Adafruit’s max98306

Leave a Reply to Richard Farrar Cancel reply

Your email address will not be published. Required fields are marked *