SignalK / SensESP

Universal Signal K sensor framework for the ESP32 platform
https://signalk.org/SensESP/
Apache License 2.0
153 stars 81 forks source link

Compile error in analog_reader.h with S2 and S3 variants #730

Open CaptIgmu opened 2 months ago

CaptIgmu commented 2 months ago

Getting compile error in platformio with SensESP v3 in file _analogreader.h when using ESP32-S2 and S3 variants:

_pio/libdeps/adafruit_qtpy_esp32s3_n4r2/SensESP/src/sensesp/sensors/analog_reader.h:28:30: error: 'ADC_ATTEN_DB_12' was not declared in this scope adc_attent attenuation = ADC_ATTEN_DB_12; ^~~~~~~ .pio/libdeps/adafruit_qtpy_esp32s3_n4r2/SensESP/src/sensesp/sensors/analog_reader.h:28:30: note: suggested alternative: 'ADC_ATTEN_DB11'

I can get it to compile by changing to ADC_ATTEN_DB_11 but noticed in the ESP-IDF docs: _enumerator ADC_ATTEN_DB_11 This is deprecated, it behaves the same as ADC_ATTEN_DB12

So not sure if a Pull request will work for all ESP32s !

Update 8Sept2024: Same error with my new Halmet board with regular ESP32!

imoldovavan commented 2 months ago

Try ADC_ATTEN_DB_0

mairas commented 2 months ago

Could you provide your platformio.ini file? I tried with setting the board to esp32-s3-devkitc-1 and used a simple program with the following:

  auto* analog_input =
      new AnalogInput(pin, read_delay, analog_in_config_path, output_scale);

  auto analog_sk_output = new SKOutput<float>(sk_path);
  analog_input->connect_to(analog_sk_output);

With the above setup, I couldn't reproduce the error.

CaptIgmu commented 2 months ago

Here is my platformio.ini file:

[env] lib_ldf_mode = deep monitor_speed = 115200 upload_speed = 460800

[espressif32_base] build_unflags = -Werror=reorder board_build.partitions = min_spiffs.csv monitor_filters = esp32_exception_decoder

[env:adafruit_qtpy_esp32s3_n4r2] extends = espressif32_base platform = espressif32 board = adafruit_qtpy_esp32s3_n4r2 framework = arduino lib_deps = signalk/SensESP @ >=3.0.0-beta.1,<4

https://github.com/SignalK/SensESP.git # Use this line to use the latest git version

# symlink:///Users/mairas/src/SignalK/SensESP  # Use this line to use a local copy
mairas/ReactESP @ >=2.1.0,<3
sensesp/OneWire @ >=3.0.0,<4

build_flags = ; Max (and default) debugging level in Arduino ESP32 Core -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE ; Arduino Core bug workaround: define the log tag for the Arduino ; logging macros. -D TAG='"Arduino"' ; Use the ESP-IDF logging library - required by SensESP. -D USE_ESP_IDF_LOG

janifr commented 1 month ago

I have the exact same problem compiling unmodified project template.

In file included from .pio/libdeps/esp32dev/SensESP/src/sensesp/sensors/analog_input.h:4, from src/main.cpp:11: .pio/libdeps/esp32dev/SensESP/src/sensesp/sensors/analog_reader.h:28:30: error: 'ADC_ATTEN_DB_12' was not declared in this scope adc_atten_t attenuation_ = ADC_ATTEN_DB_12; ^~~~~~~~~~~~~~~ .pio/libdeps/esp32dev/SensESP/src/sensesp/sensors/analog_reader.h:28:30: note: suggested alternative: 'ADC_ATTEN_DB_11' adc_atten_t attenuation_ = ADC_ATTEN_DB_12; ^~~~~~~~~~~~~~~ ADC_ATTEN_DB_11

CaptIgmu commented 1 month ago

Same error with my new Halmet board with regular ESP32!

GHBLoos commented 1 month ago

Same issue. I didn't change anything of the downloaded code. After changing it to ADC_ATTEN_DB_11;, the build succeeds

smeisner commented 1 month ago

I am seeing this as well with an ESP32-DevKitC board. I will eventually be using the ESP32-S3, so it won't be resolved with the target HW.

If I change it to ADC_ATTEN_DB_11 or ADC_ATTEN_DB_0, it works fine.

Is there a problem changing this to ADC_ATTEN_DB_0 (as you commented above) in the source file?