What is the correct way to read an analog signal?
I have:
Code: Select all
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_DEFAULT, 0, &adc1_chars);
adc1_config_width(ADC_WIDTH_BIT_DEFAULT);
adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_DB_11);
Code: Select all
uint32_t reading = adc1_get_raw(ADC1_CHANNEL_5);
esp_adc_cal_characteristics_t *adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
uint32_t voltage = esp_adc_cal_raw_to_voltage(reading, adc_chars);