Hey, have you heard the good news? With Adafruit STEMMA boards, you can easily and safely plug sensors and devices together, like this Adafruit STEMMA Speaker - Plug and Play Audio Amplifier. Like the name implies, it's got a class D audio amplifier on board, and our favorite little 1 Watt 8 ohm speaker.

Connecting it up is easy - you only need ground, 3 to 5V power, and audio signal. The audio signal does not need to be AC coupled, we do that for you, and can range up to the power pin voltage (3 or 5V peak-to-peak). You can use either the 3-pin JST socket or the alligator/sew-pads for this slim and portable package. The sound quality is good enough for music, tones, speech, whatever you like and volume can be adjusted with a small screwdriver.

For use with a CircuitPlayground or micro:bit, this JST to alligator-clip cable works best. Red is power, ground is black and signal is white.

For use with a breadboard, try one of the following cables:

  1. JST PH 3-Pin to Male Header Cable - 200mm
  2. JST PH 3-Pin to Female Socket Cable - 200mm

Let's take a look at what comes on the Adafruit STEMMA Speaker plug and play audio amplifier!

Speaker and Connector

Located in the center of the board is the 1 watt 8 ohm speaker connected to the board via a Molex PicoBlade connector.

JST Connector

The easiest way to connect the STEMMA speaker to your project is the 3-pin JST connector at the base of the board. There are 3-pin JST to various connectors available, including to alligator clip and breadboard pin options, to make it super easy to connect it to any kind of project.

  • White Signal (SIG) This is 0-3V signal input, we decouple this signal so it can be AC or DC coupled.
  • Red Power (+) This is 3-5V DC power
  • Black Ground (-) Signal/power ground

Alligator Clips

The STEMMA speaker comes with three alligator clips pads to use with alligator clips. In the image to the left, they are top to bottom:

  • Signal (SIG) This is 0-3V signal input, we decouple this signal so it can be AC or DC coupled.
  • Power (+) This is 3-5V DC power
  • Ground (-) Signal/power ground

Volume

You can change the volume using a small screwdriver to rotate the volume trim pot.

Amplifier

The board includes a class D amplifier located above the JST connector.

Using the Adafruit STEMMA speaker is as simple as connecting it to your project. Existing audio code works the same way but will use the STEMMA speaker instead. Let's take a look at an example using Circuit Playground Express.

You can use any device that outputs analog 'line level' audio signal, we're testing with a Circuit Playground but you can use for any general purpose audio output amplification!

Circuit Playground Express Wiring

First, wire up the STEMMA speaker to a Circuit Playground Express as shown. We suggest using a 3-pin JST to alligator clip cable with the 3-pin JST connector on the STEMMA Speaker.

  • Plug the 3-pin JST to alligator clip cable into the 3-pin JST connector on the STEMMA Speaker
  • Connect the black alligator clip to a GND pad on the CPX
  • Connect the white alligator clip to the A0 pad
  • Connect the red alligator clip to the VOUT pad

Circuit Playground Express Example Code

This example uses CircuitPython. If you're not already using CircuitPython, check out this quick-start to get it going.

The first example plays a different tone for each button on the Circuit Playground Express.

Copy the following code to a code.py file on your CIRCUITPY drive:

from adafruit_circuitplayground.express import cpx

while True:
    if cpx.button_a:
        cpx.play_tone(260, 1)
    if cpx.button_b:
        cpx.play_tone(292, 1)

Press each button to play a different tone through your STEMMA speaker.

The second example plays a different wav file for each button on the Circuit Playground Express.

Click the buttons below to download the two wav files and copy them to your CIRCUITPY drive.

Then, copy the following code to a code.py file on your CIRCUITPY drive:

from adafruit_circuitplayground.express import cpx

while True:
    if cpx.button_a:
        cpx.play_file("rise.wav")
    if cpx.button_b:
        cpx.play_file("dip.wav")

Press each button on the Circuit Playground Express to play each file through your STEMMA Speaker.

That's all there is to using your STEMMA Speaker with Circuit Playground Express and CircuitPython!

Further Information

For more information on using the STEMMA Speaker with MakeCode, check out the Music and Sound in MakeCode page of the Make It Sound guide.

For more information on using the STEMMA Speaker with CircuitPython, check out the Music and Sound in CircuitPython page of the Make It Sound guide.

This guide was first published on Oct 04, 2019. It was last updated on Oct 04, 2019.