TESEไมคฺ์ — ESP32-S3 simulation

An interactive ESP32-S3 circuit simulation you can run free in your browser on Velxio, by aekkachai-c2545.

Sketch code

#include <driver/i2s.h>

#define I2S_PORT      I2S_NUM_0
#define I2S_SCK       9   
#define I2S_WS        8   
#define I2S_DIN       6   

void setupI2S() {
  i2s_config_t i2s_config = {
    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
    .sample_rate = 16000,
    .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .communication_format = I2S_COMM_FORMAT_I2S,
    .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
    .dma_buf_count = 4,
    .dma_buf_len = 512,
    .use_apll = false,
    .tx_desc_auto_clear = false,
    .fixed_mclk = 0
  };

  i2s_pin_config_t pin_config = {
    .bck_io_num = I2S_SCK,
    .ws_io_num = I2S_WS,
    .data_out_num = I2S_PIN_NO_CHANGE,
    .data_in_num = I2S_DIN
  };

  i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
  i2s_set_pin(I2S_PORT, &pin_config);
  i2s_start(I2S_PORT);
}

void setup() {
  Serial.begin(115200);
  delay(1000);
  setupI2S();
  Serial.println("Debug Raw Audio Ready!");
}

void loop() {
  int16_t buffer[16];
  size_t bytesRead = 0;
  i2s_read(I2S_PORT, &buffer, sizeof(buffer), &bytesRead, portMAX_DELAY);
  
  // พิมพ์ค่าดิบตัวแรกในบัฟเฟอร์ออกมาดูตรงๆ
  Serial.print("Bytes: "); Serial.print(bytesRead);
  Serial.print("\t| Raw Buffer[0]: "); Serial.println(buffer[0]);

  delay(200);
}

More projects by aekkachai-c2545