6#ifdef CYW43_USES_VSYS_PIN
7#include "pico/cyw43_arch.h"
9#include <hardware/adc.h>
15#define PICO_VSYS_PIN 29
20static const char *
const TAG =
"adc.rp2040";
23 static bool initialized =
false;
31 LOG_SENSOR(
"",
"ADC Sensor",
this);
33 ESP_LOGCONFIG(TAG,
" Pin: Temperature");
35#ifdef USE_ADC_SENSOR_VCC
36 ESP_LOGCONFIG(TAG,
" Pin: VCC");
38 LOG_PIN(
" Pin: ", this->
pin_);
45 LOG_UPDATE_INTERVAL(
this);
53 adc_set_temp_sensor_enabled(
true);
61 adc_set_temp_sensor_enabled(
false);
63 return aggr.aggregate();
65 return aggr.aggregate() * 3.3f / 4096.0f;
69#ifdef CYW43_USES_VSYS_PIN
70 if (pin == PICO_VSYS_PIN) {
80 adc_select_input(pin - 26);
87#ifdef CYW43_USES_VSYS_PIN
88 if (pin == PICO_VSYS_PIN) {
94 return aggr.aggregate();
96 float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f;
97 return aggr.aggregate() * 3.3f / 4096.0f * coeff;
virtual uint8_t get_pin() const =0
float sample() override
Perform a single ADC sampling operation and return the measured value.
void setup() override
Set up the ADC sensor by initializing hardware and calibration parameters.
void dump_config() override
Output the configuration details of the ADC sensor for debugging purposes.
SamplingMode sampling_mode_
const LogString * sampling_mode_to_str(SamplingMode mode)
void HOT delay(uint32_t ms)