Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Audio & Sound Modules

PCM5102 I2S DAC Module: Crystal Clear Audio for ESP32

PCM5102 I2S DAC Module: Crystal Clear Audio for ESP32

March 11, 2026 /Posted byJayesh Jain / 1

PCM5102 I2S DAC Module: Crystal Clear Audio for ESP32

The PCM5102 I2S DAC module delivers audiophile-grade audio quality from ESP32, Raspberry Pi, and other microcontrollers. With 32-bit resolution, 384kHz sample rate, and an exceptional 106dB dynamic range, the PCM5102 from Texas Instruments produces crystal clear audio that rivals dedicated audio players costing thousands of rupees. This guide covers complete setup, firmware, music streaming, and Internet radio builds for Indian ESP32 projects.

Table of Contents

  1. PCM5102 Specifications and Why It Matters
  2. ESP32 I2S Wiring and Pin Configuration
  3. Arduino IDE Setup and Basic Playback
  4. Playing WAV and MP3 Files from SPIFFS
  5. Internet Radio Streaming Over WiFi
  6. Audio Quality Optimization
  7. PCM5102 vs MAX98357 vs WM8960
  8. Frequently Asked Questions

PCM5102 Specifications and Why It Matters

The PCM5102A is a premium audio DAC (Digital-to-Analog Converter) that transforms I2S digital audio into analog voltage for headphones and amplifiers. Unlike the MAX98357 (which has an integrated amplifier but lower dynamic range), the PCM5102 focuses purely on conversion quality.

  • Dynamic Range: 106dB (A-weighted) — exceptional for a ₹250-450 module
  • THD+N: -93dB (0.0007%) — inaudible distortion
  • Sample Rates: 8kHz to 384kHz
  • Bit Depth: 16/24/32-bit
  • Output: Line-level analog (2Vrms) — requires external amplifier for speakers
  • Interface: Standard I2S (no I2C control — configuration via hardware pins)
  • Supply: 3.3V digital, 3.3V analog (separate decoupled supplies on good modules)
  • India module price: ₹250-450

The PCM5102’s hardware-pin configuration is both a simplicity advantage (no software configuration) and a limitation (no runtime adjustments). Most breakout boards set it to standard 24-bit I2S mode, which works perfectly with ESP32.

ESP32 I2S Wiring and Pin Configuration

/* PCM5102 DAC Module → ESP32 Wiring
 *
 * PCM5102 Pin  → ESP32 Pin    Description
 * VCC          → 3.3V         Power (NOT 5V!)
 * GND          → GND          Ground
 * BCK (BCLK)   → GPIO 26      Bit Clock
 * LCK (LRCK)   → GPIO 25      Word Select / Frame Clock
 * DIN          → GPIO 22      I2S Data In (to DAC)
 * FMT          → GND          I2S format (standard left-justified)
 * XSMT         → 3.3V         Soft mute (HIGH = unmuted)
 * SCK          → GND or NC    System clock (usually NC on modules)
 *
 * Audio Output:
 * OUT_L        → Amplifier left channel input
 * OUT_R        → Amplifier right channel input
 * GND          → Amplifier ground
 *
 * For headphone output (no amplifier):
 * OUT_L/R directly to 3.5mm jack (OK for headphones, low volume for speakers)
 */

Recommended Product

AI Thinker ESP32-A1S WiFi+BT Audio Development Board
All-in-one ESP32 audio board with built-in codec, amplifier, and microphone — a complete alternative to ESP32 + PCM5102 combo for standalone audio projects.
Category: Audio & Sound Modules

Arduino IDE Setup and Basic Playback

// PCM5102 Basic I2S Tone Generation on ESP32
// Arduino IDE: Install ESP32 board support from Espressif
// Library: No external library needed — using built-in ESP-IDF I2S

#include <driver/i2s.h>

// I2S pin configuration (match your wiring)
#define I2S_BCK_PIN  26
#define I2S_LRCK_PIN 25
#define I2S_DOUT_PIN 22

// I2S configuration
const i2s_config_t i2s_config = {
  .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX),
  .sample_rate = 44100,
  .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
  .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // Stereo
  .communication_format = I2S_COMM_FORMAT_STAND_I2S,
  .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
  .dma_buf_count = 8,
  .dma_buf_len = 64,
  .use_apll = true, // Use APLL for more accurate clock (better audio)
  .tx_desc_auto_clear = true
};

const i2s_pin_config_t pin_config = {
  .bck_io_num = I2S_BCK_PIN,
  .ws_io_num = I2S_LRCK_PIN,
  .data_out_num = I2S_DOUT_PIN,
  .data_in_num = I2S_PIN_NO_CHANGE // No input (DAC only)
};

void setup() {
  Serial.begin(115200);
  
  // Initialize I2S
  i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
  i2s_set_pin(I2S_NUM_0, &pin_config);
  i2s_zero_dma_buffer(I2S_NUM_0);
  
  Serial.println("PCM5102 I2S DAC initialized at 44100Hz/16-bit stereo");
}

// Generate a 440Hz sine wave test tone
void loop() {
  const int FREQ = 440; // A4 note
  const int SAMPLE_RATE = 44100;
  const int SAMPLES_PER_CYCLE = SAMPLE_RATE / FREQ; // 100 samples
  const float AMPLITUDE = 0.5; // 50% volume
  
  static int16_t sineBuffer[200]; // Buffer for one full cycle
  
  // Pre-compute sine wave
  for (int i = 0; i < SAMPLES_PER_CYCLE; i++) {
    float angle = 2.0 * PI * i / SAMPLES_PER_CYCLE;
    sineBuffer[i] = (int16_t)(sin(angle) * 32767.0 * AMPLITUDE);
  }
  
  // Write to I2S (interleaved stereo: L, R, L, R...)
  size_t bytesWritten;
  int16_t stereoBuffer[SAMPLES_PER_CYCLE * 2];
  for (int i = 0; i < SAMPLES_PER_CYCLE; i++) {
    stereoBuffer[i*2] = sineBuffer[i];   // Left channel
    stereoBuffer[i*2+1] = sineBuffer[i]; // Right channel (same for mono tone)
  }
  
  i2s_write(I2S_NUM_0, stereoBuffer, 
            SAMPLES_PER_CYCLE * 2 * sizeof(int16_t),
            &bytesWritten, portMAX_DELAY);
}

Playing WAV and MP3 Files from SPIFFS

ESP32’s SPIFFS (SPI Flash File System) can store audio files up to ~1.5MB in the 4MB flash. For longer audio, use SD card.

// Play WAV file from SPIFFS using ESP32-audioI2S library
// Library install: PlatformIO: earlephilhower/ESP32-audioI2S
// Or: https://github.com/schreibfaul1/ESP32-audioI2S

#include "Audio.h"
#include "SPIFFS.h"

// PCM5102 pins
#define I2S_DOUT 22
#define I2S_BCLK 26
#define I2S_LRC  25

Audio audio;

void setup() {
  Serial.begin(115200);
  
  // Mount SPIFFS
  if (!SPIFFS.begin(true)) {
    Serial.println("SPIFFS mount failed!");
    return;
  }
  
  // Initialize audio with PCM5102 pins
  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
  audio.setVolume(17); // 0-21 scale
  
  // Play WAV from SPIFFS
  // Upload file via Arduino IDE: Sketch → Upload Files
  audio.connecttoFS(SPIFFS, "/welcome.wav");
}

void loop() {
  audio.loop(); // Must be called continuously
}

// Callbacks (optional but useful)
void audio_info(const char *info) {
  Serial.print("Audio info: "); Serial.println(info);
}
void audio_eof_mp3(const char *info) {
  Serial.println("Track ended");
  // Play next track here
}

Internet Radio Streaming Over WiFi

One of the most impressive ESP32 + PCM5102 applications is Internet radio — streaming MP3 or AAC audio from online stations like Radio Mirchi, AIR (All India Radio), or international streams. The ESP32-audioI2S library handles HTTP streaming natively.

// ESP32 Internet Radio with PCM5102
// Streams live audio from Indian/international radio stations

#include "Audio.h"
#include <WiFi.h>

#define I2S_DOUT 22
#define I2S_BCLK 26
#define I2S_LRC  25

const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";

// Indian Radio Stream URLs (update as needed)
const char* stations[] = {
  "http://air.pc.cdn.bitgravity.com/air/live/pbaudio001/playlist.m3u8", // AIR National
  "http://prclive1.listenon.in:9960/",  // Radio City Mumbai
  "https://stream.zeno.fm/r0zy9rr6ztzuv", // Radio Mirchi 98.3
};
int currentStation = 0;

Audio audio;

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  
  Serial.print("Connecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500); Serial.print(".");
  }
  Serial.print("nConnected! IP: ");
  Serial.println(WiFi.localIP());
  
  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
  audio.setVolume(18);
  
  // Start streaming first station
  audio.connecttohost(stations[currentStation]);
  Serial.println("Internet Radio Started!");
}

void loop() {
  audio.loop();
  
  // Serial command to change station
  if (Serial.available()) {
    char cmd = Serial.read();
    if (cmd == 'n') { // Next station
      currentStation = (currentStation + 1) % 3;
      audio.connecttohost(stations[currentStation]);
      Serial.print("Switched to station: "); Serial.println(currentStation);
    }
    if (cmd == '+') { // Volume up
      int vol = audio.getVolume();
      audio.setVolume(min(21, vol + 1));
    }
    if (cmd == '-') { // Volume down
      int vol = audio.getVolume();
      audio.setVolume(max(0, vol - 1));
    }
  }
}

Recommended Product

Mini Digital Amplifier Module — 3W Dual Track
Pair PCM5102 line output with this compact Class D amplifier for a complete Internet radio speaker system. Drives 4Ω-8Ω speakers directly.
Category: Audio & Sound Modules

Audio Quality Optimization

Use APLL (Audio PLL) for Accurate Sample Rate

ESP32’s main PLL is optimized for CPU speed, not audio. Set use_apll = true in i2s_config to use the dedicated audio PLL. This eliminates jitter-induced audio artifacts that cause subtle harshness in high-quality audio.

DMA Buffer Tuning

Too few DMA buffers = audio dropouts; too many = added latency. For streaming audio (radio), use dma_buf_count = 16, dma_buf_len = 128. For low-latency applications (audio feedback, VoIP), use dma_buf_count = 4, dma_buf_len = 32.

Power Supply Decoupling

PCM5102 has separate analog (AVDD) and digital (DVDD) supply pins. Quality modules route these separately with 10µF + 100nF bypass capacitors on each. Poor power supply = audible hiss and hum. Use a linear regulator (AMS1117-3.3) instead of switching regulator for the PCM5102 AVDD supply for lowest noise floor.

PCM5102 vs MAX98357 vs WM8960

Feature PCM5102 MAX98357 WM8960
Dynamic Range 106dB 77dB 98dB
Integrated Amp No (line out only) Yes (3W Class D) Yes (40mW HP + 1W SPK)
Microphone Input No No Yes (full duplex)
India Price ₹250-450 ₹150-300 ₹400-700
Best For HiFi music, Internet radio Smart speakers, Bluetooth Voice assistants, recording

Recommended Product

INMP441 MEMS Microphone for ESP32
Add voice input to your PCM5102 project — ESP32 handles I2S from both INMP441 (receive) and PCM5102 (transmit) simultaneously for a full voice assistant build.
Category: Audio & Sound Modules

Frequently Asked Questions

Q: Does PCM5102 work with ESP8266?

A: ESP8266 lacks hardware I2S support and has insufficient RAM/processing power for real-time audio decoding. For audio projects, ESP32 is the recommended platform. ESP32’s dual-core 240MHz processor and hardware I2S peripheral are essential for stutter-free music streaming.

Q: Can I connect PCM5102 directly to headphones?

A: Yes — PCM5102 outputs 2Vrms line level, which is sufficient to drive standard headphones (32Ω or higher impedance). Volume will be lower than a dedicated headphone amplifier. For low-impedance in-ear monitors, add a small headphone buffer (NE5532 op-amp) to prevent loading effects that degrade frequency response.

Q: I hear a “ticking” or clicking noise from PCM5102. How to fix?

A: Common causes: (1) I2S clock synchronization issues — ensure ESP32 is master and PCM5102 slave, (2) DMA underrun — increase dma_buf_count from 4 to 8+, (3) CPU task competing with I2S — run audio in dedicated FreeRTOS task pinned to Core 0, (4) Insufficient power decoupling — add 100µF capacitor directly on PCM5102 VCC pins.

Q: How do I play Bollywood MP3 files from SD card?

A: Use ESP32-audioI2S library with SD card: audio.connecttoSD("/bollywood.mp3");. Format SD card as FAT32, place MP3 files in root. ESP32 supports SD via SPI (slower, 4 pins) or SDMMC (faster, 6 pins). For highest quality, use 320kbps MP3 files and set sample rate to 44100Hz.

Q: What amplifier should I pair with PCM5102 for room-filling sound?

A: For 5-10W (bedroom/small room), pair with PAM8610 stereo 10W Class D amplifier module (₹120-200). For 20-50W (living room), use TPA3116 50W module (₹350-600). Connect PCM5102 line out → amplifier input → 4Ω or 8Ω speakers. This combination produces audiophile-quality sound for under ₹1500 total cost in India.

Shop I2S DAC and Audio Modules at Zbotic.in
Tags: ESP32 audio, ESP32 music player, I2S Audio, I2S DAC, Internet radio ESP32, PCM5102, PCM5102 ESP32
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Time-Lapse Camera Project Usin...
blog time lapse camera project using esp32 cam and sd card 599480
blog bom management in kicad and easyeda export for jlcpcb 599484
BOM Management in KiCad and Ea...

Related posts

Svg%3E
Read more

Audio Oscillator: 555 Timer Tone Generator Projects

April 1, 2026 0
Table of Contents 555 Timer as Audio Oscillator Astable Mode for Continuous Tones Frequency Calculation and Control Tone Generator Projects... Continue reading
Svg%3E
Read more

Doorbell Chime: Custom Sound with Arduino and Speaker

April 1, 2026 0
Table of Contents Custom Arduino Doorbell Generating Musical Tones MP3 Doorbell with DFPlayer Wireless Doorbell with ESP32 Complete Doorbell Build... Continue reading
Svg%3E
Read more

Music Reactive Fountain: Water Dance with Arduino

April 1, 2026 0
Table of Contents Music-Driven Water Fountains Pumps, Valves, and Audio Input Audio-to-Pump Control Circuit Arduino Fountain Controller Code Building the... Continue reading
Svg%3E
Read more

Sound Direction Finder: Microphone Array Localization

April 1, 2026 0
Table of Contents Sound Source Localisation Time Difference of Arrival (TDOA) Microphone Array Design Direction Finding Algorithm Practical Applications FAQ... Continue reading
Svg%3E
Read more

Audio AGC Circuit: Automatic Volume Level Control

April 1, 2026 0
Table of Contents What Is Automatic Gain Control? AGC Theory and Applications Analog AGC with OTA Digital AGC with Arduino... Continue reading

One comment

  • Avatar of Invictre

    Invictre

    March 15, 2026 - 9:44 pm

    Hello, this article is Great, you prove that PCM5102 is good for doing DIY MP3, this article is the one I’m looking for, but my question is, if i integrated DFPlayer for the storage, is that Viable?

    Reply

Add comment Cancel reply

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

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now