Use of arduino-esp32 in platformio

Is it possible to setup arduino-esp32 in platformio? I happened to come across this https://techoverflow.net/2024/12/19/how-to-fix-platformio-esp32-missing-sconscript-file-platformio-build-py/ and thought it might be possible.

I am currently trying these.
[env:esp32]
framework = arduino
platform = espressif32
; platform_packages = framework-arduinoespressif32 @ GitHub - espressif/arduino-esp32: Arduino core for the ESP32
; platform_packages = framework-arduinoespressif32 @ file:///home/cw/Arduino/hardware/espressif/esp32
platform_packages =
framework-arduinoespressif32 @ file:///home/cw/Arduino/hardware/espressif/esp32
; framework-arduinoespressif32 @ file:///home/cw/Arduino/hardware/espressif/esp32/tools/esp32-arduino-libs
board = esp32doit-devkit-v1

arduino-esp32 has already been installed in the standard folder Arduino/hardware/espressif/esp32. The problem I found from the above trials are

*** missing SConscript file ‘/home/cw/.platformio/packages/framework-arduinoespressif32/tools/platformio-build.py’

File “/home/cw/.platformio/platforms/espressif32/builder/frameworks/arduino.py”, line 49, in

or can’t locate Arduino.h

What are you trying to achieve?
platform = espressif32 @ 6.9.0 gives you Espressif32 Arduino 2.0.17.

If you want to use a newer Espressif32 Arduino, try pioarduino!
e.g. latest Espressif32 Arduino 3.1.1:

platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.11/platform-espressif32.zip
  1. platform = espressif32 @ 6.9.0
  • Arduino - v2.0.17 (based on IDF v4.4.7)
  • ESP-IDF - v5.3.1
    Arduino here seems to lag behind so much.
  1. pioarduino
    it seems they recommend using pioarduino ide but I have it running with platformio too. The biggest problem I have is esp32c2 is not part of their standard build. Actually I want only esp32, esp32c3, and esp32c2.

Recently I tried building esp32-arduino-lib-builder, but I had problem understanding how to switch to idf 5.3.

Thats the reason why pioarduino exists. For the long story read Support Arduino ESP32 v3.0 based on ESP-IDF v5.1 ¡ Issue #1225 ¡ platformio/platform-espressif32 ¡ GitHub

There is no Arduino support for ESP32-C2 from Espressif - See GitHub - espressif/arduino-esp32: Arduino core for the ESP32

There is but it just needs us to rebuild using esp32-arduino-lib-builder. I used to do it with idf v5.1 but I had problem with understanding branch/checkout to v5.3 there.

Note from Espressif:

ESP32-C2 is also supported by Arduino-ESP32 but requires rebuilding the static libraries. This is not trivial and requires a good understanding of the ESP-IDF build system. For more information, see the Lib Builder documentation.

In Espressif web, ESP32C2 is supposed to come and replace ESP8266. Just adding this to the builder shouldn’t be a big deal but somehow it becomes a big deal.

Similar to the long story, it shouldn’t have been a big deal if one just keep one’s ego down. Based on the ESP32C2 build, it’s not so difficult to understand why it’s so hard to deal with the big guys there.

If you want to be on the safe side, use the ESP32-C3 or ESP32-S3. These are supported in Arduino 2.x and therefore available in platform-espressif32 @ 6.9.0

If you want to use newer chips like ESP32-C6, ESP32-H2, ESP32-P4 use pioarduino.

@ceewanna

I didn’t know, but pioarduino supports ESP32-C2 (ESP32-C2-DevKitM-1):
board = esp32-c2-devkitm-1

yes that’s the esp32c2 board I am using.
I only handle esp32, esp32c3, esp32c2 and esp8266.

Should be no problem when using pioarduino.

What’s left?

From Jason reply in pioarduino, I can now use pioarduino and use esp32 lib builder to build only cpu that I use. By standard build, pioarduino comes with so many cpu’s except esp32c2.

Right now I am having headache with platformio.ini. I have these two sections and need to merge with other build_flags and cpus.

