The whole point of this project is to learn, I am trying to recreate this little guy here: Link
You press a button, it plays a short audio file, its small, battery powered, that's it.
I am currently using a ATtiny85, LM386 for audio amplification, and a 8ohm 1w speaker. Obviously the goal is size, it has to be small. My main issue right now is the audio output is quiet even with the amp. I'm wondering if there are any better ways to go about this project because even if I can get the audio to be louder, there is still that size constraint. Are there any small chips designed to play mp3 files that could be used for this? I am well aware there are sd card modules that can be used, but again, the size constraint.
More information is needed.
Please post a schematic diagram of the circuit and post the code producing the sound, using code tags. Also explain how the project is powered.
small chips designed to play mp3 files
Yes, this one.
I am not asking how to fix my current circuit, im asking are there better ways to go about this project. You also linked the exact sd card module that I said wouldn't work for this project, again because of the size constraint.
You are welcome. Have fun!
How loud does it have to be?
We don't know what dB level you have right now, how much power the LM386 is producing, or how efficient that speaker is. Any of those will affect the volume.
not very, just loud enough where its audible. Right now the LM386 is being powered by a 9v power source and the ATtiny85 is being powered by a separate 5v source with a common ground. Which really isn't very practical, just seeing if anyone knew of a better way to go about this.
Try plugging something else into the LM386 amplifier... The line-headphone output from your computer or phone, or the analog "RCA" outputs from your DVD/CD player, etc.
It should go plenty loud enough to hear. I'm guessing there's a problem somewhere else.
You can also try tone(1000) which should make a signal strong enough to overdrive the amplifier as loud as it can go. (I'm assuming tone() works on the ATtiny.)
With 9V you can get a theoretical maximum of just-over 1W into 8-Ohms and with 5V a little less than 1/2W. Double that into 4-Ohms.
There is also a potential advantage with a battery because it's pure DC with no noise. With a shared power supply, sometimes "digital noise" gets into the power supply and then gets amplified by the amplifier.
Yes tone works which makes it plenty loud, I would prefer to use the PCM.h library though because it allows me to encode a mp3 file to be played, which im sure is also part of the problem, I just don't know a workaround without having to buy a sd card module.
DFRobot MP3 Player Pro is about 1"square and has a 3W amplifier. It can be used stand-alone without arduino also and it's pretty loud. MP3s store directly to the chip so no SD card is needed.
DFPlayer Pro - A Mini MP3 Player for Arduino WiKi - DFRobot
One possibility is that the LM386 is getting over-stressed. Since there is no DAC and no true-analog output the PCM library puts-out high-frequency full-voltage PWM. If the 386 chip is too hot to the touch, that's like the issue (or an issue). Even with quiet audio, it's putting-out the full voltage and unfiltered, that's putting a lot of stress on the amplifier.
Are you sure? I think it plays PCM (WAV) files. And, you'd want to decode (decompress) MP3 to play it. I don't think the ATtiny is powerful enough to decode MP3 in real time, and if it is, you'd need a library for that.
I had no idea there was a pro version! Which is so much better because I don't have to use an sd card. Although it might be challenging to reverse engineer the pcb. Also, I read some reviews on it, it seems that the audio file plays on repeat when the play button is pressed, when the end goal is to have it play once per button press. I would imagine this is an easy code or hardware fix (if it's an issue). Do you have one yourself? Have you messed around with it or know more about it?
The LM386 isn't hot to the touch. I only say I would prefer to use the PCM library because I dont know of any others. Do you?
I've built a couple of projects with them. It's been a while, but I remember that some of the behavior can be programmed and stored so you don't need to keep an arduino connected.