Stufin
Home Quick Cart Profile

M5 StickC Speaker Hat (PAM8303)

Buy Now on Stufin

Stereo Speaker Output

Supports stereo audio output with a maximum power output of 3W per channel.

Onboard Capacitors

Includes onboard capacitors for filtering and decoupling, ensuring clean and stable audio output.

Compact Design

The speaker hat is designed to be compact and lightweight, making it ideal for space-constrained applications.

### Technical Specifications

Supply Voltage

3.3V to 5V

Current Consumption

Typically 20mA ( standby), 100mA (max)

Audio Frequency Response

20Hz to 20kHz

Signal-to-Noise Ratio (SNR)90dB
Total Harmonic Distortion (THD)0.5% (typical)

### Compatibility

M5 StickC CompatibilityDesigned specifically for use with the M5 StickC series of microcontrollers.

Operating Temperature

-20C to 70C

Applications

--------------

The M5 StickC Speaker Hat (PAM8303) is suitable for a wide range of applications, including

IoT projects requiring audio output

Robotics and robotic arms

Home automation systems

Industrial control systems

Wearable devices

Audio-based interactive installations

Conclusion

----------

The M5 StickC Speaker Hat (PAM8303) is a versatile and efficient audio solution for M5 StickC-based projects. Its compact design, low power consumption, and high-quality audio output make it an ideal choice for a wide range of applications. With its easy-to-use I2S interface and compact design, this speaker hat is perfect for developers, makers, and engineers looking to add audio capabilities to their projects.

Pin Configuration

  • M5 StickC Speaker Hat (PAM8303) Pinout Documentation
  • The M5 StickC Speaker Hat (PAM8303) is a compact audio amplifier module designed for the M5 StickC series of microcontrollers. This documentation provides a detailed explanation of the pins on the Speaker Hat, along with connection guidelines.
  • Pinout Structure:
  • The Speaker Hat has a total of 6 pins, arranged in two rows of 3 pins each. The pinout is as follows:
  • Row 1:
  • 1. VIN ( Vin )
  • Function: Power supply input (3.3V to 5V)
  • Description: This pin is connected to the power supply of the M5 StickC or other microcontrollers. Ensure a stable voltage supply within the recommended range.
  • 2. GND ( Ground )
  • Function: Ground connection
  • Description: This pin is connected to the ground of the M5 StickC or other microcontrollers, providing a common ground reference.
  • 3. DAC ( Digital-to-Analog Converter )
  • Function: I2S audio signal input
  • Description: This pin is connected to the I2S output of the M5 StickC or other microcontrollers, providing the digital audio signal to the amplifier.
  • Row 2:
  • 1. L+ ( Left Channel Positive )
  • Function: Amplified audio output (left channel)
  • Description: This pin outputs the amplified left audio channel signal, which is connected to the positive terminal of a speaker or headphones.
  • 2. L- ( Left Channel Negative )
  • Function: Amplified audio output (left channel)
  • Description: This pin outputs the amplified left audio channel signal, which is connected to the negative terminal of a speaker or headphones.
  • 3. R+ ( Right Channel Positive )
  • Function: Amplified audio output (right channel)
  • Description: This pin outputs the amplified right audio channel signal, which is connected to the positive terminal of a speaker or headphones.
  • Connection Guidelines:
  • When connecting the Speaker Hat to the M5 StickC or other microcontrollers, follow these guidelines:
  • Connect the VIN pin to a stable power supply within the recommended range (3.3V to 5V).
  • Connect the GND pin to the ground of the M5 StickC or other microcontrollers.
  • Connect the DAC pin to the I2S output of the M5 StickC or other microcontrollers.
  • Connect the L+ and L- pins to the corresponding terminals of a speaker or headphones (left channel).
  • Connect the R+ pin to the positive terminal of a speaker or headphones (right channel).
  • Important Notes:
  • Ensure proper power supply and ground connections to avoid damage to the Speaker Hat or connected components.
  • Use appropriate cables and connectors to connect the Speaker Hat to the M5 StickC or other microcontrollers, as well as to speakers or headphones.
  • Adjust the volume and audio settings on the microcontroller or connected device to optimize the audio output.
  • By following these guidelines and pinout explanations, you can successfully connect and utilize the M5 StickC Speaker Hat (PAM8303) for audio applications with your M5 StickC or other microcontrollers.

