We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
分支:MASTER COMMIT:3b15c065c5f37db69b4555fc23c78b8837c3554b 源码:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/adc.h" #include "esp_log.h" static const char *TAG = "adc example"; static void adc_task() { int x; uint16_t adc_data[100]; uint16_t adc_value_average,adc_voltage_mv1; uint32_t adc_values; while (1) { if (ESP_OK == adc_read(&adc_data[0])) { ESP_LOGI(TAG, "adc read: %d\r\n", adc_data[0]); } adc_values = 0; ESP_LOGI(TAG, "adc read fast:\r\n"); if (ESP_OK == adc_read_fast(adc_data, 100)) { for (x = 0; x < 100; x++) { adc_values += adc_data[x]; // printf("%d\n", adc_data[x]); } } adc_value_average = adc_values/100; adc_voltage_mv1 = (adc_value_average * 1000) / 1024; printf("\n------------------------------------------adc_voltage_mv1 = %dmV\n",adc_voltage_mv1); //printf("%d\n", adc_data[x]); vTaskDelay(1000 / portTICK_RATE_MS); } } void app_main() { // 1. init adc adc_config_t adc_config; // Depend on menuconfig->Component config->PHY->vdd33_const value // When measuring system voltage(ADC_READ_VDD_MODE), vdd33_const must be set to 255. adc_config.mode = ADC_READ_TOUT_MODE; adc_config.clk_div = 8; // ADC sample collection clock = 80MHz/clk_div = 10MHz ESP_ERROR_CHECK(adc_init(&adc_config)); // 2. Create a adc task to read adc value xTaskCreate(adc_task, "adc_task", 1024, NULL, 5, NULL); }
结果: 万用表测出的电压值: ESP8266计算出来的电压值:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
分支:MASTER
COMMIT:3b15c065c5f37db69b4555fc23c78b8837c3554b
源码:
结果:


万用表测出的电压值:
ESP8266计算出来的电压值:
The text was updated successfully, but these errors were encountered: