Audio Codec Breakout - WM8960 Hookup Guide
Example 13: DAC Gain
This example is similar to example 10. The difference is that we are adding a trim pot to the ESP32's analog input and using the measurement to adjust the codec's DAC digital volume.
Hardware Hookup
Connect power, I2C, I2S, line input 1, trim pot, and the headphone output. Your circuit should look similar to the circuit diagram below.
If you have not already, insert a USB cable into your IoT RedBoard ESP32 and a TRS cable from your audio source (e.g. MP3 player, smartphone, or computer) into the audio connector. Then connect your headphones to the output. For those that are sensitive to sounds, you may want to hear the example output before inserting the headphones into your ears.
Upload Code
From the menu, select the following: File > Examples > SparkFun WM8960 Arduino Library > Example_13_DacGain. If you have not already, select your Board (in this case the SparkFun ESP32 IoT RedBoard), and associated COM port. Then hit the upload button.
Open the Arduino Serial Monitor and set it to 115200 baud to view the serial output. Then hit the play button on your audio source. Make sure that the volume from the audio source is turned up. You should hear some music from the headphones. Adjust the volume to your desired setting by rotating the trim pot clockwise or counterclockwise.