Arduino library for WTV020-SD-16P audio module

Kindly explain in English. I don't understand the language

I finally got mine to work. All this time is was an incompatible memory card. The data sheet should give some examples of working cards to use, that way we know what to get, the first time.

I've got the Sparkfun breakout board for this audio module working intermittently. I'm using it in serial mode connected to an Arduino UNO with the Wtv020sd16p.h library from the original post in this thread. The breakout board is powered from the 3.3 volts from my UNO. I'm getting my sounds to play okay, but frequently I don't get any sounds. If I remove power the UNO (which removes power from the breakout board), then re-apply, it works again. I've tried adding a speaker.reset() before I try to play a sound. I also tried increasing the delay() in Wtv020sd16p.cpp on line 37 from 300 to 750 and line 94 from 20 to 50 per a suggestion from a Sparkfun user in the breakout board comments, but neither helped. Here's my sketch:

#include <Wtv020sd16p.h> 

int resetPin = 8;  // The pin number of the reset pin.
int clockPin = 9;  // The pin number of the clock pin.
int dataPin = 10;   // The pin number of the data pin.
int busyPin = 11;   // The pin number of the busy pin. 

bool playingSong; 

// Create an instance of the Wtv020sd16p class.
Wtv020sd16p speaker(resetPin,clockPin,dataPin,busyPin);

void setup() 
{
  Serial.begin(9600);
  speaker.reset(); // Initializes the speaker module
  playingSong = false;
  Serial.println("Finished setup");
}

void loop()
{

  if (playingSong == false)
  {
    Serial.println("Play sound");
    speaker.asyncPlayVoice(0);
    delay(200);  
    if(digitalRead(busyPin) == HIGH)
    { 
      playingSong = true; // Set flag so command to play song doesn't run again
      Serial.println("Busy"); 
    }
    else
    {
      Serial.println("speaker not busy");  
    }
  }
  
  if (digitalRead(busyPin) == LOW)  // when song is over, reset flag so it will play again
  {
    Serial.println("finished song, play again");
    playingSong = false;
  }
}

When I have the problem of no sound the sketch outputs this over and over, it's seems to loop a few times per second:
Play sound
Busy
finished song, play again
Play sound
speaker not busy
finished song, play again
Play sound
Busy
finished song, play again
Play sound
speaker not busy
finished song, play again
Play sound
Busy

Hi the-rebel-agent,

Thanks for your library. Got my unit up and running in less that 30 minutes (most of it getting the wiring right!).

I had an old 64Mb(!) micro SD card that works fine and will probably be enough for what I want to do (voice for a robot).

Thank you for sharing this library!

I'm using the SparkFun breakout board as well, but I'm encountering some weird problems. Basically, I can get it to play back sounds, but when I try to play multiple files in a row, things don't work properly. Sometimes it will play the first file and then nothing for a couple of minutes, sometimes it will skip a file. Here's an example:

while(true){
wtv020sd16p.playVoice(1);
delay(2000);
digitalWrite(testLED, LOW);
wtv020sd16p.playVoice(3);
delay(2000);
digitalWrite(testLED, HIGH);
}

This behaves erratically. The LED flashes as expected, but the sound doesn't always play. Sometimes file 1 will play, sometimes nothing plays, and rarely file 3 plays. If I take it out of the loop, file 1 usually plays, but file 3 does not. I also tried it with asyncPlayVoice(), with the same results. If I take the delays out, the LED flickers and then stops while one of the files plays. Then it flickers some more and plays another file (usually it'll alternate, but sometimes it'll repeat).

Any ideas?

As with so many others on this thread, my problems have all come down to SD card issues.

Both a Sandisk and a Kingston 2GB failed to play any music at all - however a no-name 2GB card works fine. And by "works", I mean all songs play through fine as expected via 2-line control as done by this thread's library - so I must add my name to the chorus thanking the-rebel-agent!

