ESP32 I2C along with analogue read not working. How to fix it?
I had similar issue when I used BLE and analogread together. 

Try the following function if you use arduino-core. 
Use adc2_config_channel_atten function ifyou are usung esp-idf

int new_analogRead(int pin){
  int value = 0;
  int8_t channel = digitalPinToAnalogChannel(pin);
  if(channel &lt; 0){
      return 0;//not adc pin
  }
  if(channel &gt; 7){    //ADC2
    adc2_config_channel_atten(adc2_channel_t(channel-10),ADC_ATTEN_11db);//11dB attenuation (ADC_ATTEN_11db) gives full-scale voltage 3.9V
    adc2_get_raw(adc2_channel_t(channel-10), ADC_WIDTH_BIT_10, &amp;value);
    //used chanel-10 based on gpioMUX in esp32-hal-gpio
    return value;
  } else {//ADC1- not required
      // while (GET_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_DONE_SAR) == 0); //wait for conversion
      // value = GET_PERI_REG_BITS2(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_DATA_SAR, SENS_MEAS1_DATA_SAR_S);
      return 0;
  }
}