Skip to content

I2S PDM tx mode is not working on ESP32 (works on at least ESp32S3 instead) #2064

@paolo960

Description

@paolo960

Problem Description

For ESP32 regular, PDM tx mode is not included in /src/AudioToolsConfig.h. Only PDMrx is supported.
Solved adding on row 282

FROM

// ----- Regular ESP32 -----
#if defined(ESP32) && !defined(ESP32X) && !defined(CONFIG_IDF_TARGET_ESP32H2)

if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)

define USE_INT24_FROM_INT

#endif

TO

// ----- Regular ESP32 -----
#if defined(ESP32) && !defined(ESP32X) && !defined(CONFIG_IDF_TARGET_ESP32H2)

define USE_PDM // added on 5/6/2025

if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)

define USE_INT24_FROM_INT

#endif

ArduinoMonitorReport.pdf

Device Description

Tested on ESP32devBoard

Sketch

/**
 * @file streams-generator-i2s.ino
 * @author Phil Schatzmann
 * @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-generator-i2s/README.md 
 * @copyright GPLv3
 */
 
#include "AudioTools.h"

AudioInfo info(44100, 2, 16);
SineWaveGenerator<int16_t> sineWave(32000);                // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound(sineWave);             // Stream generated from sine wave
I2SStream out; 
StreamCopy copier(out, sound);                             // copies sound into i2s

// Arduino Setup
void setup(void) {  
  // Open Serial 
  Serial.begin(115200);
  while(!Serial);
  delay(5000);
  AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Error);

  // start I2S
  Serial.println("starting I2S...");
  auto config = out.defaultConfig(TX_MODE);
  config.copyFrom(info); 
  config.pin_ws  = -1;   
  config.pin_bck = 7;                                       
  config.pin_data= 8;                                    
  config.signal_type=PDM;
  out.begin(config);

  // Setup sine wave
  sineWave.begin(info, N_B4);
  Serial.println("started...");
}

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

Other Steps to Reproduce

No response

What is your development environment (incl. core version info)

Arduino 1.8.19, ESP32 package 3.2.0, audio-tools release v1.1.0 stable

I have checked existing issues, discussions and online documentation

  • I confirm I have checked existing issues, discussions and online documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions