Compiling binary locally on mac fails when including ADC sensor on ESP32c6

hello! I’m trying to add a battery sensor to a device using a seeed xiao ESP32c6. I have a voltage divider attached to pin D1(GPIO1). I am trying to compile on a mac running the espHome web interface locally. I have espHome version 2024.12.4. A reduced version of my yaml that gets the same error looks like this:

esphome:
  name: seeed_balcony_controller
  friendly_name: balcony_seeed


esp32:
  board: esp32-c6-devkitm-1
  variant: esp32c6
  framework:
    type: esp-idf
    version: "5.3.1"
    platform_version: 6.9.0

# Enable logging
logger:

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

ota:
  - platform: esphome
    password: "xxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Seed-Balcony Fallback Hotspot"
    password: "xxxxxxx"

sensor:
  - platform: adc
    pin: GPIO1
    name: "battery"
    update_interval: 60s

the error message is as follows:

INFO ESPHome 2024.12.4
INFO Reading configuration /Users/obucklin/Documents/repos/HomeAssistant/espHome/adc-test.yaml...
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING 'seeed_balcony_controller': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Generating C++ source...
INFO Updating https://github.com/espressif/[email protected]
INFO Compiling app...
Processing seeed_balcony_controller (board: esp32-c6-devkitm-1; framework: espidf; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32C6 160MHz, 320KB RAM, 4MB Flash
 - framework-espidf @ 3.50301.0 (5.3.1) 
 - tool-cmake @ 3.16.4 
 - tool-ninja @ 1.9.0 
 - 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 @ 13.2.0+20240530
Reading CMake configuration...
Dependency Graph
|-- noise-c @ 0.1.6
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/adc/adc_sensor_common.cpp.o
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/adc/adc_sensor_esp32.cpp.o
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/esp32/core.cpp.o
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/esp32/gpio.cpp.o
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/esp32/preferences.cpp.o
In file included from src/esphome/components/adc/adc_sensor.h:9,
                 from src/esphome/components/adc/adc_sensor_common.cpp:1:
/Users/obucklin/.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:9,
                 from src/esphome/components/adc/adc_sensor_esp32.cpp:3:
/Users/obucklin/.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:
/Users/obucklin/.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:10:
/Users/obucklin/.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"
      |  ^~~~~~~
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/esphome/ota/ota_esphome.cpp.o
src/esphome/components/adc/adc_sensor.h:40:21: error: 'adc2_channel_t' has not been declared
   40 |   void set_channel2(adc2_channel_t channel) {
      |                     ^~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h:79:3: error: 'adc2_channel_t' does not name a type; did you mean 'adc_channel_t'?
   79 |   adc2_channel_t channel2_{ADC2_CHANNEL_MAX};
      |   ^~~~~~~~~~~~~~
      |   adc_channel_t
src/esphome/components/adc/adc_sensor.h:82:3: error: 'esp_adc_cal_characteristics_t' does not name a type
   82 |   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:38:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   38 |     this->channel2_ = ADC2_CHANNEL_MAX;
      |           ^~~~~~~~~
      |           channel1_
src/esphome/components/adc/adc_sensor.h:40:21: error: 'adc2_channel_t' has not been declared
   40 |   void set_channel2(adc2_channel_t channel) {
      |                     ^~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor.h:79:3: error: 'adc2_channel_t' does not name a type; did you mean 'adc_channel_t'?
   79 |   adc2_channel_t channel2_{ADC2_CHANNEL_MAX};
      |   ^~~~~~~~~~~~~~
      |   adc_channel_t
src/esphome/components/adc/adc_sensor.h:38:23: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   38 |     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:41:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   41 |     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.h:82:3: error: 'esp_adc_cal_characteristics_t' does not name a type
   82 |   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:38:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   38 |     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.h:38:23: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   38 |     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:41:11: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   41 |     this->channel2_ = channel;
      |           ^~~~~~~~~
      |           channel1_
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:91:24: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   91 |       } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                        ^~~~~~~~~
      |                        channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:91:37: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
   91 |       } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                                     ^~~~~~~~~~~~~~~~
      |                                     ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor_esp32.cpp:92:28: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
   92 |         adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw);
      |                            ^~~~~~~~~
      |                            channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:92:9: error: 'adc2_get_raw' was not declared in this scope; did you mean 'adc1_get_raw'?
   92 |         adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw);
      |         ^~~~~~~~~~~~
      |         adc1_get_raw
src/esphome/components/adc/adc_sensor_esp32.cpp:103:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  103 |     uint32_t mv = esp_adc_cal_raw_to_voltage(sum, &this->cal_characteristics_[(int32_t) this->attenuation_]);
      |                                                          ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:103:19: error: 'esp_adc_cal_raw_to_voltage' was not declared in this scope
  103 |     uint32_t mv = esp_adc_cal_raw_to_voltage(sum, &this->cal_characteristics_[(int32_t) this->attenuation_]);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/adc/adc_sensor_esp32.cpp:124:20: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  124 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                    ^~~~~~~~~
      |                    channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:124:33: error: 'ADC2_CHANNEL_MAX' was not declared in this scope; did you mean 'ADC1_CHANNEL_MAX'?
  124 |   } else if (this->channel2_ != ADC2_CHANNEL_MAX) {
      |                                 ^~~~~~~~~~~~~~~~
      |                                 ADC1_CHANNEL_MAX
src/esphome/components/adc/adc_sensor_esp32.cpp:125:37: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  125 |     adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_12_COMPAT);
      |                                     ^~~~~~~~~
      |                                     channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:125:5: error: 'adc2_config_channel_atten' was not declared in this scope; did you mean 'adc1_config_channel_atten'?
  125 |     adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_12_COMPAT);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
      |     adc1_config_channel_atten
src/esphome/components/adc/adc_sensor_esp32.cpp:126:24: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  126 |     adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw12);
      |                        ^~~~~~~~~
      |                        channel1_
Compiling .pioenvs/seeed_balcony_controller/src/esphome/components/logger/logger.cpp.o
src/esphome/components/adc/adc_sensor_esp32.cpp:126:5: error: 'adc2_get_raw' was not declared in this scope; did you mean 'adc1_get_raw'?
  126 |     adc2_get_raw(this->channel2_, ADC_WIDTH_MAX_SOC_BITS, &raw12);
      |     ^~~~~~~~~~~~
      |     adc1_get_raw
src/esphome/components/adc/adc_sensor_esp32.cpp:128:39: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  128 |       adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_6);
      |                                       ^~~~~~~~~
      |                                       channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:129:26: 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, &raw6);
      |                          ^~~~~~~~~
      |                          channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:131:41: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  131 |         adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_2_5);
      |                                         ^~~~~~~~~
      |                                         channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:132:28: 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, &raw2);
      |                            ^~~~~~~~~
      |                            channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:134:43: error: 'class esphome::adc::ADCSensor' has no member named 'channel2_'; did you mean 'channel1_'?
  134 |           adc2_config_channel_atten(this->channel2_, ADC_ATTEN_DB_0);
      |                                           ^~~~~~~~~
      |                                           channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:135:30: 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, &raw0);
      |                              ^~~~~~~~~
      |                              channel1_
src/esphome/components/adc/adc_sensor_esp32.cpp:145:60: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  145 |   uint32_t mv12 = esp_adc_cal_raw_to_voltage(raw12, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_12_COMPAT]);
      |                                                            ^~~~~~~~~~~~~~~~~~~~
*** [.pioenvs/seeed_balcony_controller/src/esphome/components/adc/adc_sensor_common.cpp.o] Error 1
src/esphome/components/adc/adc_sensor_esp32.cpp:145:19: error: 'esp_adc_cal_raw_to_voltage' was not declared in this scope
  145 |   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:146:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  146 |   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:147:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  147 |   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:148:58: error: 'class esphome::adc::ADCSensor' has no member named 'cal_characteristics_'
  148 |   uint32_t mv0 = esp_adc_cal_raw_to_voltage(raw0, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_0]);
      |                                                          ^~~~~~~~~~~~~~~~~~~~
*** [.pioenvs/seeed_balcony_controller/src/esphome/components/adc/adc_sensor_esp32.cpp.o] Error 1
========================== [FAILED] Took 3.27 seconds ==========================

I know the c6 is not yet fully supported or was recently added, so I expect this may be part of the problem.

I tried reinstalling esphome with homebrew, I tried a few different GPIO pins, but no luck.

Anyways, if anyone could lend me a hand I would much appreciate it!

Try removing the versions from Esp32 configuration.

Thanks for the reply, unfortunately that didn’t solve it. I did now compile without those lines, so I guess the c6 is now supported!

Does it work without that sensor?

yes it compiles fine with the i2c sensor

You tried with GPIO2, 3, 6 ?

Yeah I ran through all the ADC pins and none worked

Not much to suggest here then…

ok maybe I’ll post an issue on GH.

thanks anyway for your help!

The same config compiles fine with a c3, so I expect it’s just growing pains with a new board

Quite sure…