[syncweb]
build_flags =
-D USE_SYNC_WEBSERVER
lib_ignore =
AsyncTCP
AsyncTCP_RP2040W
ESPAsyncTCP
ESPAsyncWebServer

[asyncweb]
build_flags =
-D USE_ASYNC_WEBSERVER
lib_compat_mode = strict
lib_ldf_mode = chain

“extends” is so limited in the use. It’s tedious having to repeat ${} interpolated variables.

I didn’t formulate my question clearly enough.
What is the reason why you are using the Lib Builder?

You can use extends — PlatformIO latest documentation
and Interpolation of Values — PlatformIO latest documentation

Well, I have using pioarduino for esp32 and esp32c3 and another Jason build for esp32c2 for quite a while. I always see the front page of arduino-esp32 saying esp32c2 is supported but you have to build it yourself. I always wonder why they don’t just build it as standard. Everytime I asked question about this kind of thing, people always mentioned about the issue between platformio and espressif. The more I get this kind of response, the more I feel like I have to be able to manage something on our own. So one day I get to try building my own lib.

I still have issue with esp32c2 but I want to them a break for now. :slight_smile: The printf of long long int or int64_t with “%lld” format always comes out as “ld”. This happens to every lib that I have been using so far, including the own build. Maybe it has to do with sdkconfig somewhere. It doesn’t happen to esp32 and c3. This is one of the reasons I want to build the lib myself too.

But pioarduino directly supports the ESP32-C2. There should be no need to build the libs manually.

About the “%lld”:
I don’t think that it is about some sdkconfig settings.
Either this is expected behavior or it’s an error and should be reported.

No it’s not directly supported from the standard build. esp32c2 is not part of the standard build. You can have a look in .platformio/packages/framework-arduinoespressif32-libs. There is no esp32c2 folder there.

“%lld” problem may have come from an issue related to nano and newlib. I am still new on this. It’s has to do with limiting the print out to 32bit. It’s not an expected behaviour, I am sure.

@ceewanna There is a misunderstanding on your side. pioarduino adds support for C2. This is done by pioarduino Hybrid Compile. pioarduino builds the needed Arduino libs just before compiling the C2 Arduino sketch. This is an exclusive feature from pioarduino programmed and added from me.

1 Like

What you referred to as “support” in my view is equivalent to saying “it can” compile. I can appreciate that.

But by default lib in pioarduino, there is no esp32c2 lib built in, anyone who wants to use esp32c2 will have to struggle for ways to make it “really supports”. That’s from the perspective a layman user like me.

Again wrong. Just use the provided C2 boards manifest provided from pioarduino and a normal Arduino sketch. Hit compile as for every other MCU. There is no difference for the end user compiling a C2 Arduino sketch to all other MCUs

I did that already many times and my board = esp32-c2-devkitm-1.
There is always this message coming out.
**** missing SConscript file ‘/home/cw/.platformio/packages/framework-arduinoespressif32-libs/esp32c2/pioarduino-build.py’*
File “/home/cw/.platformio/packages/framework-arduinoespressif32/tools/pioarduino-build.py”, line 159, in

all other boards are fine.
[e32pio]
extends = env:arduino
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.11/platform-espressif32.zip

[env:c3]
extends = e32pio
board = esp32-c3-devkitm-1 ; c3 super mini
board_build.partitions = partitions/max4M_ota_minFS.csv

[env:e32]
extends = e32pio
board = esp32doit-devkit-v1
board_build.partitions = partitions/max4M_ota_minFS.csv

[env:c2]
extends = e32pio
board = esp32-c2-devkitm-1
board_build.partitions = partitions/max4M_ota_minFS.csv

The libs folder in platformio has no esp32c2.
~/.platformio/packages/framework-arduinoespressif32-libs$ ls .
esp32 esp32c3 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3 package.json tools.json versions.txt

Only yesterday, when I built the libs myself and customized platform_packages = framework-arduinoespressif32-libs @ file:///myhome/esp32-arduino-libs
It can now work.