Initialization that runs just once before the first sleep consists of:
Code: Select all
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(ADC1_GPIO32_CHANNEL, ADC_ATTEN_DB_11);
adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, VREF, adc_chars);
adc_power_off();
Code: Select all
adc_power_on();
esp_adc_cal_get_voltage(ADC1_GPIO32_CHANNEL, adc_chars, &V_raw);
adc_power_off();