ESP32C6 (Xiao C6) configuration - replacement of legacy adc driver?

Hello Everyone,

I am having some trouble setting up an ESP32C6 module as a moisture sensor.
I previously configured several C3 modules the same way, however I noticed that while with the C3, it is OK to have the platform as ‘arduino’, with the C6, the platform needs to be changed to ‘esp-idf’, otherwise the board is not getting recognized.

I suspect as a byproduct, perhaps some of the syntax has to be changed, however unfortunately the previous modules I set up based on online tutorials rather than properly understanding the programming language, thus I am flying a bit blind here.

Would any of you be able to point out what and how I would need to change in order to get this C6 module functioning the same way my C3 does?

This is the code itself
esphome:
  name: moisture-sensor-lawn
  friendly_name: Lawn Moisture Sensor
  on_boot:
    then:
      - output.turn_on: lawn_power
      - script.execute: test_lawn_ota
  on_shutdown:
    then:
      - output.turn_off: lawn_power

esp32:
  board: esp32-c6-devkitc-1
  framework:
    type: esp-idf
            
# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "encryption key"

ota:
  - platform: esphome
    password: "enter password"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: on
  power_save_mode: LIGHT
  manual_ip:
   static_ip: 192.168.1.190
   gateway: 192.168.1.1
   subnet: 255.255.255.0
   dns1: 192.168.1.1

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Xiao-C6 Lawn Fallback Hotspot"
    password: "enter password"

captive_portal:

sensor:
  - platform: adc
    pin: 
      number: 1
      allow_other_uses: True
    name: "Lawn Surface Moisture Voltage"
    id: lawn_soil_surface_moisture_voltage
    update_interval: 1s
    attenuation: 12db
  - platform: adc
    pin: 
      number: 1
      allow_other_uses: True
    name: "Lawn Moisture"
    unit_of_measurement: "%"
    device_class: MOISTURE
    update_interval: 1s
    attenuation: 12db
    filters:
    - calibrate_linear: #set your own values here
        - 0.30 ->  100.00 
        - 2.25 ->  0.00
    - lambda: |
       if (x < 0) return 0;
       else if (x > 100) return 100;
       else return (x);
    accuracy_decimals: 0
  - platform: wifi_signal
    name: "Lawn Moisture Sensor WiFi Signal"
    update_interval: 5s
  - platform: adc
    pin: 
      number: 2
      allow_other_uses: true
    name: "Lawn Moisture Sensor Battery Life"
    unit_of_measurement: "%"
    device_class: BATTERY
    update_interval: 2s
    attenuation: 12db #required
    filters:
     - multiply: 2.0
     - calibrate_polynomial: #set your own values here
        degree: 4
        datapoints:
        #Map 0.0 (from sensor) to 0.0 (true value)
        - 4.2 -> 100
        - 4.15 -> 95
        - 4.11 -> 90
        - 4.08 -> 85
        - 4.02 -> 80
        - 3.98 -> 75
        - 3.95 -> 70
        - 3.91 -> 65
        - 3.87 -> 60
        - 3.85 -> 55
        - 3.84 -> 50
        - 3.82 -> 45
        - 3.80 -> 40
        - 3.78 -> 35
        - 3.77 -> 30
        - 3.75 -> 25
        - 3.73 -> 20
        - 3.71 -> 15
        - 3.69 -> 10
        - 3.61 -> 5
        - 3.60 -> 0
     - lambda: |
        if (x < 0) return 0; 
        else if (x > 100) return 100;
        else return (x);
        
  - platform: adc
    pin: 
      number: 2
      allow_other_uses: true
    name: "Lawn Moisture Sensor Battery Voltage"
    update_interval: 2s
    attenuation: 12db #required
    filters:
     - multiply: 2.0 #ajust as necessary to correct voltage divider
     
output:
  - platform: gpio
    pin: GPIO23
    id: lawn_power

binary_sensor:
  - platform: status
    name: "Lawn Moisture Sensor Status"
  - platform: homeassistant
    name: "Lawn OTA Mode"
    id: lawnotamode
    entity_id: input_boolean.lawn_ota_mode

button:
  - platform: restart
    name: "Lawn Moisture Sensor Restart"

deep_sleep: #modify to adjust sleep/runtime
  id: gotosleep
  run_duration: 15s
  sleep_duration: '59:45'

script:
  - id: test_lawn_ota
    mode: queued
    then:
      - logger.log: "Checking Lawn Moisture Sensor OTA Mode"
      - if:
          condition:
            binary_sensor.is_on: lawnotamode
          then:
            - logger.log: 'Lawn Moisture Sensor OTA Mode ON'
            - deep_sleep.prevent: gotosleep
          else:
            - logger.log: 'Lawn Moisture Sensor OTA Mode OFF'
            - deep_sleep.allow: gotosleep
      - delay: 1s
      - script.execute: test_lawn_ota
And this is the error I am getting when I am trying to configure the module with the above code
In file included from src/esphome/components/adc/adc_sensor.h:9,
                 from src/esphome/components/adc/adc_sensor_esp32.cpp:3:
/data/cache/platformio/packages/framework-espidf/components/esp_adc/deprecated/include/esp_adc_cal.h:17:2: warning: #warning "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h" [-Wcpp]
   17 | #warning "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h"
      |  ^~~~~~~
In file included from src/esphome/components/adc/adc_sensor.h:10:
/data/cache/platformio/packages/framework-espidf/components/driver/deprecated/driver/adc.h:19:2: warning: #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively" [-Wcpp]
   19 | #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"
      |  ^~~~~~~
In file included from src/esphome/components/adc/adc_sensor.h:9,
                 from src/esphome/components/adc/adc_sensor_common.cpp:1:
/data/cache/platformio/packages/framework-espidf/components/esp_adc/deprecated/include/esp_adc_cal.h:17:2: warning: #warning "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h" [-Wcpp]
   17 | #warning "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h"
      |  ^~~~~~~
In file included from src/esphome/components/adc/adc_sensor.h:10:
/data/cache/platformio/packages/framework-espidf/components/driver/deprecated/driver/adc.h:19:2: warning: #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively" [-Wcpp]
   19 | #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"
      |  ^~~~~~~
src/esphome/components/adc/adc_sensor.h:55:21: error: 'adc2_channel_t' has not been declared
   55 |   void set_channel2(adc2_channel_t channel) {
      |                     ^~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h:96:3: error: 'adc2_channel_t' does not name a type; did you mean 'adc_channel_t'?
   96 |   adc2_channel_t channel2_{ADC2_CHANNEL_MAX};
      |   ^~~~~~~~~~~~~~
      |   adc_channel_t
src/esphome/components/adc/adc_sensor.h:99:3: error: 'esp_adc_cal_characteristics_t' does not name a type
   99 |   esp_adc_cal_characteristics_t cal_characteristics_[SOC_ADC_ATTEN_NUM] = {};
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h: In member function 'void esphome::adc::ADCSensor::set_channel1(adc1_channel_t)':
src/esphome/components/adc/adc_sensor.h:53:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   53 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |           ^~~~~~~~~
      |           channel1_
src/esphome/components/adc/adc_sensor.h:53:23: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   53 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |                       ^~~~~~~~~~~~~~~~
      |                       ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor.h: In member function 'void esphome::adc::ADCSensor::set_channel2(int)':
src/esphome/components/adc/adc_sensor.h:56:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   56 |     this->channel2_ = channel;
      |           ^~~~~~~~~
      |           channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp: In member function 'virtual void esphome::adc::ADCSensor::setup()':
src/esphome/components/adc/adc_sensor_esp32.cpp:32:20: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   32 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                    ^~~~~~~~~
      |                    channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:32:33: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   32 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                                 ^~~~~~~~~~~~~~~~
      |                                 ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor_esp32.cpp:34:39: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   34 |       adc2_config_channel_atten(this->channel2_, this->attenuation_);
      |                                       ^~~~~~~~~
      |                                       channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:34:7: error: 'adc2_config_channel_atten' was not declared in this scope; did you mean 'adc1_config_channel_atten'?
   34 |       adc2_config_channel_atten(this->channel2_, this->attenuation_);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~
      |       adc1_config_channel_atten
src/esphome/components/adc/adc_sensor_esp32.cpp:42:54: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
   42 |                                               &this->cal_characteristics_[i]);
      |                                                      ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:40:22: error: 'esp_adc_cal_characterize' was not declared in this scope
   40 |     auto cal_value = esp_adc_cal_characterize(adc_unit, (adc_atten_t) i, ADC_WIDTH_MAX_SOC_BITS,
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:44:12: error: 'ESP_ADC_CAL_VAL_EFUSE_VREF' was not declared in this scope
   44 |       case ESP_ADC_CAL_VAL_EFUSE_VREF:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:47:12: error: 'ESP_ADC_CAL_VAL_EFUSE_TP' was not declared in this scope
   47 |       case ESP_ADC_CAL_VAL_EFUSE_TP:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:50:12: error: 'ESP_ADC_CAL_VAL_DEFAULT_VREF' was not declared in this scope
   50 |       case ESP_ADC_CAL_VAL_DEFAULT_VREF:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp: In member function 'virtual float esphome::adc::ADCSensor::sample()':
src/esphome/components/adc/adc_sensor_esp32.cpp:93:24: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   93 |       } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                        ^~~~~~~~~
      |                        channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:93:37: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   93 |       } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                                     ^~~~~~~~~~~~~~~~
      |                                     ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor_esp32.cpp:94:28: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   94 |         adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw);
      |                            ^~~~~~~~~
      |                            channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:94:9: error: 'adc2_get_raw' was not declared in this scope; did you mean 'adc1_get_raw'?
   94 |         adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw);
      |         ^~~~~~~~~~~~
      |         adc1_get_raw
src/esphome/components/adc/adc_sensor_esp32.cpp:106:61: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  106 |         esp_adc_cal_raw_to_voltage(aggr.aggregate(), &this->cal_characteristics_[(int32_t) this->attenuation_]);
      |                                                             ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h:55:21: error: 'adc2_channel_t' has not been declared
   55 |   void set_channel2(adc2_channel_t channel) {
      |                     ^~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h:96:3: error: 'adc2_channel_t' does not name a type; did you mean 'adc_channel_t'?
   96 |   adc2_channel_t channel2_{ADC2_CHANNEL_MAX};
      |   ^~~~~~~~~~~~~~
      |   adc_channel_t
src/esphome/components/adc/adc_sensor.h:99:3: error: 'esp_adc_cal_characteristics_t' does not name a type
   99 |   esp_adc_cal_characteristics_t cal_characteristics_[SOC_ADC_ATTEN_NUM] = {};
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h: In member function 'void esphome::adc::ADCSensor::set_channel1(adc1_channel_t)':
src/esphome/components/adc/adc_sensor.h:53:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   53 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |           ^~~~~~~~~
      |           channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:106:9: error: 'esp_adc_cal_raw_to_voltage' was not declared in this scope
  106 |         esp_adc_cal_raw_to_voltage(aggr.aggregate(), &this->cal_characteristics_[(int32_t) this->attenuation_]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:127:20: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  127 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                    ^~~~~~~~~
      |                    channel1_
src/esphome/components/adc/adc_sensor.h:53:23: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   53 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |                       ^~~~~~~~~~~~~~~~
      |                       ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor.h: In member function 'void esphome::adc::ADCSensor::set_channel2(int)':
src/esphome/components/adc/adc_sensor.h:56:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   56 |     this->channel2_ = channel;
      |           ^~~~~~~~~
      |           channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:127:33: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
  127 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                                 ^~~~~~~~~~~~~~~~
      |                                 ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor_esp32.cpp:128:37: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  128 |     adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_12_COMPAT);
      |                                     ^~~~~~~~~
      |                                     channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:128:5: error: 'adc2_config_channel_atten' was not declared in this scope; did you mean 'adc1_config_channel_atten'?
  128 |     adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_12_COMPAT);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
      |     adc1_config_channel_atten
src/esphome/components/adc/adc_sensor_esp32.cpp:129:24: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  129 |     adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw12);
      |                        ^~~~~~~~~
      |                        channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:129:5: error: 'adc2_get_raw' was not declared in this scope; did you mean 'adc1_get_raw'?
  129 |     adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw12);
      |     ^~~~~~~~~~~~
      |     adc1_get_raw
src/esphome/components/adc/adc_sensor_esp32.cpp:131:39: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  131 |       adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_6);
      |                                       ^~~~~~~~~
      |                                       channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:132:26: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  132 |       adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw6);
      |                          ^~~~~~~~~
      |                          channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:134:41: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  134 |         adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_2_5);
      |                                         ^~~~~~~~~
      |                                         channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:135:28: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  135 |         adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw2);
      |                            ^~~~~~~~~
      |                            channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:137:43: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  137 |           adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_0);
      |                                           ^~~~~~~~~
      |                                           channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:138:30: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  138 |           adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw0);
      |                              ^~~~~~~~~
      |                              channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:148:60: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  148 |   uint32_t mv12 = esp_adc_cal_raw_to_voltage(raw12, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_12_COMPAT]);
      |                                                            ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:148:19: error: 'esp_adc_cal_raw_to_voltage' was not declared in this scope
  148 |   uint32_t mv12 = esp_adc_cal_raw_to_voltage(raw12, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_12_COMPAT]);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:149:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  149 |   uint32_t mv6 = esp_adc_cal_raw_to_voltage(raw6, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_6]);
      |                                                          ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:150:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  150 |   uint32_t mv2 = esp_adc_cal_raw_to_voltage(raw2, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_2_5]);
      |                                                          ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:151:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  151 |   uint32_t mv0 = esp_adc_cal_raw_to_voltage(raw0, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_0]);
      |                                                          ^~~~~~~~~~~~~~~~~~~~
*** [.pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_common.cpp.o] Error 1
*** [.pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_esp32.cpp.o] Error 1

I would be grateful for any help, thanks in advance!

What version of esphome are you running?

Have you tried cleaning your build?

I am running 2025.5.2

What do you mean by cleaning the build?

Also, when you swap the framework from arduino to esp-idf, you need to upload first time using cable.

Thank you, I managed to clean the build files, but I do run into the same issue during the installation itself.

I did not specify in my original post, but I do connect the module to the machine running ESPHome via cable. The device does get recognized as ‘online’, but when running the installation, I get the error I attached in my first post.

Esp32-c6 doesn’t even have ADC2, so logs about that are confusing.
How it goes if you upload a yaml without any ADC component?

I removed the entire sensor section, which included all adc components.
That way the unit could be configured with the rest of the code. (though it loses its main purpose)

Interesting…
What if you add something simple?

sensor:
  - platform: adc
    pin: GPIO1
    name: "Lawn Surface Moisture Voltage"
    id: lawn_soil_surface_moisture_voltage
    update_interval: 1s
    attenuation: auto

I am still getting an error. :frowning:

INFO ESPHome 2025.5.2
INFO Reading configuration /config/esphome/moisture-sensor-lawn.yaml...
INFO Generating C++ source...
INFO Updating https://github.com/espressif/[email protected]
INFO Compiling app...
Processing moisture-sensor-lawn (board: esp32-c6-devkitc-1; framework: espidf; platform: https://github.com/pioarduino/platform-espressif32.git#51.03.07)
--------------------------------------------------------------------------------
Library Manager: Installing esphome/noise-c @ 0.1.6
INFO Installing esphome/noise-c @ 0.1.6
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
Library Manager: Installing esphome/libsodium @ 1.10018.4
INFO Installing esphome/libsodium @ 1.10018.4
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Installing bblanchon/ArduinoJson @ 6.18.5
INFO Installing bblanchon/ArduinoJson @ 6.18.5
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
HARDWARE: ESP32C6 160MHz, 320KB RAM, 8MB Flash
 - framework-espidf @ 3.50106.0 (5.1.6) 
 - tool-cmake @ 3.21.3 
 - tool-esptoolpy @ 4.8.1 
 - tool-mklittlefs @ 3.2.0 
 - tool-ninja @ 1.7.1 
 - tool-riscv32-esp-elf-gdb @ 12.1.0+20221002 
 - tool-xtensa-esp-elf-gdb @ 12.1.0+20221002 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-riscv32-esp @ 12.2.0+20230208
Reading CMake configuration...
Generating assembly for certificate bundle...
Dependency Graph
|-- noise-c @ 0.1.6
|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_common.cpp.o
Compiling .pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_esp32.cpp.o
Compiling .pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_esp8266.cpp.o
Compiling .pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_libretiny.cpp.o
Compiling .pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_rp2040.cpp.o
Compiling .pioenvs/moisture-sensor-lawn/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/moisture-sensor-lawn/src/esphome/components/api/api_frame_helper.cpp.o
In file included from src/esphome/components/adc/adc_sensor.h:9,
                 from src/esphome/components/adc/adc_sensor_common.cpp:1:
/data/cache/platformio/packages/framework-espidf@src-f61644d6990eba6c2084961ff40be733/components/esp_adc/deprecated/include/esp_adc_cal.h:17:2: warning: #warning "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h" [-Wcpp]
   17 | #warning "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h"
      |  ^~~~~~~
In file included from src/esphome/components/adc/adc_sensor.h:10:
/data/cache/platformio/packages/framework-espidf@src-f61644d6990eba6c2084961ff40be733/components/driver/deprecated/driver/adc.h:19:2: warning: #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively" [-Wcpp]
   19 | #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"
      |  ^~~~~~~
In file included from src/esphome/components/adc/adc_sensor.h:9,
                 from src/esphome/components/adc/adc_sensor_esp32.cpp:3:
/data/cache/platformio/packages/framework-espidf@src-f61644d6990eba6c2084961ff40be733/components/esp_adc/deprecated/include/esp_adc_cal.h:17:2: warning: #warning "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h" [-Wcpp]
   17 | #warning "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h"
      |  ^~~~~~~
In file included from src/esphome/components/adc/adc_sensor.h:10:
/data/cache/platformio/packages/framework-espidf@src-f61644d6990eba6c2084961ff40be733/components/driver/deprecated/driver/adc.h:19:2: warning: #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively" [-Wcpp]
   19 | #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"
      |  ^~~~~~~
src/esphome/components/adc/adc_sensor.h:55:21: error: 'adc2_channel_t' has not been declared
   55 |   void set_channel2(adc2_channel_t channel) {
      |                     ^~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h:96:3: error: 'adc2_channel_t' does not name a type; did you mean 'adc_channel_t'?
   96 |   adc2_channel_t channel2_{ADC2_CHANNEL_MAX};
      |   ^~~~~~~~~~~~~~
      |   adc_channel_t
src/esphome/components/adc/adc_sensor.h:99:3: error: 'esp_adc_cal_characteristics_t' does not name a type
   99 |   esp_adc_cal_characteristics_t cal_characteristics_[SOC_ADC_ATTEN_NUM] = {};
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h: In member function 'void esphome::adc::ADCSensor::set_channel1(adc1_channel_t)':
src/esphome/components/adc/adc_sensor.h:53:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   53 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |           ^~~~~~~~~
      |           channel1_
src/esphome/components/adc/adc_sensor.h:53:23: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   53 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |                       ^~~~~~~~~~~~~~~~
      |                       ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor.h: In member function 'void esphome::adc::ADCSensor::set_channel2(int)':
src/esphome/components/adc/adc_sensor.h:56:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   56 |     this->channel2_ = channel;
      |           ^~~~~~~~~
      |           channel1_
*** [.pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_common.cpp.o] Error 1
src/esphome/components/adc/adc_sensor.h:55:21: error: 'adc2_channel_t' has not been declared
   55 |   void set_channel2(adc2_channel_t channel) {
      |                     ^~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h:96:3: error: 'adc2_channel_t' does not name a type; did you mean 'adc_channel_t'?
   96 |   adc2_channel_t channel2_{ADC2_CHANNEL_MAX};
      |   ^~~~~~~~~~~~~~
      |   adc_channel_t
src/esphome/components/adc/adc_sensor.h:99:3: error: 'esp_adc_cal_characteristics_t' does not name a type
   99 |   esp_adc_cal_characteristics_t cal_characteristics_[SOC_ADC_ATTEN_NUM] = {};
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h: In member function 'void esphome::adc::ADCSensor::set_channel1(adc1_channel_t)':
src/esphome/components/adc/adc_sensor.h:53:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   53 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |           ^~~~~~~~~
      |           channel1_
src/esphome/components/adc/adc_sensor.h:53:23: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   53 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |                       ^~~~~~~~~~~~~~~~
      |                       ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor.h: In member function 'void esphome::adc::ADCSensor::set_channel2(int)':
src/esphome/components/adc/adc_sensor.h:56:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   56 |     this->channel2_ = channel;
      |           ^~~~~~~~~
      |           channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp: In member function 'virtual void esphome::adc::ADCSensor::setup()':
src/esphome/components/adc/adc_sensor_esp32.cpp:32:20: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   32 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                    ^~~~~~~~~
      |                    channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:32:33: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   32 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                                 ^~~~~~~~~~~~~~~~
      |                                 ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor_esp32.cpp:34:39: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   34 |       adc2_config_channel_atten(this->channel2_, this->attenuation_);
      |                                       ^~~~~~~~~
      |                                       channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:34:7: error: 'adc2_config_channel_atten' was not declared in this scope; did you mean 'adc1_config_channel_atten'?
   34 |       adc2_config_channel_atten(this->channel2_, this->attenuation_);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~
      |       adc1_config_channel_atten
src/esphome/components/adc/adc_sensor_esp32.cpp:42:54: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
   42 |                                               &this->cal_characteristics_[i]);
      |                                                      ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:40:22: error: 'esp_adc_cal_characterize' was not declared in this scope
   40 |     auto cal_value = esp_adc_cal_characterize(adc_unit, (adc_atten_t) i, ADC_WIDTH_MAX_SOC_BITS,
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:44:12: error: 'ESP_ADC_CAL_VAL_EFUSE_VREF' was not declared in this scope
   44 |       case ESP_ADC_CAL_VAL_EFUSE_VREF:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:47:12: error: 'ESP_ADC_CAL_VAL_EFUSE_TP' was not declared in this scope
   47 |       case ESP_ADC_CAL_VAL_EFUSE_TP:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:50:12: error: 'ESP_ADC_CAL_VAL_DEFAULT_VREF' was not declared in this scope
   50 |       case ESP_ADC_CAL_VAL_DEFAULT_VREF:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp: In member function 'virtual float esphome::adc::ADCSensor::sample()':
src/esphome/components/adc/adc_sensor_esp32.cpp:93:24: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   93 |       } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                        ^~~~~~~~~
      |                        channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:93:37: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   93 |       } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                                     ^~~~~~~~~~~~~~~~
      |                                     ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor_esp32.cpp:94:28: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   94 |         adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw);
      |                            ^~~~~~~~~
      |                            channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:94:9: error: 'adc2_get_raw' was not declared in this scope; did you mean 'adc1_get_raw'?
   94 |         adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw);
      |         ^~~~~~~~~~~~
      |         adc1_get_raw
src/esphome/components/adc/adc_sensor_esp32.cpp:106:61: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  106 |         esp_adc_cal_raw_to_voltage(aggr.aggregate(), &this->cal_characteristics_[(int32_t) this->attenuation_]);
      |                                                             ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:106:9: error: 'esp_adc_cal_raw_to_voltage' was not declared in this scope
  106 |         esp_adc_cal_raw_to_voltage(aggr.aggregate(), &this->cal_characteristics_[(int32_t) this->attenuation_]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:127:20: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  127 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                    ^~~~~~~~~
      |                    channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:127:33: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
  127 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                                 ^~~~~~~~~~~~~~~~
      |                                 ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor_esp32.cpp:128:37: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  128 |     adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_12_COMPAT);
      |                                     ^~~~~~~~~
      |                                     channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:128:5: error: 'adc2_config_channel_atten' was not declared in this scope; did you mean 'adc1_config_channel_atten'?
  128 |     adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_12_COMPAT);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
      |     adc1_config_channel_atten
src/esphome/components/adc/adc_sensor_esp32.cpp:129:24: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  129 |     adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw12);
      |                        ^~~~~~~~~
      |                        channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:129:5: error: 'adc2_get_raw' was not declared in this scope; did you mean 'adc1_get_raw'?
  129 |     adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw12);
      |     ^~~~~~~~~~~~
      |     adc1_get_raw
