Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

There are similar projects where a PCM1808 ADC is used to connect an analog audio source, run through an ESP32 with Audio Tools and output to a PCM5102 DAC and stereo amp. But the information is a bit scattered and lacking in detail so I created this little setup complete with image, code and schematic. If you follow this exactly, music will flow and all is golden.

Sketch

 /**
 * @file streams-i2s-i2s-2.ino
 * @brief Copy audio from I2S to I2S: We use 2 different i2s ports!
 * @author Phil Schatzmann
 * @copyright GPLv3
 */

#include "AudioTools.h"
 
AudioInfo info_in(44100, 2, 32);
AudioInfo info_out(44100, 2, 32);
I2SStream in;
I2SStream out;
//NumberFormatConverterStream nfc(out);    //**did not work**
//StreamCopy copier(nfc, in);              //**did not work**
StreamCopy copier(out, in); // copies sound into i2s

// Arduino Setup
void setup(void) {  
  // Open Serial 
  Serial.begin(115200);
  // change to Warning to improve the quality
  AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning); 

  //nfc.begin(32,16);    //**did not work**

  // start I2S in - (PC soundcard  -> PCM1808)
  Serial.println("starting I2S...");
  auto config_in = in.defaultConfig(RX_MODE);
  config_in.copyFrom(info_in); 
  config_in.i2s_format = I2S_STD_FORMAT;
  config_in.is_master = true;
  config_in.port_no = 0;
  config_in.pin_bck = 18;
  config_in.pin_ws = 21;
  config_in.pin_data = 19;
  config_in.pin_mck = 3;
  in.begin(config_in);

  // start I2S out - (PCM5102 -> stereo amp)
  auto config_out = out.defaultConfig(TX_MODE);
  config_out.copyFrom(info_out); 
  config_out.i2s_format = I2S_STD_FORMAT;
  config_out.is_master = true;
  config_out.port_no = 1;
  //config_out.bits_per_sample = 16;    //**did not work**
  config_out.bits_per_sample = 32;
  config_out.pin_bck = 25;
  config_out.pin_ws = 13;
  config_out.pin_data = 26;
  out.begin(config_out);

  Serial.println("I2S started...");
}

// Arduino loop - copy sound to out 
void loop() {
  copier.copy();
}

The PCM1808 board is a generic ebay item while the PCM5102 is from Adafruit. Note, I tried to convert the 32-bit input from PCM1808 to a 16-bit depth for the PCM5102 but all I got was silence so not sure why it did not work. See the commented lines in sketch. Ignore the potentiometer connections, they are leftover from a previous project.

ADC-PCM1808-DAC-PCM5102

schematic

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.