6#ifdef CYW43_USES_VSYS_PIN
7#include "pico/cyw43_arch.h"
9#include <hardware/adc.h>
15#define PICO_VSYS_PIN 29
21static const char *
const TAG =
"adc.rp2040";
24 static bool initialized =
false;
32 LOG_SENSOR(
"",
"ADC Sensor",
this);
34 ESP_LOGCONFIG(TAG,
" Pin: Temperature");
36#ifdef USE_ADC_SENSOR_VCC
37 ESP_LOGCONFIG(TAG,
" Pin: VCC");
39 LOG_PIN(
" Pin: ", this->
pin_);
46 LOG_UPDATE_INTERVAL(
this);
54 adc_set_temp_sensor_enabled(
true);
62 adc_set_temp_sensor_enabled(
false);
64 return aggr.aggregate();
66 return aggr.aggregate() * 3.3f / 4096.0f;
70#ifdef CYW43_USES_VSYS_PIN
71 if (pin == PICO_VSYS_PIN) {
81 adc_select_input(pin - 26);
88#ifdef CYW43_USES_VSYS_PIN
89 if (pin == PICO_VSYS_PIN) {
95 return aggr.aggregate();
97 float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f;
98 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 HOT delay(uint32_t ms)