I'm working in a project and part of this project is sending a .wav file from an Arduino to other device (for example anther Arduino).

I already am able to send a .txt file from an SD which was included in the Ethernet Shield to other Arduino SD card, but it doesn't work when I try to send a .wav file.

Any idea ?

void loop() {
if(digitalRead(push1) == LOW){
      Serial.println("i will send now");
      Udp.beginPacket(destIp, port);
      Serial.println("Sending UDP message");}}

void writeanddeletSDcard(){
   myFile = SD.open("S13.txt", FILE_WRITE); // boolean 
   data = myFile.size();
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.println("i will Write now ");
    myFile.println("HELLO WORLD");

    // close the file:
else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");}

// ---------------- here end of Writing an a massege on the SD Card
  // re-open the file for reading:
  myFile = SD.open("S2.WAV");
  if (myFile) {
    Serial.println("inside the file there's");

c= 0 ;
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      a[c] = myFile.read();

   // close the file:
  } else {
   // if the file didn't open, print an error:
    Serial.println("error opening test.txt");}}
  • What is a? How big is the WAV file?
    – Majenko
    Feb 27, 2019 at 11:31
  • hello, a is an array of char type i want to store the data on it , and then send it , the size of the wav file is 49289 Byte
    – khalid
    Feb 27, 2019 at 12:06
  • And you want to store 49289 bytes in an array on an Arduino with only 2K of memory...? Good luck...
    – Majenko
    Feb 27, 2019 at 12:13
  • i don't want to store it in the Arduino, i want to Store it in the SD card, then dived it to small byte and send it as a Stream of byte
    – khalid
    Feb 27, 2019 at 12:15
  • At the moment you're just "reading from the file until there's nothing in it". I see no attempt at only reading a portion of the file and sending it.
    – Majenko
    Feb 27, 2019 at 12:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.