Hardware Guidance for Simple Audio Project

Hello,

I’m currently working on a simple audio project using tmrpcm library. I’m getting sounds for same duration of the song it supposed to be playing, but it’s unrecognizable. Please help suggest additional hardware that I need, in order for the sound to come out properly

Here’s my current set up, Arduino Uno, Micro SDcard Adapter, an earphone. The earphone is connected directly to pin9 and ground, without any additional resistor. The code is attached.

I have browsed through other similar projects. They used either 8ohms or 16 ohms speaker connected with a transistor and a resistor. As I said, right now I have my earphone connected directly to the Arduino without these components. Is this why I’m getting loud, yet unrecognizable sound? Should my set up be any different since I’m using an earphone not a speaker? and what type/size of transistor and/or resistor should I use?

Thanks in advance.

sketch_feb09a.ino (566 Bytes)

From what I can gather with a quick squint through, the output will be a pwm signal. It will have a dc component. Try adding a capacitor (100uF?) in series with your earphone to remove it

Allan.

Thanks, I'll try it. Do you mind explaining why do I need the capacitor for earphones but not for speakers? Do speakers usually have one built in already?

Do you mind explaining why do I need the capacitor for earphones but not for speakers?

You need them for both.

Do speakers usually have one built in already?

No.

You could also do with a reconstruction filter, that is after the capacitor a series resistor of 1K5 to the ear phone and a capacitor of 10nF across the ear phone to ground.

Hey guys, I tried both set up.

  1. the 100 microFarad capacitor in series with the earphone

  2. the 100 microFarad capacitor in series with 1k Ohm resistor. Both are then in series with the earphone. And a 10 nanoFarad capacitor across the earphone.

Both set up still give me the monotonic crackle for the length of the song. The reason why I asked if I would need the capacitor if I were to use a speaker instead is, I found a similar project which didn’t seem to use capacitor at https://diyhacking.com/arduino-audio-player/

Anyway, if you have any further suggestion on how I can get the sound to work properly please let me know. Thanks a lot for your effort so far

Tut

Well, the hardware ought to work.... so there's something wrong with your source material or your code.

Maybe the serial comms is interfering - try removing it form the loop(). Or using a much higher datarate - eg 115200 baud.

Allan

the 100 microFarad capacitor in series with 1k Ohm resistor. Both are then in series with the earphone. And a 10 nanoFarad capacitor across the earphone.

How about posting a schematic so we can check that your interpretation of those words match ours.

I found a similar project which didn’t seem to use capacitor at …

Hey, there is a lot of crap on the internet. Just because a particular design worked for one person doesn’t make it a good design that will work for everyone.

I would be very suspicious of any web page that does not post a schematic, it implies the author is a rank beginner.

  1. I have removed the code from the loop(). Please see the new code attached, if you want to confirm. I’ve also tried various datarates(300, and 115200). But there is still no change in the sound.

  2. I’ve made a schematic of what I have. Please let me know if I understand you guys correctly

sketch_feb09a_draft1.ino (413 Bytes)

Hi,
What do you get on the monitor screen?

Have you checked the TMRpcm.h library example and set volume

I don't know if its compatible with your setup.

Tom... :slight_smile:

I'm currently getting the following on the print out.
Line1: Start
Line2: 1

Which is what I'm supposed to be getting. Meaning the SD card is initialized and read properly and the song is playing.

I'm not experiencing any volume problem. The sound that I'm getting is actually quite loud, but it's a monotonic crackles, instead of a song.

The circuit looks fine. Could it be your sound file is not of the right format. Try loading this one.

yes.wav.zip (6.05 KB)

tuttang:
Here's my current set up, Arduino Uno, Micro SDcard Adapter, an earphone.

Impedance of the speaker or earphone?

If the impedance is rather low (below 20 Ohms or so), you can use this wiring picture to connect a speaker or earphone to the Arduino output:

You can either use a resistor (maybe 100 Ohm... 330 Ohm)
Or use a capacitor instead (maybe 1µF)

Test it by using the tone() function for creating an output fequency.

If the tone function works well, also PCM output should work without too much distortion.

  1. I tried your yes.wav file. Still no change, loud crackle for the the duration of the file.

  2. I tried the tone function, using the example arduino melody code (code attached). It works fine. The sound output is exactly what it suppose to be.

As for the impedance of the earphone, it’s an earphone that came with my phone when I bought it, so I’m quite certain it’s less than 25Ohm

sketch_feb13a.ino (1.03 KB)

Just a thought ... is a uno quick enough to do this?

I've seen audio libraries for a due, but not the slower processors...

Open to correction

Allan

Thanks a lot guys for you effort. I have switched to SimpleSDAudio library instead of TMRPCM. Now it works fairly well. Not sure why.