Configure A2DP Soruce Profile: send data from ADC input

gguereque
Posts: 3
Joined: Wed Mar 25, 2020 7:03 pm

Configure A2DP Soruce Profile: send data from ADC input

Postby gguereque » Wed Mar 25, 2020 7:09 pm

Hello,

I'm fairly new to the ESP32 environment and i would like to know if there is a way through menuconfig an option to enable A2DP to take data from ADC channel

Right now what i'm doing is modifying the a2dp_source example. Especifically the data_cb function like so:

Code: Select all

static int32_t bt_app_a2d_data_cb(uint8_t *data, int32_t len)
{
    if (len < 0 || data == NULL) {
        return 0;
    }

    // generate random sequence
  for (int i = 0; i < (len >> 1); i++) {
         int val = adc1_get_raw(ADC1_CHANNEL_0);
       //  val = ((val << 4) & (uint16_t)0xFFF0) | ((val>> 8) & (uint16_t)0x000F);
          data[(i << 1)] = val & 0xff;
          data[(i << 1) + 1] = (val >> 8) & 0xff;

    }

    vTaskDelay( pdMS_TO_TICKS( 1 ) );

    return len;
}
However there are all types of glitches and noises and i'm not able to hear mid-low and low frequencies (probably because of the stack size, which i have modified and notice no change at all)

Is there a better way to do this?

Thank you!!

ESP_Sprite
Posts: 9016
Joined: Thu Nov 26, 2015 4:08 am

Re: Configure A2DP Soruce Profile: send data from ADC input

Postby ESP_Sprite » Thu Mar 26, 2020 10:54 am

Note that it's possible (and probably better) to have the I2S peripheral read the ADC. I think there are examples for that in the esp-idf example folder. (Although it's not combined with a2dp, that would be up to you.)

gguereque
Posts: 3
Joined: Wed Mar 25, 2020 7:03 pm

Re: Configure A2DP Soruce Profile: send data from ADC input

Postby gguereque » Tue Mar 31, 2020 12:52 am

@ESP_Sprite

Thank you for your answer. I will be using I2S device in the near future but this is just to get me started on how to send audio via bluetooth.

Is there any general guide or manual of a2dp interaction with ADCs or I2S audio codec devices?

Regards,

Who is online

Users browsing this forum: No registered users and 112 guests