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?