Upload download mp3 file to SD card

Hi, I want know how upload and download mp3 file to SD card.

Something like:

  1. Send: microphone -> music shield -> mp3 -> SD card -> upload mp3 to internet server;
  2. Receive: download mp3 from internet server -> save to SD card -> music shield -> speaker;

Should I use HTTP POST GET or TCP?


If you just want an mp3 file on the SD card without any programming I advise you to copy the file to the card using a PC. :wink:

Other wise You are in for a lot of programming; MP3 encoding, connecting through the sd card @kennethlimcp, by means of the library written by @mdma, and so forth.

good luck!

The idea work like voice message: voice to mp3, and mp3 to speaker.

So I want find way send and receive mp3 file with server. I find spark core support tcp, but good send string. If I need upload and download mp3 file, I think should use something like ftp?

@rhoulay, you could use a VS1053 breakout like this one:

The use of TCP is most likely the best interface for large data though packet sizes are limited to 1400 bytes or so. The VS1053 will compress the MIC audio but I am not sure it will store it on the SD card. There is a library for the VS1053 available though some members have reported issues with higher bitrates. You have your work cut out but I believe it is possible. Do a search in the Community for “VS1053” and you will find topics very similar to what you are looking for. :smiley:

1 Like

This is definitely do-able. I’ve done the same with downloading an image into flash and then displaying it on a display connected to the Core. I download over HTTP in “chunks” so all I have to do is host the image file on any normal web server. Would this work for you?

@harrisonhjones, I’d love to see that code! :stuck_out_tongue_winking_eye:

Good one,

In sweden we don’t have this :wink:

@harrisonhjones Yes, I think image and audio file are same thing in this case.

And how you upload and download file with HTTP?

@rhoulay,@peekay123, I’ll try to package the code up and put it on a gist tomorrow. Ping me if you don’t hear anything by Saturday


@harrisonhjones hi, how about your sample code?

Hey, this code is crazy rough and not all of its actually there but the general gist is there. Read through it and ask any questions if you are unclear.

It downloads an image which is fixed @ 9600 bytes. As such, there’s only enough free space available for 80 “slots” for these images to be saved into external flash. A more flexible implementation would be nice but I simply haven’t had the time to write it.

1 Like

Hi, @harrisonhjones I find you use some custom function and variable not include in your sample code. Could you include that code?

And how about the main setup and loop flow for spark core?

Sure. Reply back which functions you need and I’ll gladly provide them. The DBG_* functions are just special Serial.print(…) statements which I constructed to make it easier to visualize what’s going on. You are also going to be missing a decent number of constants… I’ll just post the entire file tonight. I’ll update you when it’s there


Alright guys/gals. It’s updated: https://gist.github.com/harrisonhjones/7f7eb97600069279e16e. That’s the whole thing. All that’s needed now is a web server with a script running on it (to serve the image files)

Ping @peekay123 and @rhoulay so you both see this


@harrisonhjones, thanks for sharing! My troublemaker brain is wondering if a webhook could not be used to make the image request (non-local server) and get the data back as 512-byte chunks :stuck_out_tongue_winking_eye:

I don’t see why not. This was written before webhooks and for a battery application so I wanted to limit how much I used the spark cloud

1 Like

Why the extra effort for transferring the for in chunks?

@rsteckler, cause webhooks remove all the tcp code requirements and because they’re fun! :stuck_out_tongue:

Sorry, I wasnt clear on my question :smile:
I’m wondering why @harrisonhjones used http chunk encoding for the downloads. It seems like extra effort to chunk up the transfer like that.

@rsteckler, both the firmware and CC3000 have limited buffering space so chunking avoids buffer overflow issues, which on the CC3000 causes it to crash.