Hello everyone!
So let's start with: this is my first topic and Arduino project. I will try to explain as much as possible in this post my problem: please correct me if something is wrong!
I tried for hours and hours to play a wav music from my Elegoo Uno R3 (= arduino UNO) using the TMRpcm library, a 2W speaker (from a basic computer speaker), the TDA2822M chip and a micro SD card.
My issue is that the sound going out from the speaker contains a LOT of buzzing (cf. audio).
I first tested the SD reader and it appears it has no problem connecting to the card and reading the music (I guess). Moreover I can hear the music in the background of the buzzing.
I tried all the frequencies for the music (8000, 16000, 32000, 48000 Hz), I tried mono and stereo, I tried 8 and 16 bits. Well I tried to play many different WAV files and none of them actually worked.
I use the circuit from Figure 2 (Bridge) provided by the TDA2822M notice (https://www.st.com/resource/en/datasheet/cd00000134.pdf) and as the input on port 7 I connect to the port 9 of the Elegoo Uno R3. For +Vs I tried 5V and 3.3V but none of them gave a correct sound.
I am using the code written at the end of this post (for clearness). With the function "tmrpcm.setVolume(x)" I tested every value from 1 to 7: none of them gave a correct result. The only difference is that a bigger value gave a louder buzzing sound.
I tried to uncomment "#define DISABLE_SPEAKER2" in pcmConfig.h but nothing changed.
I tried to use the same speaker with tone and it correctly played the notes expected. I guess the problem does not come from the speaker.
Well I really need help otherwise I might shout loud from my balcony out of sadness.
Thank you for your help !!!
The code
#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
TMRpcm tmrpcm;
void setup(){
tmrpcm.speakerPin = 9;
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}
tmrpcm.setVolume(2);
tmrpcm.play("16000u.wav");
}
void loop(){ }
EDIT
I added the circuit made with Fritzing.
buzzing.aac.zip (92.6 KB)