src/esphome/components/adc/adc_sensor_esp32.cpp:131:39: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  131 |       adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_6);
      |                                       ^~~~~~~~~
      |                                       channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:132:26: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  132 |       adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw6);
      |                          ^~~~~~~~~
      |                          channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:134:41: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  134 |         adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_2_5);
      |                                         ^~~~~~~~~
      |                                         channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:135:28: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  135 |         adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw2);
      |                            ^~~~~~~~~
      |                            channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:137:43: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  137 |           adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_0);
      |                                           ^~~~~~~~~
      |                                           channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:138:30: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  138 |           adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw0);
      |                              ^~~~~~~~~
      |                              channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:148:60: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  148 |   uint32_t mv12 = esp_adc_cal_raw_to_voltage(raw12, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_12_COMPAT]);
      |                                                            ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:148:19: error: 'esp_adc_cal_raw_to_voltage' was not declared in this scope
  148 |   uint32_t mv12 = esp_adc_cal_raw_to_voltage(raw12, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_12_COMPAT]);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:149:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  149 |   uint32_t mv6 = esp_adc_cal_raw_to_voltage(raw6, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_6]);
      |                                                          ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:150:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  150 |   uint32_t mv2 = esp_adc_cal_raw_to_voltage(raw2, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_2_5]);
      |                                                          ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:151:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  151 |   uint32_t mv0 = esp_adc_cal_raw_to_voltage(raw0, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_0]);
      |                                                          ^~~~~~~~~~~~~~~~~~~~
*** [.pioenvs/moisture-sensor-lawn/src/esphome/components/adc/adc_sensor_esp32.cpp.o] Error 1
========================= [FAILED] Took 13.50 seconds =========================

What I’ve read on the matter is the following: since the C6 board does not support the arduino framework, the only way to configure it is via esp-idf.

Esp-idf on the other hand does no longer operate with - what is considered now to be - the legacy adc driver. I believe the errors I am getting is the result of not configuring the new adc driver properly; there are most likely additional parameters that are currently missing from my code.
Analog to Digital Converter (ADC) - ESP32 - — ESP-IDF Programming Guide v4.4.8 documentation

My issue is that, as I mentioned in my initial post, I am really not familiar with coding and the previous sensors I set up based on online tutorials rather than building them from scratch myself. :frowning:

You could try this external component:

1 Like

This solved it!! Thank you so much!

You are welcome, hopefully soon it works without external component.