ADC: how to configure different attenuations for channels? (solved)
Posted: Wed Apr 24, 2019 7:28 pm
Hi,
I need measure 2.5V voltage at IO_35 and 0...2V and pins 33,36,39.
So, problem is that values I've got from IO_35 is wrong...
channels & attenuation :
Looks like esp_adc_cal_characterize initializes with ADC_ATTEN_DB_6 value...
Here is output:
Calculated voltage value is wrong, I've measured and it is really 2.5V.
I need measure 2.5V voltage at IO_35 and 0...2V and pins 33,36,39.
So, problem is that values I've got from IO_35 is wrong...
channels & attenuation :
Code: Select all
static const adc_channel_t bat = ADC1_CHANNEL_5; // IO33
static const adc_channel_t one = ADC1_CHANNEL_0; // IO36
static const adc_channel_t two = ADC1_CHANNEL_3; // IO39
static const adc_channel_t vref = ADC1_CHANNEL_7; // IO35 - VREF
static const adc_atten_t atten = ADC_ATTEN_DB_6;
Code: Select all
void adc_init()
{
check_efuse();
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(bat, atten);
adc1_config_channel_atten(vref, ADC_ATTEN_DB_11);
adc1_config_channel_atten(one, atten);
adc1_config_channel_atten(two, atten);
//Characterize ADC
adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
esp_adc_cal_value_t val_type = esp_adc_cal_characterize(ADC_UNIT_1, atten, ADC_WIDTH_BIT_12, DEFAULT_VREF, adc_chars);
print_char_val_type(val_type);
}
Here is output:
Code: Select all
[2019-04-24_22:11:39]bat(IO33): bit:(3282) [1553] mV
[2019-04-24_22:11:39]one(IO36): bit:(770) [446] mV
[2019-04-24_22:11:39]two(IO39): bit:(0) [107] mV
[2019-04-24_22:11:39]vref(IO35): bit:(2940) [1402] mV