Playing wav file from SD card on Ethernet shield

Hello, I am trying to figure out how to get a wav file to play from a micro SD card on a seeed W5200 Ethernet shield, using the SD and TMRpcm libraries. It seemed to me like I should have just been able to use some of the example code from the TMRpcm library, changing the file name, and had it work. I have made sure that the SD card is formatted correctly. I converted the file from mp3 to wav using iTunes setting the sample rate to 8.00kHz, sample size to 8-bit and the channel to mono, just as instructed and copied it the the SD card. I have set the CS pin 10 as OUTPUT for the ethernet peripheral and set pin 4 as the chip select pin for the SD card. After all of this I still can’t get the file to play. I thought maybe it was the TMRpcm library because I had an issue with importing it, but after I figured that out and put some debugging code (tmrpcm.isPlaying()) in to tell me in the serial monitor whether or not the song was playing, the library seemed to be working fine. Does anyone have any ideas??

#include <SD.h>
#define SD_ChipSelectPin 4
#include <TMRpcm.h>

TMRpcm tmrpcm;

void setup()
  tmrpcm.speakerPin = 9;
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  pinMode(9,OUTPUT); //speaker pin
  if (!SD.begin(SD_ChipSelectPin)) 
    Serial.println("SD fail");  
    Serial.println("SD ok");
    int playing = tmrpcm.isPlaying();

void loop()

I actually never got it working with the TMRpcm library but used the SDAudio library instead ...

Yeah I feel that may be the solution. Although I've played with SiimpleSDAudio too and ran the "quickstart-BareMinimumWithDebug" just as it said and also can't get any sounds. Any tips? I'm pretty sure I have it on the correct CS pin and have formatted the card right.

For the SDAudio library you need a special audio format - you also need to make sure you have the right pin settings (depends on the Arduino you are using - you’ll find everything in the SDAudio.h-file IMHO)

What kind of speaker are you using? Maybe that's the problem? Have you made some test with the tone library? Do you get an output?

Isn't the format "wav"? I have converted the mp3 file to have a sample rate of 8.00 kHz and sample size of 8 bits. Is there something else that I'm missing and need to do? I was just using an 8 Ohm passive radioshack speaker for proof of concept. I did indeed check it with the tone library and it works fine, also I ran the example file in the SD card library "CardInfo" and the Arduino is talking to the SD card just fine. I've been able to write data onto the SD card as well, so I'm pretty sure the circuit is correct, just can't seem to get anything to play from it. But maybe you're right about needing to specify the format more precisely. However, if you're familiar with the SimpleSdAudio library "quickstart" guide, should't the example file they give ("EXAMPLE.AFM") to put on the SD card be in the correct format? Because even that won't run.
Is there a difference between SDAudio.h and SimpleSDAudio.h?

Also, thanks for taking the time to respond!

Well, after many hours of troubleshooting and confusion I have solved my problem!!! I finally decided to give up on using the SDcard built into the Seeed Ethernet shield and went and bought a Seeed SD card shield V3.1, which is nice because it fits both regular SD cards and microSD cards. After changing the Chip Select pin from 4 to 10 on the "music" example file from the TMRpcm.h library and inserting my own .WAV file... IT WORKED!!!!
SO, I hope this helps someone. Goodluck if you're as much as a noob at this stuff as I.

The audio library uses pins 9 and 10 for speaker output by default, so I think that may be what causes issues with the ethernet shield, but don't have one to test with.

The website says "Both W5200 and SD card communicate with Arduino via SPI bus. Pin 10 and pin 4 are chip select pins for W5200 and SD slot. They cannot be used as general I/O. " ... it may work by opening the included pcmConfig.h file with a text editor, and un-comment the line

  • that should disable the audio output on pin10