Can't play .wav file from Adafruit microSD breakout board (help?)

Hi everyone,

I’m doing a “wearable technology” project that requires playing recorded voices with a small speaker. I stored some wav. files (I used Itunes to convert them) in an Adafruit microSD breakout. I followed the example in this link to play .wav files using the TMRpcm library :
http://maxoffsky.com/maxoffsky-blog/how-to-play-wav-audio-files-with-arduino-uno-and-microsd-card/

The guy from the electronics department from my college gave me a couple of transistors and I ended up making the circuit suggested in the link above with a 2N4401 transistor.

The speaker I bought is a 16 ohm, 0.5 W speaker, this exact one :
https://nicegear.co.nz/electronics-gear/16mm-speaker-16-ohm-05-w/

I followed the example step by step and still can’t play an audible .wav file from the microSD breakout.

I thought I might have burned the speaker, so I decided to test it by following this example that plays a simple melody using the tone() command : https://www.arduino.cc/en/Tutorial/toneMelody
The speaker actually works perfectly and the melody is played well and pretty loud.

So if the circuit with the transistor and the speaker are both working fine, I can’t figure out what the problem is.

I made sure the microSD breakout board is working too, because I tested some of the examples from the Adafruit Tutorial and they worked fine.

I hope someone can help me figure out what’s going on, and if you need any other information just let me know!

Thanks!

Do you get no sound at all?

You need to make sure you have the right format of WAV file and it is placed in the correct place on the card.
What are you seeing in the serial monitor when you try that code?

I'm doing a "wearable technology" project

What sort of Arduino are you using?

Thank you for your answer :slight_smile:

So I figured out what the problem was : basically, I thought the TMRpcm library worked with the speaker connected to any of the I/O pins, but I found out by reading a post on another thread that it isn't the case : the speaker pin must be pin 9 (I was using 8, because that one worked with the tone Melody example.....).

However, the sound I get isn't as clear as I hoped it would be, there's quite a bit of distortion....

I was wondering if you could give me a suggestion to improve the sound. Like I said, I used Itunes to convert my recordings to .wav files (8 bit, 16kHz, mono). This is the circuit I made with the transistor, following the example on the link I posted above : https://bryanduxbury.files.wordpress.com/2012/01/amplified2.png

I used a 120 ohm resistor between the pin and the base of the transistor.

I'm using the Arduino UNO but I'll probably have to change for the Mega because the UNO doesn't have enough memory for what I want to do. About my project : it is a GPS autonomous navigation device destined for people who suffer from Alzheimer's disease. It basically finds the coordinates of your location, and with the help of a magnetometer and the coordinates of your destination (stored in the code before hand), it tells you which direction to go, left or right, through voice commands and haptic feedback.

I was wondering if you could give me a suggestion to improve the sound. Like I said, I used Itunes to convert my recordings to .wav files (8 bit, 16kHz, mono).

I would use Audacity to do the conversion, you have control over the clipping levels.

the sound I get isn't as clear as I hoped it would be, there's quite a bit of distortion

Yes there is due to a few things:-

  1. 8 bit audio is not very good
  2. 16KHz sample rate will only give you 8KHz maximum frequency output.
  3. If there were any frequency above 8KHz when you sampled the sound this will produce aliasing which is very noisy. To get round this you need an input filter that reduces to zero energy above 8KHz.
  4. A restoration filter on the output will cut down high frequency noise.
  5. That audio amplifier is a bit crap, there is DC in the speaker so the cone only moves over half the mechanical range it is capable of. Not only does this damage the speaker it also reduces the sound quality and makes the output libel to clipping.

I'm using the Arduino UNO but I'll probably have to change for the Mega

Because the timers are different in the Mega that library might not work, test it out before going too far down the line.

CamilaH:
So I figured out what the problem was : basically, I thought the TMRpcm library worked with the speaker connected to any of the I/O pins, but I found out by reading a post on another thread that it isn't the case : the speaker pin must be pin 9 (I was using 8, because that one worked with the tone Melody example.....).

Very useful to know!
I'm running out of pins on my project, so will need to keep 9 free!
Just to check - will that be the same pin on all Arduinos? I'm using a nano.

Just to check - will that be the same pin on all Arduinos?

It will be the same on Arduinos that use the same processor. In this case a Uno and a Nano do use the same type of processor.

Thank you for your help! It is very much appreciated :slight_smile:

So I looked up a bit more about speaker and current and I understand like you said that the speaker
should receive an AC current, and not a DC current.

I have been looking for an alternative amplifier circuit and everything seems to point to using
the LM386 amp. Would this circuit work with my 16 ohm, 0.5 W speaker?

Yes there is nothing wrong with that amplifier.

(Don’t mean to thread-jack! But looking at very similar things)

I’m planing on using a very similar LM386 circuit, but the one I looked at doesn’t have the 10uF capacitor at Vin. I think this is for “decoupling”, or removing DC?
Is it essential for Arduino audio output? Am I risking anything by omitting it?

Am I risking anything by omitting it?

You are risking instability in the amplifier.

I think this is for "decoupling", or removing DC?

It is decoupling the supply.

Ok, so I tried to make the amplifier circuit from this link :

I couldn't find a 250 uF capacitor so I used a 220 uF.
Is that ok?

It seems that I have done something wrong because the sound coming form the speaker
is still very quiet, almost not audible....

Could you help me figure out what is wrong?
Thank you!

Yes the change in capacitor you mentioned will not have any effect.

We need a picture of your circuit to see if there is anything wrong.