AzureWave Thing Plus (AW-CU488) Hookup Guide

Pages
Contributors: QCPete, bboyho
Favorited Favorite 3

Example 4b: Audio Codec - Basic Input/Output

Required Materials

To follow along with this part of the tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Breadboard - Self-Adhesive (White)

Breadboard - Self-Adhesive (White)

PRT-12002
$5.50
48
SparkFun Analog MEMS Microphone Breakout - SPH8878LR5H-1

SparkFun Analog MEMS Microphone Breakout - SPH8878LR5H-1

BOB-19389
$6.95
2
Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.75
20
Speaker - 0.5W (8 Ohm)

Speaker - 0.5W (8 Ohm)

COM-09151
$2.45
Jumper Wires Premium 6" M/F Pack of 10

Jumper Wires Premium 6" M/F Pack of 10

PRT-09140
$4.50
1
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$8.95
1
Jumper Wires Premium 6" M/M Pack of 10

Jumper Wires Premium 6" M/M Pack of 10

PRT-08431
$4.50
2
SparkFun Noisy Cricket Stereo Amplifier - 1.5W

SparkFun Noisy Cricket Stereo Amplifier - 1.5W

DEV-14475
$12.50
2
SparkFun AzureWave Thing Plus - AW-CU488

SparkFun AzureWave Thing Plus - AW-CU488

DEV-19957
$49.95 $28.50
Note: Click below for a wishlist to follow along this section.

Hardware Hookup

For the following example, you will need the following connection as shown in the Fritzing diagram. The Fritzing diagram connects the input from the microphone to the left analog output. Depending on your setup, you could connect the output to two speakers instead of one. In this case, you would also connect the right analog output (i.e. pin "13" to "RIGHT IN") to the amplifier and add a second speaker (RIGHT OUT and GND) to the setup.

Fritzing Diagram

If you have not already, solder headers to the AzureWave Thing Plus (AW-CU488), MEMs microphone, and Noisy Cricket. As explained in the previous section, make sure to carefully remove any flux residue from the boards so that liquid is not trapped in the microphone or AW-CU488 module. Then strip two wires and solder the wire ends to the speaker tabs. Of course, you could solder the pins on the M/M jumper wire to the speaker tab as well without needing to strip the wires as well.

Input Microphone and Output Speaker Connected to AzureWave Thing Plus (AW-CU488)

Example Code

Let's upload the sketch to read the input from a microphone and output the signal to one speaker. From the menu, select the following: File > Examples > Examples for AW_CU488 Thing Plus (RTL8721DM) | AmebaAudioCodec > BasicInputOutput.

Or you can copy and paste the following code in the Arduino IDE. Select the correct board definition from the menu (in this case, Tools > Boards > AW-CU488 Thing Plus (RTL8721DM)). Then select the correct COM port that the board enumerated to (in this case, it was COM15). Hit upload button.

language:c
//int analog_pin = A0;  //<=== Add this line before including Audio Codec library if you are using the potiometer and  not using the value A0

#include "AudioCodec.h"

#define SAMPLECOUNT 512

int16_t buffer[SAMPLECOUNT] = {0};
unsigned int vol = 1024;

void setup() {
    Codec.setSampleRate(16000);
    Codec.begin(TRUE, TRUE);
}

void loop() {
    // if received data is avaliable and transmit data buffer is avaliable for write
    if(Codec.writeAvaliable() && Codec.readAvaliable()) {
        Codec.readDataPage(buffer, SAMPLECOUNT);    // read latest received data from buffer
        Codec.writeDataPage(buffer, SAMPLECOUNT);   // write latest data into transmit data buffer
    }
    //vol = analogRead(A0);// commented out so we do not need to connect a potentiometer
    vol = 750; // adjust this value between 0 to 1024
    vol = map(vol, 0, 1024, 0, 100);
    Codec.setOutputVolume(vol, vol);
}

Once uploaded, try blowing some air across the microphone or lightly tapping the microphone on the table. You should hear the same sound but louder on the output speaker. You will notice a small delay on the output as the sound is read in from the microphone and written out to the speakers.