Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4484

General • Problems trying to play audio using MAX98357 audio amplifier

$
0
0
Hello everyone,

I’m working on a project using the Raspberry Pi Pico to play an audio file on loop. For this, I’m using the MAX98357 audio amplifier with a 4-ohm, 3W speaker.

This is the audio amplifier module I'm using.
And this is the speaker.

My goal is to create a custom RP2040 board that integrates the audio amplifier and includes buttons for starting/stopping the audio and adjusting the volume up and down, all powered by 2xAA batteries. (Is this too optimistic? It seems feasible in theory, right?)

So far, I’ve managed to get audio output, and it works fine when powered by my computer. However, when I switch to 2xAA batteries, the sound crackles a lot, and eventually, it only produces crackling sounds with no actual audio playback. I’ve recorded the issue so you can see it for yourself:
Powered by the computer
Powered by 2xAA batteries

Here’s the minimal code I’m using to reproduce the issue (this is the same code running in the videos):

Code:

import timeimport board # type: ignoreimport audiocoreimport audiomixerimport audiobusioaudio = audiobusio.I2SOut(board.GP19, board.GP18, board.GP20)mixer = audiomixer.Mixer(voice_count=1, sample_rate=24000, channel_count=1, bits_per_sample=16, samples_signed=True)audio.play(mixer)volume = 1.0mixer.voice[0].level = volumewavFile = audiocore.WaveFile(open("re-save-room.wav","rb"))isPlaying = Falsewhile True:    if isPlaying:        print("Play")        mixer.voice[0].play( wavFile, loop=True )        isPlaying = True
And this is the connections diagram:
Screenshot 2025-01-05 at 20.10.10.png
Basically the connections are from the audio amplifier are:
- LRCLK - GPIO 18
- BCLK - GPIO 19
- DIN - GPIO 20
- GAIN - GND

I initially thought that the buck-boost converter on the Pico would be enough to handle 2xAA batteries, but it seems like that’s not the case.

I’m a bit stuck right now, so any help would be hugely appreciated. I might be overlooking something basic about the Pico, the audio amplifier, or the speaker. If anyone has suggestions, resources, or ideas on what to investigate next, I’d be really grateful.

I’m also open to different approaches, such as using another audio amplifier, speaker, or a completely different way to get audio out of the Pico with decent quality.

Thanks in advance for your time!

Statistics: Posted by lobo14 — Sun Jan 05, 2025 5:11 pm — Replies 3 — Views 74



Viewing all articles
Browse latest Browse all 4484

Trending Articles