Tuesday, 21 June 2016

Playing audio with a WTV020M01 and Arduino

There are quite a few posts on the interwebs about these little audio playback devices.
First up, they're not always accurately described. We bought a few to try out, based on the idea that they were "mp3 playback modules" (according to the Chinese seller on eBay).
It turns out that the M01 version of the module (although there are -SD versions which may work differently) uses a proprietary format, .ad4

This is a highly-compressed audio format - but one that plays surprisingly well from such a little device! At least as well as our PIC-based audio-players (though at twice the price, I should think so too!). Now a lot of people online have complained that these are picky little devices, some people can't get them to work at all and some just call them sh!te and buy an Adafruit wavshield.

With some trepidation, we wired our little device up to a breadboard.
Although the title of this post suggests an Arduino is involved, to get it to actually play sounds, you don't even need a microcontroller - just some power and a ground connection to the "play" pin on the module.

In the fullness of time, we'll try playing specific files using the SPI interface, but for now we just wanted to hear the little module make some noise. The first thing to ensure is that the correct voltage jumper is set. We suspect that many of the people who simply said these things don't work probably missed this important step!

(see that big blob of solder? We added that, to make it work from a 3.3v supply)

We're using 2Gb Sandisk microSD cards - again off a cheap Chinese seller off eBay, so there's no guarantee that they're genuine; but they worked first time (so maybe they are). To make sure any potential problems were not down to us using the wrong audio format, we downloaded some sample .ad4 files from http://www.buildcircuit.com/how-to-convert-mp3-and-wav-files-to-ad4-format-wtv020sd-tutorial/ and simply dragged-and-dropped them onto the SD card.

Then connected a speaker directly to the SPK+/- PWM pins and added power. The busy line sinks to ground when the device is not playing, so we stuck an LED on there -  and that was it. Pull the "play/pause" line low to make it start playing. No microcontroller needed - just poke a wire into a hole for the same effect.

That'll do us for now.
What was really impressive was the volume of the audio, straight from the pwm pins - no need for an additional amplifier or even a transistor/capacitor combination (as we favoured in our PIC-based audio module). Just pop a speaker onto the pins and off you go!

According to the datasheet, you can use a simple SPI interface to send commands to the module.
If the files are stored with the filenames 0000.ad4, 0001.ad4, 0002.ad4 etc. then you can use the next/prev pins to skip between files. Commands include:

0xFFFF - stop the device
0xFFFE - play/pause toggle
0xFFF7 - set volume to 7

alternatively, simply send 0x0000 to play file 0000.ad4, 0x0001 to play file 0001.ad4 and so on.
As it's late, we'll have to investigate that in the morning.......