池子数据的更新清空问题
Posted: Fri Jul 21, 2023 8:01 am
在esp-idf v5.1,adc的池子里数据如何更新,清空。希望哪位大神帮我解答一下,万分感谢!!!
Code: Select all
#include "esp_adc_cal.h"
esp_adc_cal_characteristics_t adc_chars;
adc1_config_width(ADC_WIDTH_BIT_12); // 设置分辨率为12位
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_0); // 设置通道和增益(衰减)等级
esp_adc_cal_get_characteristics(V_REF, ADC_WIDTH_BIT_12, ADC_ATTEN_DB_0, &adc_chars); // 计算ADC校准值
Code: Select all
uint32_t adc_reading = 0;
for (int i = 0; i < NUM_SAMPLES; i++) {
adc_reading += adc1_get_raw(ADC1_CHANNEL_0);
}
adc_reading /= NUM_SAMPLES;
uint32_t voltage = esp_adc_cal_raw_to_voltage(adc_reading, &adc_chars);