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 ESP_LOGCONFIG(TAG,
"Setting up ADC '%s'...", this->
get_name().c_str());
18 static bool initialized =
false;
26 LOG_SENSOR(
"",
"ADC Sensor",
this);
28 ESP_LOGCONFIG(TAG,
" Pin: Temperature");
30#ifdef USE_ADC_SENSOR_VCC
31 ESP_LOGCONFIG(TAG,
" Pin: VCC");
33 LOG_PIN(
" Pin: ", this->
pin_);
38 LOG_UPDATE_INTERVAL(
this);
46 adc_set_temp_sensor_enabled(
true);
54 adc_set_temp_sensor_enabled(
false);
56 return aggr.aggregate();
58 return aggr.aggregate() * 3.3f / 4096.0f;
62#ifdef CYW43_USES_VSYS_PIN
63 if (pin == PICO_VSYS_PIN) {
73 adc_select_input(pin - 26);
80#ifdef CYW43_USES_VSYS_PIN
81 if (pin == PICO_VSYS_PIN) {
87 return aggr.aggregate();
89 float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f;
90 return aggr.aggregate() * 3.3f / 4096.0f * coeff;
const StringRef & get_name() const
virtual uint8_t get_pin() const =0
void setup() override
Setup ADC.
void dump_config() override
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)