Go Down

Topic: .WAV file cannot be played (Read 2020 times) previous topic - next topic


Apr 18, 2018, 07:38 pm Last Edit: Apr 21, 2018, 09:37 pm by DanJennings
I am attempting to make a motion activated .WAV player using an Arduino Uno. I am using a TMRpcm program to play the .WAV file and have a SD card reader module connected to the Arduino's 5V supply. The .WAV file is 16000 Hz 8 bit mono. The program has no actual errors present during compiling or uploading, only the  "deprecated conversion from string constant to 'char*' ". When attempting to play the file I got the println text telling me that there was no file. I tested the SD card reader by uploading a program that would read and open a .TXT file which proved the SD card reader is functional, I also tested the two 4 Ohm speakers and they also work. When using an audio player program, the middle two pre-installed LEDs faintly glow red before the led on the right glows red. I will leave a copy of the program below for you to examine. Is there anything that could be suggested that might be causing this problem from what I have described so far? Any answers and/or suggestions would be greatly appreciated and I will be posting the program for more insight on the issue. Thanks.

#include <SD.h>                      // need to include the SD library
//#define SD_ChipSelectPin 53  //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 4  //using digital pin 4 on arduino nano 328, can use other pins
#include <TMRpcm.h>           //  also need to include this library...
#include <SPI.h>

TMRpcm tmrpcm;   // create an object for use in this sketch

void setup(){

  tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc

  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
    Serial.println("SD fail"); 
    return;   // don't do anything more if not
  tmrpcm.play("jugg.wav"); //the sound file "jugg" will play each time the arduino powers up, or is reset

void loop(){ 

    if(Serial.read() == 'p'){ //send the letter p over the serial monitor to start playback



Change the test program to read/open the .wav file...  If that works compare that code to your other one and
make sure its doing the same stuff for the SD card.  RAM usage could be an issue, use verbose mode for upload
and read the output to see if memory is tight?
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]


Okay, thanks! Ill make sure to try this out when I can.


The WAV filename on the SD card must conform to 8.3 format. Long filenames won't work.

Don't send me technical questions via Private Message.


Well, this explains a lot actually! The file name is long, so ill have to try shortening it. Thanks a lot for your help!


long filenames in FAT filesystems are a massive bodge and tend not to be supported by embedded devices,
accident of history...
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]


Unfortunately, making the filename shorter didn't help. Thank you for your suggestion anyways. I posted the program so hopefully there is something that you can find wrong with it. Also, I forgot to mention, The two middle LEDs on the UNO faintly glow red as if they try to light up but cannot. What would this mean and would that be a part of the problem?


Try using all CAPS for 8.3 filenames
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]


Alright, hopefully this works... Thanks for your help!


thanks for (WAV file cannot be played) post. i helped me a lot.


Just to add to the general experience, I spent a few hours yesterday struggling to use the library TMRpcm. I discovered the problem only when I used another SD card program to read the card and print out the first few 100 bytes of the .wav file. In the file I saw the text "Microsoft encryption provider" or similar and it dawned on me that I had copied the file from a PC where the encrypting file system was active. Anyway, I've now got that working and am now hacking the library so you jump into a .wav file in increments of one hundredth of a second (instead of the current one second).

Go Up