Play music using arduino uno and tpa3118

I made a project to play music from the sd card reader using arduino uno and the tpa3118 mono amplifier. the project scheme is as follows:

The code I use is the following:


#include <Arduino.h>
#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(5);
  tmrpcm.play("audio.wav");
}

void loop()
{
  // put your main code here, to run repeatedly:
}

The problem is that if I increase the volume of the potentiometer to more than a quarter, a very strong background noise appears and the music is no longer heard well. Audio files are in .wav format. I think that I should use an input filter in the amplifier, which will eliminate the background noise. For the amplifier I use a 12V, 2A source. Does anyone have an idea how I could solve the background noise problem?

Is it a high-pitch whine?

I've never used TMRpcm but since the regular Arduino doesn't have a DAC (no true-analog output) it's actually PWM and it's putting-out a 5V PWM signal even with "silence".

You probably need a low-pass filter. Do you know the PWM frequency? "Full power" PWM can potentially do "bad things" to an audio amplifier.

And, I believe it's only 8-bits at up-to 32kHz so it's not exactly "high fidelity".

...Class D amplifiers are basically PWM too but it's usually very high frequency, way above the audio range and better filtered-out, usually with an LC filter.

Thanks for the reply. Unfortunately I don't know the pwm frequency. yes, is it a high-pitch whine. I will try to use a low pass filter to see if it has any results.

HI!! Do you have any pictures do how you made these connections? I´m a hard time making it work! Thanks in advance

download latest tonos de llamada 2023 for free as mp3 to add to andruino and tpa3118

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.