Add Voice /Audio to projects using WTV020SD

Adding sound to your projects is great, there can be several methods to do it. In this post i will show how we can use wtv020-sd module to get this task done. I wont go in detailed description of the module and will keep the post short and to the point. The module can be operated in a number of modes including pushbutton modes but the one we are going for is the 3 wire serial mode. its actually SDA,SCL and reset wires that we use. The module would play back the ad4 files stored on uSD Card. and spk+ and spk- pins can be connected directly to a speaker. More details about the module can be found in the datasheet and the webpage link.

RECOMMENDED READ  function to return binary equivalent of an int in a string format

The interface is simple. you only need to connect Supply , DI ,CLK and reset Pins to get it working although you may also connect some other pins also but this is what is really needed to get the module working.


The timing diagrams in the datasheet can be used to write the program. I will share the code I use for this module.
below is the code .


#define SCL 4                 //serial clock
#define SDA 5                 //serial data
#define RST 3                 //audio module reset
/*=============================Delay functions starts==========================*/
void delayus(unsigned int usec)  // Function to provide time delay in us.
  int i,j;
  for(i=0;i 0; mask >>= 1)
    if (value & mask) PORTC|=(1< <sda); else="" portc&="~(1<<sda);" delayus(200);="" portc|="(1<<scl);" }="" delayms(2);="" stop="" bit="" indication="" void="" init_audio()="" {="" reseting="" the="" module="" delayms(100);="" delayms(10);="" delayms(300);="" send_audio(0xfff7);="" to="" set="" maximum="" sound="" <="" pre="">

Here is an example code to play file 0005.ad4 for 5 secs and then stops the file and start playing file 0001.ad4.

        send_audio(0xFFFF); //stop playing


To convert your audio files to AD4 format you can use the tool provided by waytronics. Get the converter and Sample files from the zip file HERE


Dost Muhammad Shah

Dost Muhammad specializing in Embedded Design, Firmware development, PCB designing , testing and prototyping. He enjoys sharing his experience with others .Get in touch with Dost on Twitter or via Contact form


4 thoughts on “Add Voice /Audio to projects using WTV020SD

    1. This is an old post. I am not sure if I have the exact file. Let me know the issues that you are facing and I might help to fix them

  1. what will be the design of EVM for atmega 32 microcontroller…. using 16*2 Lcd?…..Do i need to change anything in the code? that u have given?
    I have tried this 'code and design' for atmega 32 with LMO16L but it didn't work….. so what should i do??

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.