Code Examples

M5 StickC Speaker Hat (PAM8303) Documentation
Overview
The M5 StickC Speaker Hat (PAM8303) is a compact and versatile speaker module designed for use with the M5 StickC series of microcontrollers. It features a PAM8303 audio amplifier and a 1W speaker, making it suitable for a wide range of IoT applications, from simple alarm systems to more complex multimedia projects.
Hardware Specifications
PAM8303 audio amplifier
 1W speaker
 Compatible with M5 StickC series microcontrollers
 Operating voltage: 3.3V - 5V
 Dimensions: 30.5 x 15.4 mm
Software Library
To use the M5 StickC Speaker Hat (PAM8303), you'll need to install the M5StickC library for your preferred programming language. For this example, we'll use the Arduino library.
Code Examples
### Example 1: Simple Tone Generation
This example demonstrates how to generate a simple tone using the M5 StickC Speaker Hat (PAM8303).
```c++
#include <M5StickC.h>
#define SPEAKER_PIN 25  // Speaker pin on M5 StickC
void setup() {
  M5.begin();
  pinMode(SPEAKER_PIN, OUTPUT);
}
void loop() {
  tone(SPEAKER_PIN, 1000, 500);  // Generate a 1 kHz tone for 500 ms
  delay(1000);  // Wait 1 second
  noTone(SPEAKER_PIN);  // Stop the tone
  delay(1000);  // Wait 1 second
}
```
### Example 2: Playing a WAV File
This example demonstrates how to play a WAV file using the M5 StickC Speaker Hat (PAM8303) and an SD card module.
```c++
#include <M5StickC.h>
#include <WiFi.h>
#include <SD.h>
#define SD_CS 5  // SD card chip select pin
#define SPEAKER_PIN 25  // Speaker pin on M5 StickC
WiFiClient client;
SDCard sdCard;
void setup() {
  M5.begin();
  pinMode(SPEAKER_PIN, OUTPUT);
  sdCard.begin(SD_CS);
}
void loop() {
  File file = sdCard.open("example.wav");
  if (!file) {
    Serial.println("Error opening file");
    return;
  }
int16_t sample;
  while (file.available()) {
    sample = file.read() | (file.read() << 8);
    digitalWrite(SPEAKER_PIN, sample > 0 ? HIGH : LOW);
    delayMicroseconds(50);
  }
file.close();
  delay(1000);  // Wait 1 second
}
```
### Example 3: Text-to-Speech using ESP8266 and Google Translate
This example demonstrates how to use the M5 StickC Speaker Hat (PAM8303) to play text-to-speech audio generated using the Google Translate API and the ESP8266 WiFi module.
```c++
#include <M5StickC.h>
#include <WiFi.h>
#include <HTTPClient.h>
#define SPEAKER_PIN 25  // Speaker pin on M5 StickC
WiFiClient client;
HTTPClient http;
void setup() {
  M5.begin();
  pinMode(SPEAKER_PIN, OUTPUT);
  WiFi.begin("your_wifi_ssid", "your_wifi_password");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
}
void loop() {
  http.begin("http://translate.google.com/translate_tts?ie=UTF-8&q=Hello+World&tl=en&client=tw-ob");
  int httpCode = http.GET();
  if (httpCode == HTTP_CODE_OK) {
    int16_t sample;
    while (http.available()) {
      sample = http.stream().read() | (http.stream().read() << 8);
      digitalWrite(SPEAKER_PIN, sample > 0 ? HIGH : LOW);
      delayMicroseconds(50);
    }
  } else {
    Serial.println("Error retrieving audio data");
  }
  http.end();
  delay(1000);  // Wait 1 second
}
```
Remember to replace the WiFi credentials and the Google Translate API URL with your own values.