ADC with Deep Sleep
Posted: Wed Feb 05, 2020 4:04 pm
Hello. I am trying to implement ADC read with the ESP32 periodically going into deep sleep. Will esp_adc_cal_get_voltage() give the correct voltage reading for subsequent function calls if I just initialize the ADC once before the first deep sleep cycle and then just toggle it using adc_power_on() and adc_power_off()?
Initialization that runs just once before the first sleep consists of:
Part that runs every few sleep cycles:
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();