ADC reads fail when running I2S

Posts: 2
Joined: Thu Jan 14, 2021 9:09 pm

ADC reads fail when running I2S

Postby JoeCool » Thu Jan 14, 2021 9:14 pm

How to read analog data from one ADC1 channel via I2S and also read data from other ADC1 pins? Reading ADC data from one channel via I2S works fine, but as soon as I2S is initialized all other ADC1 pins read 4095 only.
What is the correct handling to achieve reading from multiple ADC pins?
Can't use ADC2 because of wifi.
Thank you for your help!

Code excerpt:

Code: Select all

Serial.println(analogRead(34));  // prints the correct ADC value of GPIO 34 / ADC1 Channel 6
i2s_config_t i2s_config = {
    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN),
    .sample_rate = 8000,
    .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .communication_format = I2S_COMM_FORMAT_I2S_LSB,
    .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
    .dma_buf_count = 2,
    .dma_buf_len = AUDIOBUF_SIZE,
    .use_apll = false,
    .tx_desc_auto_clear = false,
    .fixed_mclk = 0};
//install and start i2s driver
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);

//init ADC pad
i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_0);	 // GPIO 36 / ADC1 Channel 0

// enable the ADC

Serial.println(analogRead(34));  // now prints always 4095

Who is online

Users browsing this forum: ms71de and 33 guests