What is the specific #if defined(ARDUINO_ARCH_ESP32) for ESP32-S2, ESP32-S3, ESP32-C3?

as title.
what is the specific #if defined(ARDUINO_ARCH_ESP32) for ESP32-S2, ESP32-S3, ESP32-C3?

I want to do something only if ESP32-S2 is used for example.

1 Like

The ARDUINO_ARCH_ESP32 is the same for all ESP32-x chips, there is no ARDUINO_ARCH_ESP32_S2 for example.

However, you can use side-information from the sdkconfig.h that gets auto-included when you just #include <Arduino.h> and test for example for the following chip specific macros.

et cetara.

You can also see stuff like that happening in the core

thanks for the help, I really appreciate it.

I am trying this one:

#if defined(CONFIG_IDF_TARGET_ESP32C3)
    root["board"] = "ESP32-C3";
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
    root["board"] = "ESP32-S2";
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
    root["board"] = "ESP32-S3";
#elif defined(ESP32)
    root["board"] = "ESP32";
#endif

but it always ends up setting ESP32 even when using ESP32-S2.

ESP32 is again defined for all boards.

Can you try

#if CONFIG_IDF_TARGET_ESP32C3
    root["board"] = "ESP32-C3";
#elif CONFIG_IDF_TARGET_ESP32S2
    root["board"] = "ESP32-S2";
#elif CONFIG_IDF_TARGET_ESP32S3
    root["board"] = "ESP32-S3";
#elif CONFIG_IDF_TARGET_ESP32
    root["board"] = "ESP32";
#else
  #error "Unrecognized ESP."
#endif

same thing, my root object contains ESP32…

I can’t reproduce that at all. When I add a snippet like

#include <Arduino.h>

#if CONFIG_IDF_TARGET_ESP32C3
    #warning "Compiling for ESP32-C3"
#elif CONFIG_IDF_TARGET_ESP32S2
    #warning "Compiling for ESP32-S2"
#elif CONFIG_IDF_TARGET_ESP32S3
    #warning "Compiling for ESP32-S3"
#elif CONFIG_IDF_TARGET_ESP32
    #warning "Compiling for ESP32"
#else
  #error "Unrecognized ESP."
#endif

it’s clearly showing me only one bock activated

and that’s with

[env:lolin_s2_mini]
platform = espressif32
board = lolin_s2_mini
framework = arduino

Can you add this snippet in your code somewhere and check if it triggers correctly in the build warning messages?

Are you sure you have put an #include <Arduino.h> before accessing those macros?

I’m using CLion from JetBrains with the PlatformIO plugin.
I reinited the project and now it works as expected.

thank you very much @maxgerhardt for the patience and for the help,
I really appreciate it :slight_smile: