ADC calibration with VREF
Posted: Thu Jan 25, 2018 9:01 am
Hi all
I'm trying to follow the instruction on the official documentation to calibrate the ADC:
https://esp-idf.readthedocs.io/en/lates ... s/adc.html
I was able to route the internal VREF to GPIO25 and read the value with a multimeter, it's 1.146V:
Then I tried to develop a program which reads the value using ADC2:
but the value read is very different from the one I see on the multimeter (1.260V). I tried different attenuation values but the calculated voltage is always different (greater)... I also used 0db attenuation but in that case (as expected) the ADC saturates to 4095.
Am I missing something? Is this the correct way to do what is explained in the doc:
https://github.com/espressif/esp-idf/bl ... ple_main.c
but it doesn't seem to read the vref value if V_REF_TO_GPIO is defined, it only routes the value to the pin:
Thanks!
I'm trying to follow the instruction on the official documentation to calibrate the ADC:
https://esp-idf.readthedocs.io/en/lates ... s/adc.html
I was able to route the internal VREF to GPIO25 and read the value with a multimeter, it's 1.146V:
Code: Select all
ESP_ERROR_CHECK(adc2_vref_to_gpio(GPIO_NUM_25));
printf("VREF routed to ADC2, pin 25\n");
Code: Select all
ESP_ERROR_CHECK(adc2_config_channel_atten(ADC2_CHANNEL_8, ADC_ATTEN_DB_2_5));
ESP_ERROR_CHECK(adc2_vref_to_gpio(GPIO_NUM_25));
int adc2_raw_value;
ESP_ERROR_CHECK(adc2_get_raw(ADC2_CHANNEL_8, ADC_WIDTH_12Bit, &adc2_raw_value));
printf("Raw value from ADC2: %d\n", adc2_raw_value);
float voltage = 1.5 * adc2_raw_value / 4095;
printf("Voltage: %.4f\n", voltage);
Am I missing something? Is this the correct way to do what is explained in the doc:
I also gave a look to the example provided:Routing ADC reference voltage to GPIO, so it can be manually measured and entered in function esp_adc_cal_get_characteristics():
https://github.com/espressif/esp-idf/bl ... ple_main.c
but it doesn't seem to read the vref value if V_REF_TO_GPIO is defined, it only routes the value to the pin:
Code: Select all
#else
//Get v_ref
esp_err_t status;
status = adc2_vref_to_gpio(GPIO_NUM_25);
if (status == ESP_OK){
printf("v_ref routed to GPIO\n");
}else{
printf("failed to route v_ref\n");
}
fflush(stdout);
#endif