I want to learn how to read an MP3 file from a mini-SD /wATtiny85...

Ok, so, I would like to program an ATtiny85, to read different MP3 files(single words mp3 file), and read the file(s), selected by the program after a certain input occurs. Lets say, i want it to monitor the weather, and it will output, in any language, the temperature, humidity, winds, and be able to voice the variables, from the ATtiny85, and reading the mp3 words on the mini SD card, and output it as a voice, with the known variables after being read. This all should happen on a push button event.

The SD card is able to have the words recorded, with anyone’s voice, and record the words in mp3 format, so that it outputs some such as - “Your current weather is - “Temperature, (mp3 file - Temperature is -(VAR), “Humidity (VAR)xxx%”, winds at,(VAR-MP3Word”).”

How would this be possible? How do I read the mp3 files, and output them to a small speaker, and insert the variables I described? I have searched but failed to find much in the forums. And I may not be searching for the correct forum, or message. I am SURE it can be done. I just need a bit of coaching to program it correctly. Reading the file, and outputting it, would it be using the ‘lprint’ command, with a port number? If not, how…

Many Thanks, folks…


Use plain WAV files, not mp3, as you need them to run together in time (mp3 requires substantial pre-processing on opening the file before a single sample is available).

You'd need every digit and sound to be an individual file so you can stitch them together.

Hello, Mark!
I want to thank you for that knowledge. I did not know that, and I will make a important note on it. Now, I just need to know how to read the file when the ATtiny85 is triggered to do so, allowing it to read the words through the speaker.

How would you recommend I do this part of the software, and is there a place on the forums, that may have some code I can look at and modify??

Thank you for all of your help! You are a great mentor, thanks!

Many kind Regards;


MP3 shields typically have libraries to operate them, documented by the shield's manufacturer, that's where to start, particularly any examples that come with the library and any guides.

If you're imagining ATtiny85 could read the file from a SD card and do the work to decoding the MP3 data into audio, not to mention sending that audio data to a DAC or other hardware, the bad news is ATtiny85 and all other 8 bit AVR chips are woefully inadequate for the task of decoding MP3.

You either need a hardware shield or module that does the decoding and playing of the sound (usually using a dedicated chip), or a much more capable processor. Regarding what the code would look like on such a processor, I can point you to Frank Boesing's MP3/AAC library, which is based on a port of the Helix MP3 code released by RealNetworks.

I can confirm a Cortex-M4 at 96 MHz definitely is capable of decoding and playing MP3. Cortex-M3 should also be able to handle it, but Cortex-M0+ at 48 MHz is probably not enough CPU power for MP3's IMDTC and filter banks.

Using software or a hardware shield approach, you should probably be aware that MP3 is a rather complex encoding which is designed for continuous streaming, involving considerable buffering. MP3 is not designed for low-latency. It is a streaming protocol, composed of relatively large blocks of data (26ms per block is typical), where the decoded audio depends not only on the current block, but on data from several prior blocks.

If you try to use MP3 files for individual words to form speech, those high latency streaming-designed features of MP3 are likely to cause you frustration. Obviously if you use software like Frank's library and you run it on a more powerful processor, you probably can overcome obstacles like needing to rapidly pre-read enough data to fill the MP3 "bit reservoir" and decode enough to prime the MDTC buffers. You'll also have much better control over the MP3 decoder state, so you could re-initialize well (to avoid a chirp or other audible artifact) when you start sending a new MP3 data stream. If you go with a shield or module based on a dedicated chip, you'll have no control over the MP3 decoding process and you'll (probably) be stuck with whatever latency and other less-than-desirable behavior that chip has when re-synchronizing to a new MP3 data stream.

For an attempt to synthesize speech by stringing together sound clips of individual words, you really should go with uncompressed data, or an encoding which is designed to provide low latency. But if you're determined to go with MP3, hopefully this info and Frank's library can give you a starting point.

Hello, Mark...

Thanks for the info! Let me make the end product more clear.

The weather station comparative prolly wasn't the best one. When a phrase is in ""quotes, is what I want to have said. Here IS the thing I want to create:

This is the basic flow of the "Defect Detector", I want to create. It basically uses a IR tx/rx detector(s), and triggers the following event -

It starts a count of the number of cars going over the detector itself.

when the detector sensor is cleared, it will select a word, or short phrase, in the following format:

"BNSF Defect Detector(programmable name), mile post(VAR int), "Total number of axles"(VAR int), "Train Length(int, length in scale feet), "Total number of defects(VAR int), "Defect Detector, Out".

It will store the number of cars, and then multiply that by x4, to get the number of axles, it can have a temp sensor if wanted, as the prototype does have that.

The only thing is, it will have difficulty knowing of there is a "defect", as the prototype does. Although I have been tinkering with a sensor that counts the "CARS", The WHEEL sets(axles), and can sense when a wheel is off the track. Counts the Cars, and can actually figure out the true scale length of the consist, in feet(Enter scale being used). In this case, HO scale.

I hope this explains better what I want to achieve. Simple, hopefully.

As the selection of a processor, would the ATtiny84 work better? Maybe a ATtiny 2313??

I hope more people weigh in on ideas for this, I am thinking it would be a cool novelty item to have on a layout...

Thanks again for your help. I really do need to find some coding I can look at, modify, and try out. I just do NOT have any idea where to start at this point.

Many THANKS to the ones who have made suggestions to try. Everything is important to me, to help learn these means and ways.

Input is GRATEFULLY Appreciated!!!!



Ok, So, How would I call the player to play a certain sound byte?


How would I call the player to play a certain sound byte?

Assuming you mean "sound byte" to mean a small amount of sound and not byte in the computing term of 8 bits, then you simply use the command that causes a sound to be played and pass it the name of the file where your required sound is stored.

As the selection of a processor, would the ATtiny84 work better? Maybe a ATtiny 2313??

The ATtiny of any sort is right out. Did you read reply# 4? If so why are you ignoring the important information you were told there? If you are told something that you don't understand then ask about it do not ignore it.


Your last reponse went against community standards and was DELETED.