Contents

Interfacing UDA1334A I2S Stereo Decoder Module with ESP32

interfacing UDA1334A with Arduino

UDA1334A I2S Stereo Decoder Module Features

The UDA1334A is a versatile digital-to-analog converter (DAC) known for its exceptional audio performance. Its key property lies in its ability to deliver high-fidelity sound reproduction, making it a preferred choice for audio enthusiasts and professionals alike. The DAC supports a wide range of sampling frequencies, ensuring accurate and detailed audio playback.

Download the datasheet of ADS1015 module below.

UDA1334A I2S Pinout

The ADS1015 ADC Module has 14 pins:

  • 5V: Power supply input (5V)
  • 3.3V: Power supply input (3.3V)
  • GND: Ground reference for the IC
  • LRC (Left/Right Clock): Input for left/right channel identification
  • DOUT (Data Out): Serial Data Output for transmitting converted analog signals
  • BCLK (Bit Clock): Input for synchronizing data transmission
  • LOUT (Left Channel Output): Analog audio output for the left channel
  • AGND (Analog Ground): Ground for internal analog reference
  • ROUT (Right Channel Output): Analog audio output for the right channel
  • SCLK (System Clock): Input for system clock synchronization
  • SF0 and SF1 (Digital Filter Select): Inputs for selecting digital filter options. SF0 and SF1 are used to set the input data format. By default, both are pulled Low for I2S but you can change them around for alternate formats.
  • MUTE: Input for muting the audio output
  • PLL (Phase-Locked Loop): Input for external clock synchronization
  • DEEM (De-emphasis): Input for de-emphasis control

You can see the pinout of this module in the image below.

Required Materials

Interfacing UDA1334A ADC Module with Arduino

Step 1: Circuit

The following circuit shows how you should connect ESP32 to this module. Connect wires accordingly.

Step 2: Installing Library

First, install the following library on Arduino IDE.

https://github.com/schreibfaul1/ESP32-audioI2S

Step 3: Code

Upload the following code to your ESP32.

				
					//**********************************************************************************************************
//*    audioI2S-- I2S audiodecoder for ESP32,                                                              *
//**********************************************************************************************************
//
// first release on 11/2018
// Version 3  , Jul.02/2020
//
//
// THE SOFTWARE IS PROVIDED "AS IS" FOR PRIVATE USE ONLY, IT IS NOT FOR COMMERCIAL USE IN WHOLE OR PART OR CONCEPT.
// FOR PERSONAL USE IT IS SUPPLIED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR
// OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
//

#include "Arduino.h"
#include "WiFiMulti.h"
#include "Audio.h"
#include "SPI.h"
#include "SD.h"
#include "FS.h"

// Digital I/O used
#define SD_CS          5
#define SPI_MOSI      23
#define SPI_MISO      19
#define SPI_SCK       18
#define I2S_DOUT      25
#define I2S_BCLK      27
#define I2S_LRC       26

Audio audio;
WiFiMulti wifiMulti;
String ssid =     "xxxxx";
String password = "xxxxx";


void setup() {
    pinMode(SD_CS, OUTPUT);      digitalWrite(SD_CS, HIGH);
    SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
    SPI.setFrequency(1000000);
    Serial.begin(115200);
    SD.begin(SD_CS);
    WiFi.mode(WIFI_STA);
    wifiMulti.addAP(ssid.c_str(), password.c_str());
    wifiMulti.run();
    if(WiFi.status() != WL_CONNECTED){
        WiFi.disconnect(true);
        wifiMulti.run();
    }
    audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
    audio.setVolume(12); // 0...21

//    audio.connecttoFS(SD, "/320k_test.mp3");
//    audio.connecttoFS(SD, "test.wav");
//    audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u");
//    audio.connecttohost("http://macslons-irish-pub-radio.com/media.asx");
//    audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.aac"); //  128k aac
      audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.mp3"); //  128k mp3
}

void loop()
{
    audio.loop();
    if(Serial.available()){ // put streamURL in serial monitor
        audio.stopSong();
        String r=Serial.readString(); r.trim();
        if(r.length()>5) audio.connecttohost(r.c_str());
        log_i("free heap=%i", ESP.getFreeHeap());
    }
}

// optional
void audio_info(const char *info){
    Serial.print("info        "); Serial.println(info);
}
void audio_id3data(const char *info){  //id3 metadata
    Serial.print("id3data     ");Serial.println(info);
}
void audio_eof_mp3(const char *info){  //end of file
    Serial.print("eof_mp3     ");Serial.println(info);
}
void audio_showstation(const char *info){
    Serial.print("station     ");Serial.println(info);
}
void audio_showstreamtitle(const char *info){
    Serial.print("streamtitle ");Serial.println(info);
}
void audio_bitrate(const char *info){
    Serial.print("bitrate     ");Serial.println(info);
}
void audio_commercial(const char *info){  //duration in sec
    Serial.print("commercial  ");Serial.println(info);
}
void audio_icyurl(const char *info){  //homepage
    Serial.print("icyurl      ");Serial.println(info);
}
void audio_lasthost(const char *info){  //stream URL played
    Serial.print("lasthost    ");Serial.println(info);
}

				
			

After uploading, the ESP32 will establish a connection to the Radio Server and initiate the playback of songs.

Liked What You See?​
Get Updates And Learn From The Best​

Comments (2)

  • Clovis Fritzen Reply

    Hi, your code does not compile, every function is missing its “()”. Also when fixing this it still does not compile, says “sketch too big”.

    October 23, 2024 at 10:59 am
    • Mohammad Damirchi Reply

      Hi Clovis,
      Thanks for your feedback.
      The code has been updated. Please install the necessary library first, then compile the code. Let me know if you encounter any issues.

      October 27, 2024 at 3:11 pm

Leave a Reply

Your email address will not be published. Required fields are marked *