# Improving ADC121C021 or esp32's ADC sample time

**URL:** <https://forum.arduino.cc/t/improving-adc121c021-or-esp32s-adc-sample-time/1144688>\
**Category:** Networking, Protocols, and Devices\
**Created:** [July 4, 2023, 10:07pm UTC](https://forum.arduino.cc/t/improving-adc121c021-or-esp32s-adc-sample-time/1144688 "2023-07-04T22:07:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![omri1](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/omri1/32/1098793_2.png) [@omri1](https://forum.arduino.cc/u/omri1)\
**Post date:** [July 4, 2023, 10:07pm UTC](https://forum.arduino.cc/t/improving-adc121c021-or-esp32s-adc-sample-time/1144688/1 "2023-07-04T22:07:18Z")

</div>

Hi,  
I would like to improve my adc readings to its maximum capability, trying to understand if i'm there or not.  
My code using ADC121C021:

```arduino
#include <Wire.h>
 
#define ADDR_ADC121 0x50
 
#define V_REF 3.00
 
#define REG_ADDR_RESULT 0x00
#define REG_ADDR_ALERT 0x01
#define REG_ADDR_CONFIG 0x02
#define REG_ADDR_LIMITL 0x03
#define REG_ADDR_LIMITH 0x04
#define REG_ADDR_HYST 0x05
#define REG_ADDR_CONVL 0x06
#define REG_ADDR_CONVH 0x07
 
unsigned int getData;
float analogVal = 0;

void setup() {
  
  Serial.begin(115200);

  Serial.println("ADC121C021");

  Wire.begin(21, 22, 3400000);

  init_adc();

}
 
void loop() {

  read_adc();
  
}

void read_adc() {
  Wire.beginTransmission(ADDR_ADC121); // transmit to device
  Wire.write(REG_ADDR_RESULT); // get result
  Wire.endTransmission();

  Wire.requestFrom(ADDR_ADC121, 2); // request 2byte from device
  
  if (Wire.available()) {
    byte data = Wire.read(); // Read the received data
  }

}

void init_adc() {
  Wire.beginTransmission(ADDR_ADC121); // transmit to device
  Wire.write(REG_ADDR_CONFIG); // Configuration Register
  Wire.write(0x20);
  Wire.endTransmission();  
}

```

I'm using 3.4Mhz for the i2c and according to datasheet ADC121C021 supports that. Why am I getting only 5kHz?  
Using esp32(tiny pico) with this code gives me 18kHz:

```arduino
#include <esp_adc_cal.h>

#define ADC1_CHANNEL_32 ADC1_CHANNEL_4 // GPIO32
#define ADC_WIDTH ADC_WIDTH_BIT_12 // ADC resolution
#define VREF_MV 3300 // Reference voltage in millivolts

esp_adc_cal_characteristics_t adc_chars;

uint32_t mic1Value;

void setup() {
  Serial.begin(115200);

  adc1_config_width(ADC_WIDTH);
  adc1_config_channel_atten(ADC1_CHANNEL_32, ADC_ATTEN_DB_11);
  
  esp_adc_cal_value_t cal_type = esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_0, ADC_WIDTH, VREF_MV, &adc_chars);

  mic1Value = adc1_get_raw(ADC1_CHANNEL_32);

}

void loop() {

  mic1Value = adc1_get_raw(ADC1_CHANNEL_32);
  
}

```

Can I get better results?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [December 31, 2023, 10:07pm UTC](https://forum.arduino.cc/t/improving-adc121c021-or-esp32s-adc-sample-time/1144688/2 "2023-12-31T22:07:54Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
