ADC values less than half of expected
Posted: Mon Mar 18, 2024 10:32 pm
I've got a project we're working on where we are implementing a hardware ID process, using the ADC and a GPIO for a vref. This is an ESP32_WROOM_32UE on ESP-IDF 4.3.7
Essentially we have a voltage divider that is on SENSOR_VP (GPIO36/ADC1_CHANNEL_0) and GPIO_13
The code is pretty straightforward. Sets the vref GPIO, attenuation, then gets a reading from ADC1 CH0.
The voltage on GPIO13 is 1.029v. The voltage on GPIO36 is 90mV. The expected value is around 358 ((90/1029) * 4095 = 358), however I'm only getting about 90.
When I short GPIO13 to GPIO36, to give it the full reference voltage, I expect to see 4095, but it ends up as this:
Any idea why these numbers are so far off what's expected?
Essentially we have a voltage divider that is on SENSOR_VP (GPIO36/ADC1_CHANNEL_0) and GPIO_13
The code is pretty straightforward. Sets the vref GPIO, attenuation, then gets a reading from ADC1 CH0.
Code: Select all
adc2_vref_to_gpio(GPIO_NUM_13);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_0);
adc1_config_width(ADC_WIDTH_BIT_12);
while (1)
{
int raw_val = adc1_get_raw(ADC1_CHANNEL_0);
printf("ADC value: %d\n", raw_val);
vTaskDelay(pdMS_TO_TICKS(500));
}
When I short GPIO13 to GPIO36, to give it the full reference voltage, I expect to see 4095, but it ends up as this:
Any idea why these numbers are so far off what's expected?