Quite some time ago, I tried to use the functionality of the Arduino Audio Tools to download a file from an URL and store it on a SD card, but I was running into some problems. I finally found the time to investigate the issue and I have the functionality finally working now:
#include "SD.h"
#include "AudioTools.h"
const char *ssid = "SSID";
const char *password = "password";
URLStream url(ssid, password); // Music Stream
StreamCopy copier; //(i2s, music, 1024); // copy music to i2s
File file; // final output stream
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
// intialize SD
if(!SD.begin()){
LOGE("SD failed");
return;
}
// open music stream
url.begin("https://pschatzmann.github.io/Resources/audio/audio-8000.raw");
// copy file
file = SD.open("/audio-8000.raw", FILE_WRITE);
file.seek(0); // overwrite from beginning
copier.begin(file, url);
copier.copyAll();
file.close();
}
void loop() {}
The (potentially updated) Sketch can be found on Github!
0 Comments