"https://esp32.com/viewtopic.php?t=21969"
But doing that, my esp32-s2 keeps reading only up to 2.5 volts, after that I have a ghost zone on the potentiometer axis. Is there anyone here who was successful in this implementation? I don't want to have to generate the necessary attenuation via hardware.
Code: Select all
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <soc/adc_channel.h>
#include <soc/rtc.h>
#include <driver/adc.h>
#include <esp_adc_cal.h>
#include <esp_log.h>
static const char* TAG = "test";
void app_main() {
adc1_config_width(ADC_WIDTH_BIT_13);
adc1_config_channel_atten(ADC1_GPIO1_CHANNEL, ADC_ATTEN_11db);
for (;;) {
int raw = adc1_get_raw(ADC1_GPIO1_CHANNEL);
ESP_LOGI(TAG, "%d", raw);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}