

The M5Stack ModuleAudio is an audio module designed for use with M5Stack development kits. It integrates an I2S-based digital audio amplifier, enabling high-quality audio playback in compact IoT and embedded systems. This module is ideal for applications requiring sound output, such as smart speakers, voice assistants, alarms, and multimedia projects.
Common applications and use cases:








The M5Stack ModuleAudio connects to the M5Stack Core via the standard M-BUS interface. Below is the pin configuration for the I2S interface:
| Pin Name | Description | Connection |
|---|---|---|
| LRCK | Left/Right Clock (Word Select) | GPIO25 (default) |
| BCLK | Bit Clock | GPIO26 (default) |
| DIN | Data Input | GPIO22 (default) |
| GND | Ground | Common ground |
| VCC | Power Supply (5V) | 5V from M5Stack base |
Connect the ModuleAudio to the M5Stack Core:
Power the Module:
Configure the I2S Interface:
Write Code for Audio Playback:
#include <Arduino.h>
#include <I2S.h> // Include the I2S library for audio communication
void setup() {
// Initialize serial communication for debugging
Serial.begin(115200);
// Initialize the I2S interface
if (!I2S.begin(I2S_PHILIPS_MODE, 44100, 16)) {
Serial.println("Failed to initialize I2S!");
while (1); // Halt execution if I2S initialization fails
}
Serial.println("I2S initialized successfully!");
}
void loop() {
// Example: Generate a simple sine wave for testing
for (int i = 0; i < 360; i++) {
float sample = sin(i * PI / 180); // Generate sine wave sample
int16_t audioSample = (int16_t)(sample * 32767); // Scale to 16-bit range
I2S.write((uint8_t *)&audioSample, sizeof(audioSample)); // Send to I2S
}
delay(10); // Small delay to control playback speed
}
No Sound Output:
Distorted Audio:
I2S Initialization Fails:
Module Overheating:
Q: Can I use an external speaker with the ModuleAudio?
A: Yes, you can connect an external speaker to the module. Ensure the speaker impedance is 4Ω or higher and does not exceed the module's power rating.
Q: Does the ModuleAudio support stereo output?
A: No, the ModuleAudio is a mono audio module. For stereo output, additional hardware is required.
Q: Can I use the ModuleAudio with platforms other than M5Stack?
A: Yes, the ModuleAudio can be used with other microcontrollers that support I2S communication. Ensure proper pin connections and software configuration.
Q: What audio formats are supported?
A: The ModuleAudio supports I2S audio in Philips mode with a sampling rate of up to 48kHz and 16-bit resolution.