6#ifdef CYW43_USES_VSYS_PIN
7#include "pico/cyw43_arch.h"
9#include <hardware/adc.h>
14static const char *
const TAG =
"adc.rp2040";
17 static bool initialized =
false;
25 LOG_SENSOR(
"",
"ADC Sensor",
this);
27 ESP_LOGCONFIG(TAG,
" Pin: Temperature");
29#ifdef USE_ADC_SENSOR_VCC
30 ESP_LOGCONFIG(TAG,
" Pin: VCC");
32 LOG_PIN(
" Pin: ", this->
pin_);
39 LOG_UPDATE_INTERVAL(
this);
47 adc_set_temp_sensor_enabled(
true);
55 adc_set_temp_sensor_enabled(
false);
57 return aggr.aggregate();
59 return aggr.aggregate() * 3.3f / 4096.0f;
63#ifdef CYW43_USES_VSYS_PIN
64 if (pin == PICO_VSYS_PIN) {
74 adc_select_input(pin - 26);
81#ifdef CYW43_USES_VSYS_PIN
82 if (pin == PICO_VSYS_PIN) {
88 return aggr.aggregate();
90 float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f;
91 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)
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)