SD Card issues ... again

Hey guys!

I'm, once again having some issues with the my SD Card module and speaker.

I'm trying to play a WAV file originating from an SD Card.

My SD Card module works and so does my speaker.

The problem is the following:

When I try to play a file with a siren (similar to ambulance), it works perfectly.

However, I'm trying to play a file where someone talks. When I try do do that a kind of clicking/banging sound comes out of the speaker.

Could someone help me out and maybe see what the problem is?

I have an SPK-1510 Speaker 1W 8Ω, 10 x 15mm, 4mm thick, Wired.

Could it be that the resolution of the speaker is bad. Or that I need an amplifier.

Or did I transform my mp3 file into wav the wrong way? When I play the file on my computer, however, it works perfectly.

I'd love if someone could help me out.

Thanks,

WB

Would you like help correcting the code you didn't post or for someone to check the wiring you didn't show?

What are you hoping someone can do for you?

1 Like

Well, if the code can help, here it is:

void test(){
  rtc.refresh();
  if(rtc.hour() < 12){
    tmrpcm.play("1.wav");
    delay(1350);
  }
  else{
    tmrpcm.play("2.wav");
    delay(1350);
  }
}

And here's the setup:

#include "Arduino.h"
#include "uRTCLib.h"
#include "SPI.h"
#include "TMRpcm.h"
#include "SD.h"

// uRTCLib rtc;
uRTCLib rtc(0x68); // Create library object

File myFile; // Create file object

TMRpcm tmrpcm;

// Ports
const int tb = 2; // Top button
const int bb = 3; // Bottom button
const int vp = 4; // Vibrator pin

//tb
bool tbposition;
long tbinitialtime;
long tbpresenttime;
bool tbprevposition = 0;
long tbpushtime;

// 1-bb
bool bbposition;
bool morsevoice = 0;

// RTC
// Days of the week
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

// SD
// Change this to match your SD shield or module;
const int chipSelect = 10;

void setup(){
  // Pin inputs and outputs
  pinMode(tb, INPUT);
  pinMode(bb, INPUT);
  pinMode(vp, OUTPUT);

  tmrpcm.speakerPin = 9; // Speaker pin
  
  // Begin communication
  Serial.begin(9600);
  
  delay(3000); // wait for console opening

  URTCLIB_WIRE.begin(); //Initialize RTC

  // Comment out below line once you set the date & time.
  // Following line sets the RTC with an explicit date & time
  // for example to set January 13 2022 at 12:56 you would call:
  rtc.set(0, 56, 12, 5, 13, 1, 22);
  // rtc.set(second, minute, hour, dayOfWeek, dayOfMonth, month, year)
  // set day of week (1=Sunday, 7=Saturday)

  tmrpcm.setVolume(7); // Set speaker volume

And here is the wiring:

SD Card

VCC -> 5V

GND -> GND

MISO -> 12

MOSI -> 11

SCK -> 13

CS -> 10

Speaker

9

GND

Hope this helps!

WB

I was just hoping someone knew why a siren works, but not a person that's talking.

Thanks!

WB

There are about a thousand possible reasons.

Do you want help correcting the code that you still haven't posted all of?

Do you want someone to look over the connections that you still haven't posted all of?

What is it that you want someone to be able to do from just the information that your wav file doesn't play right?

OK, listen man, the reason I haven't posted the whole code is because my code is about 2000 lines long, and I don't think you want to go through all that. Second of all, most of that is irrelevant to the speaker or SD Card module.

As for the connections, what more do you want me to post than what I already did!

And if you're looking for more information to solve my problem (which I would greatly appreciate), then what info do you want concretely?

Thanks!

WB

Ok good, it's not very long.

Great, cut it down to an MCVE. We would really appreciate that.

Looks like from the code that there is an RTC in there. It's missing. What else is missing.

I've been pretty clear about that.

Look, I'm assuming that you don't know what the problem is. If you did then why would you be here right? So please stop just giving me the information that YOU think I would need to solve it. You don't know what the problem is so you can't possibly know what information is or is not crucial. Maybe you cross wired some other part. Maybe there's a buffer overrun in some completely different part of the code. The point is that YOU DON'T KNOW. So what you have to do is get it all out there. Show the whole thing or stop wasting our time.

If you don't want to post your whole project, then cut it down to an MCVE. But at least give us a way to replicate the problem. How do you expect someone to solve it when all you've given us is the fact that there is a problem.

1 Like

Perhaps the file size, or the encoding of the two different files.

Thanks for your help guys.

I just realized (since I'm in a quieter space) that the clicking/tapping sound I was hearing is actually the file I wanted to play.

But now my question is the following:

How come the volume is so low???!!!

What info do you guys need?

Okay, I've found a way to amplify the volume, but the resolution isn't great.

Is this inevitable with the speaker I have or is there a solution to improve it?

Thanks!

WB

You keep asking questions of us like we are in the room with you and know what you have. Do you not understand that I'm in a completely different place? I don't know how you recorded your file. I don't have the file. How would I know why it is quiet?

Well, that depends on a lot of things that you seem to not want to share.

So I'm going to ask this one more time and hope you get the hint.

Do you want someone to help you correct the code that you haven't posted all of?

Or do you want someone to help you correct the connections you haven't posted all of?

OK, fine,

Here's an MCVE of the code:

#include "SD.h"
#include "TMRpcm.h"
#include "SPI.h"

TMRpcm tmrpcm;

const int chipSelect = 10;

void setup()
{
tmrpcm.speakerPin = 9;

Serial.begin(9600);

if(!SD.begin(chipSelect)){
  Serial.println("SD fail");
  return;
}

tmrpcm.setVolume(6);
}

void loop() {
  // put your main code here, to run repeatedly:
tmrpcm.play("2.wav");
delay(3000);
}

As for the connections, the speaker is connected to port 9 and GND.

I'd love to share the file to you, but I don't know how. Anything to propose?

I don't know if it could help, but I can tell you that when I converted the mp3 file to WAV:

  • The bit resolution was set to 8 bit
  • The audio frequency was set to 16 000 Hz
  • The audio channels were set to mono
  • The PCM format was set to U8

And you already know what speaker I have (SPK-1510 Speaker 1W 8Ω, 10 x 15mm, 4mm thick, Wired.)

And the file was not recorded, it was online TTS.

Need anything else?

WB

8 ohm speaker, needs an amp..
connecting directly to a pin will cause damage..

sorry.. ~q

Thanks!

Dammage to the speaker or the Arduino?

I'll try to add an amplifier, thanks for the advice and let you know how it goes.

Is there a way to make the resolution better, or do you think it's just the speaker that can't do any better?

Thanks again!

WB

the Arduino..
use ohms law..
current = voltage / resistance
or
0.625 = 5 / 8
625ma ..
check the datasheet, pins are usually like 40ma..

get an amp but damage may already be present..

sorry.. ~q

So you're saying that the Arduino would need to have 625ma for the speaker to work?

But since it doesn't, I need an amp?

No, the speaker is a 8ohm resistive load that could potentially consume 625ma through a pin with a limit of 40ma.. that's why you need an amp..
~q

maybe an old set of amplified pc speakers..
~q

Oh, OK, I get it. Thanks! Super helpful!

So it's possible that the Arduino produce 625ma but however it will get damaged.

Not it can't produce it, think it will max out at 500ma and your computers usb will also max out 500ma..
board could get hot, could also damage pc usb port..
careful.. ~q