And this behaviour was exactly the same on 2 WTV020-SD-16P modules (I got the second while trying to get the first to work, since I assumed Sandisk not working implied there might be a problem with my module).

All 3 SD cards look fine when used with a Mac SD card reader. However particularly in the case of the Sandisk, I wonder if the branded SD cards are genuine, particularly Sandisk which has a huge fakes problem?

My next steps

  1. Run cards through F3 (http://oss.digirati.com.br/f3/, Mac version of h2testw) to see if anything emerges.
  2. I have seen elsewhere (http://forum.arduino.cc/index.php?topic=115411.0) people suggesting trying slightly higher than 3.3v to the WTV, eg send in 3.6v - and that this can make previously failing cards work. I am getting a variable voltage regulator so I can try various levels and see if that helps with the 2 cards that are currently failing.
  3. I've just got a job lot of old 1Gb and smaller SD cards and will see if any pattern emerges from that, in terms of what SD cards work and what don't.

If anyone could give an amazon UK (or other) supplier of cards that is guaranteed to work, that would be extremely useful!

  1. Run cards through F3 (http://oss.digirati.com.br/f3/, Mac version of h2testw) to see if anything emerges.

All 3 SD cards showed full capacity and no errors on reading/writing. So nothing obvious there. The no-name SD card that works is slower than the other two - could it be possible that cards get too fast for the WTV020 somehow?

I will put results on this thread when I've got the regulator to test 3.5/3.6 driving voltage, and/or have tried a wider range of SD cards.

I would like to make a whole bunch of very small, very noisy things, and the WTV is the ideal module - if I can figure out a reliable source of working SD cards.

Faster card might drain more current but only if you run it faster.

Having now tried a number of SD Cards at various voltages (3.3v, 3.40v, 3.48v, 3.57v):
Kingston 2Gb: 1 card, doesn't work at all
Transcend 2Gb: 1 card, doesn't work at all
Sandisk 2Gb: 3 cards, 1 works at 3.3v, 2 require 3.4v+
No-Name 2Gb: 1 card, works perfectly at 3.3v
No Name 128Mb: 8 cards, 7 work perfectly at 3.3v, 1 skips some plays at 3.3v, works at 3.4v+
Nokia 128Mb: 3 cards, 2 work perfectly at 3.3v, 1 skips some plays at 3.3v, works at 3.4v+

Conclusions (from my admittedly limited sample):
128Mb cards do better at 3.3v than 2Gb cards
Moving slightly above 3.3v seems to help with some cards (but is not a sure-fire cure)
Once you hit 3.4v, increasing further doesn't help with any more cards from the sample

Drilling down on one of the Sandisk 2Gb cards that needs more than 3.3v, it works at 3.38v or above, and not at 3.35v or below. So less than 0.1v is making the difference here.

I have a Samsung 1Gb and it works fine. I bought a 5 pack on eBay, just in case the card stops working.

Hi,
Recently I bought a WTV020-SD-20SS module from http://emartee.com/product/41928/MP3%20SD%20Card%20Sound%20Module. But it is not behaving properly.When I gave command wtv020sd16p.asyncPlayVoice( 0) or wtv020sd16p.asyncPlayVoice(2) it does not play any sound. Again if I give wtv020sd16p.asyncPlayVoice(1) or wtv020sd16p.asyncPlayVoice(3) or wtv020sd16p.asyncPlayVoice(5) it play both 0002.ad4 and 0003. ad4 alternatively. I tried changing the mask HEX value (eg. unsiggned int mask = 0xFFFF) in the .cpp file it again behave differently.
Previously I was using WTV020-SD-16 p module from Sparkfun and it was working properly with the library.

What I feel is that , probably the timing or the mask value is not correct for WTV020-SD-20SS module. Can you help in resolving the issue?

-neel

Has anyone been able to get the volume command working properly with this device? According to the spec, commands 0xfff0 through 0xfff7 should set one of eight volume levels, but only mute (0xfff0) and full volume (0xfff7) work properly. Intermediate values cause the audio to become very choppy, randomly changing volume, like maybe the ADPCM can't sync up? This happens with this library (if I change, say, VOLUME_MIN from 0xfff0 to 0xfff3 and call mute()) as well as an interrupt-based one I'm working on.

I'm using 32Kb/s ADPCM files from the UsbRecorder utility.

Joe

Has anyone been able to get the volume command working properly with this device? According to the spec, commands 0xfff0 through 0xfff7 should set one of eight volume levels, but only mute (0xfff0) and full volume (0xfff7) work properly. Intermediate values cause the audio to become very choppy, randomly changing volume, like maybe the ADPCM can't sync up? This happens with this library (if I change, say, VOLUME_MIN from 0xfff0 to 0xfff3 and call mute()) as well as an interrupt-based one I'm working on.

I'm using 32Kb/s ADPCM files from the UsbRecorder utility.

Joe

I modified the library to increase and decrease the volume, and it works great. I added three new functions to the library. Hope these help.

Wtv020sd16p.cpp (2.74 KB)

Wtv020sd16p.h (717 Bytes)

keywords.txt (566 Bytes)

HazardsMind:
I modified the library to increase and decrease the volume, and it works great. I added three new functions to the library. Hope these help.

Thanks. Didn't help unfortunately--I still get very choppy volume when trying to modify the volume. Here's scope trace of what's supposed to be a constant 440 Hz tone, after a call to volume(3):

Turns out that it only happens with 32 Kb/s ADPCM files (created by the UsbRecorder v1.3 tool). Setting the volume with 24 Kb/s or lower sampling rate files works fine, even though 32 KB/s file play fine at full volume. Weird. Anyway, the solution is to use 24 Kb/s max.

I'm a bit confused with the busy light. According to the specs, the busy pin goes low when the module is playing a voice. Since one pin of the busy light is tied to Vcc, the light should turn on when playing a voice. So, how come the library is checking for a HIGH? Also, it has been posted that the light turns off when playing a voice. So is the specification document wrong, ie busy pin goes high when playing a voice? I'm still waiting for a Sandisk card coz mine doesn't work.

The busy pin goes high when sound is playing.

Thanks - whoever wrote that specification document should be shot. Anyway, I feel stupid because my micro SD card was working all along. Problem was that I was simply sliding the card into the slot - like what you do with the big SD cards and some micro slots with press-to-eject. Turns out I have to open the latch, put the card in, then close and lock the latch :blush:. So now I have 2 Sandisk cards coming which I don't need. I might have to buy 2 more modules so I can use them :grin:.

That's silly. SD cards are as good as flash drives for storing backup PC files. They take less space and many of the full size ones have a write-protect tab which I have yet to see on a USB flash stick.

They're removable media, the new paper. I have AVI movies on some.

Especially micro-SD, you can get cheap USB adapters for those. Otherwise you need a media reader. They go great in phones to cameras to MP3 players to whatever if you get the right size, I even had a camera and MP3 player that took full size SD cards.

Get the micro-SD's with full-size adapters and you can turn an adapter into an SD reader for Arduino by soldering right to the tabs. Hardest part is the 5V to 3.3V leveling which you can get plenty of help with right here and learn maybe 3 or 4 ways to do that cheap!

New to this - but I seem to be progressing.

  1. You need >3.5V for the module from a source that can give 100mA while it talks without dropping out.
  2. WAV files play OK. I have a set of numbers that are very clear, others seem distorted. Will work on that.
  3. NB! as delivered 2 of the pins were dry solder jointed to the card!!!!! - Scratch off the paint round the pin and resolder.
  4. An old Sandisk 2GB worked for a while off the Arduino 3V - today it stopped.
  5. New identical Sandisks also failed on the Arduino supply - but all OK now on the beefy supply
  6. Kingston 2GB failed on any power supply