ESP-IDF vs Arduino: Which Should You Use to Program ESP32?
ESP-IDF vs Arduino for ESP32: FreeRTOS, menuconfig, components, debugging and moving over with PlatformIO. Comparison table plus the same LED code in both.
The ESP-IDF vs Arduino question is really about layers, not rivals. ESP-IDF (Espressif IoT Development Framework) is the official software framework from Espressif, the company that makes the ESP32: it is written in C, uses CMake, and contains FreeRTOS, the Wi-Fi and Bluetooth stacks and every hardware driver. The Arduino core (arduino-esp32) is a shell that sits on top of that framework; it translates familiar calls such as digitalWrite(), Serial and WiFi.h into ESP-IDF functions. So every ESP32 sketch you write in the Arduino IDE already runs on ESP-IDF behind the scenes.
In this article you'll see where the two paths split: how FreeRTOS is configured differently on each side, what you can change with menuconfig, the component system, the debugging tools and when each one makes more sense. You'll blink the same LED first in Arduino and then in pure ESP-IDF, then learn how to use Arduino as an ESP-IDF component and how to move over gradually with PlatformIO. Version details are as of the time of writing: the 3.3 series of the Arduino core is built on ESP-IDF 5.5, while Espressif released ESP-IDF 6.0 in March 2026.

What are ESP-IDF and the Arduino core?
ESP-IDF is the open-source SDK Espressif develops for the whole ESP32 family (ESP32, S2, S3, C3, C6, H2, P4 and later). When a new chip comes out, ESP-IDF supports it first; the Arduino core only supports that chip after it moves to the matching ESP-IDF version. The Arduino core is also developed by Espressif, but it packages ESP-IDF as precompiled libraries with a fixed configuration file (sdkconfig) instead of building it from source. That is why Arduino compiles quickly, but you can only change the few ESP-IDF settings offered in the Tools menu out of hundreds. The table below shows which layers a command passes through when you light an LED from the Arduino IDE.
| Layer | Job | Example |
|---|---|---|
| Your sketch | Application logic | setup(), loop() |
| Arduino API (arduino-esp32) | Turns familiar calls into ESP-IDF calls | digitalWrite(), Serial, WiFi.h, Wire |
| ESP-IDF drivers and components | Manage the hardware and network stacks | gpio_set_level(), esp_wifi, nvs_flash |
| FreeRTOS | Manages tasks, timing and both cores | xTaskCreate(), vTaskDelay(), queues |
| ROM, bootloader, hardware | Boot, flash access, registers | bootloader, partition table |
Feature and difficulty comparison table
| Criterion | Arduino core | ESP-IDF |
|---|---|---|
| Language | C++ (Arduino style) | C (C++ also possible) |
| Entry point | setup() and loop() | app_main() |
| Installation | Board package in Arduino IDE, a few minutes | ESP-IDF toolchain (EIM or VS Code extension), longer |
| Learning curve | Easy | Medium to hard |
| Configuration | A few options in the Tools menu | Hundreds of options via menuconfig |
| Libraries | Thousands of Arduino libraries in Library Manager | ESP Component Registry components, Arduino libraries don't work directly |
| FreeRTOS | Yes, loop() is a task, 1000 Hz tick | Yes, full access, default tick 100 Hz |
| Debugging | Serial.print, core log level, IDE 2 debugger | Backtrace decoding in idf.py monitor, JTAG + GDB, core dump |
| New chip support | Follows ESP-IDF | Comes first |
| First build | Fast (prebuilt libraries) | Slow (framework built from source), later builds fast |
| Best for | Prototypes, hobby, teaching, quick IoT | Products, low power, security, fine tuning |
The most important row in the table is libraries. On the Arduino side you'll find a ready-made library in Library Manager for an OLED display, a DHT sensor or an MQTT client and have it running in five minutes. In pure ESP-IDF those libraries don't compile directly because they depend on the Arduino API (Wire, SPI, digitalWrite); you either find an ESP-IDF component or write the driver yourself with the I2C and SPI drivers. In return, ESP-IDF gives you full access to every setting you need to ship a product: sleep modes, power management, flash encryption, secure boot and memory layout.
The same LED in both worlds: Arduino and ESP-IDF code
The first example shows that ESP-IDF functions can be used inside an Arduino sketch too. The board starts a FreeRTOS task that blinks the on-board LED, wired to GPIO 2 on most DevKits, using the ESP-IDF GPIO driver; it also prints the chip model, free heap, FreeRTOS tick rate and the core loop() runs on to the Serial Monitor. Upload it in the Arduino IDE with ESP32 Dev Module selected and open the Serial Monitor at 115200 baud.
1// ESP32 Arduino taslağında doğrudan ESP-IDF API'leri / ESP-IDF APIs used directly in an ESP32 Arduino sketch
2#include <Arduino.h>
3#include "driver/gpio.h"
4#include "esp_system.h"
5#include "esp_chip_info.h"
6
7const gpio_num_t LED = GPIO_NUM_2; // DevKit dahili LED / on-board LED (GPIO 2)
8
9// FreeRTOS görevi: LED'i ESP-IDF GPIO sürücüsüyle yakıp söndürür
10// FreeRTOS task: blinks the LED with the ESP-IDF GPIO driver
11void ledGorevi(void *param) {
12 gpio_reset_pin(LED);
13 gpio_set_direction(LED, GPIO_MODE_OUTPUT);
14 int durum = 0;
15 for (;;) {
16 durum = !durum;
17 gpio_set_level(LED, durum);
18 vTaskDelay(pdMS_TO_TICKS(500)); // Arduino'da 1 tik = 1 ms / 1 tick = 1 ms in Arduino
19 }
20}
21
22void setup() {
23 Serial.begin(115200);
24 delay(500);
25
26 esp_chip_info_t bilgi; // yonga bilgisi / chip info
27 esp_chip_info(&bilgi);
28 Serial.printf("Yonga / chip: %s, cekirdek / cores: %d, rev: %d\n",
29 ESP.getChipModel(), bilgi.cores, bilgi.revision);
30 Serial.printf("Bos heap / free heap: %u bayt\n", (unsigned) esp_get_free_heap_size());
31 Serial.printf("FreeRTOS tik hizi / tick rate: %d Hz\n", (int) configTICK_RATE_HZ);
32 Serial.printf("loop() cekirdegi / core: %d\n", (int) xPortGetCoreID());
33
34 // LED görevini çekirdek 0'da başlat / start the LED task on core 0
35 xTaskCreatePinnedToCore(ledGorevi, "led", 2048, NULL, 1, NULL, 0);
36}
37
38void loop() {
39 // loop() kendi FreeRTOS görevinde (loopTask) çalışır / loop() runs in its own FreeRTOS task (loopTask)
40 Serial.printf("Calisma suresi / uptime: %lu s\n", millis() / 1000);
41 delay(2000); // delay() = vTaskDelay(), işlemciyi diğer görevlere bırakır / yields to other tasks
42}In the Serial Monitor you'll see a tick rate of 1000 Hz and loop() on core 1, while the LED task runs on core 0. Arduino's delay() also calls vTaskDelay() under the hood, so the processor switches to other tasks while waiting. Now let's blink the same LED with pure ESP-IDF. There is no setup() or loop() here; the program starts at app_main() and you build the endless loop yourself. Instead of Serial you use the ESP_LOGI macro for log messages; it adds the log level, a timestamp and a tag, and its level is set in menuconfig.
1// main/main.c — saf ESP-IDF ile LED yakıp söndürme / blinking an LED with pure ESP-IDF
2#include <stdio.h>
3#include "freertos/FreeRTOS.h"
4#include "freertos/task.h"
5#include "driver/gpio.h"
6#include "esp_log.h"
7
8#define LED_PIN GPIO_NUM_2 // DevKit dahili LED / on-board LED
9static const char *TAG = "blink"; // log etiketi / log tag
10
11void app_main(void)
12{
13 gpio_reset_pin(LED_PIN);
14 gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
15 int durum = 0;
16
17 while (1) {
18 durum = !durum;
19 gpio_set_level(LED_PIN, durum);
20 ESP_LOGI(TAG, "LED %s", durum ? "ON" : "OFF");
21 vTaskDelay(pdMS_TO_TICKS(500)); // ms -> tik çevirisi / ms to ticks (varsayılan 100 Hz / default 100 Hz)
22 }
23}FreeRTOS: present on both sides, configured differently
There is no program on the ESP32 without FreeRTOS; Arduino and ESP-IDF use the same kernel. The difference is in the defaults. In Arduino, loop() runs on core 1 as a task called loopTask with an 8 KB stack, and the tick rate is 1000 Hz, so vTaskDelay(1) waits one millisecond. In pure ESP-IDF, app_main() runs by default in the main task on core 0 with a stack of about 3.5 KB; the default tick rate is 100 Hz, so vTaskDelay(1) waits 10 ms. If you always write delays with pdMS_TO_TICKS() in code you port from Arduino, this difference won't bite you. For tasks, queues and semaphores in detail, see the ESP32 FreeRTOS dual-core article.
menuconfig and sdkconfig: where fine tuning happens
In an ESP-IDF project, the idf.py menuconfig command opens a menu-driven settings screen in the terminal. Every choice you make is written to the sdkconfig file in the project folder, and that part of ESP-IDF is rebuilt on the next build. There are hundreds of options, from the number of Wi-Fi buffers to disabling Bluetooth completely, from the log level to the flash size. In the Arduino core, sdkconfig is fixed in advance; the Tools menu only offers a few settings such as partition scheme, CPU frequency, PSRAM and core debug level. The table below shows where commonly needed settings live on each side.
| Setting | Arduino IDE | ESP-IDF (menuconfig) |
|---|---|---|
| Partition table | Tools > Partition Scheme | Partition Table |
| CPU frequency | Tools > CPU Frequency | Component config > ESP System Settings |
| Log level | Tools > Core Debug Level | Component config > Log |
| FreeRTOS tick rate | Fixed at 1000 Hz | Component config > FreeRTOS > Kernel |
| Main task stack | Fixed (loopTask 8 KB) | ESP System Settings > Main task stack size |
| Bluetooth on/off | Cannot change (enabled in the core) | Component config > Bluetooth |
| Flash encryption, secure boot | Not available | Security features |
Components and libraries
In ESP-IDF everything is a component: the Wi-Fi stack, the GPIO driver, the HTTP server and your own main folder too. Each component has its own CMakeLists.txt file that says which source files to compile and which other components it needs. You add ready-made components from Espressif's ESP Component Registry with the idf.py add-dependency command; it adds a line to the idf_component.yml file in the main folder, and the component is downloaded into managed_components on the first build. That's how led_strip for WS2812B strips, button for push buttons and various sensor driver components arrive. A typical project layout and the most used commands look like this:
1# Proje yapısı / project layout
2blink/
3 CMakeLists.txt # proje dosyası / project file
4 sdkconfig # menuconfig ayarları / menuconfig settings
5 main/
6 CMakeLists.txt # idf_component_register(SRCS "main.c" INCLUDE_DIRS ".")
7 idf_component.yml # bağımlılıklar / dependencies (add-dependency yazar / written by add-dependency)
8 main.c
9 managed_components/ # indirilen bileşenler / downloaded components
10
11# Komutlar (ESP-IDF terminalinde) / commands (in the ESP-IDF terminal)
12idf.py create-project blink
13idf.py set-target esp32 # esp32s3, esp32c3, esp32c6 ...
14idf.py add-dependency "espressif/led_strip"
15idf.py menuconfig
16idf.py build
17idf.py -p COM5 flash monitor # Linux/macOS: /dev/ttyUSB0 ; çıkış / exit: Ctrl+]Debugging: from Serial.print to JTAG
In Arduino, the main debugging tool is Serial.print. If you set Core Debug Level to Verbose in the Tools menu, you also see the core's own log_e, log_w and log_i messages, which is very handy for finding out why Wi-Fi won't connect. The Arduino IDE 2 debugger lets you set breakpoints on chips with built-in USB-JTAG such as the ESP32-S3 and ESP32-C3. In ESP-IDF, idf.py monitor automatically turns the addresses in the Backtrace line into file names and line numbers by looking them up in the ELF file whenever a crash happens. On top of that there is core dump, which saves the crash to flash, heap tracing for finding memory leaks, and full JTAG debugging with OpenOCD and GDB. On the classic ESP32 you connect an external adapter such as the ESP-Prog to GPIO 12, 13, 14 and 15 for JTAG; make sure you don't use those pins for anything else in the project. For the meaning of crash messages, see the ESP32 Guru Meditation article.
Using Arduino as an ESP-IDF component
If you want the best of both worlds, you can add the Arduino core to an ESP-IDF project as a component. That gives you every menuconfig setting while still using WiFi.h, Wire and many Arduino libraries from Library Manager. The one requirement is version compatibility: each Arduino core series is tied to a specific ESP-IDF version. At the time of writing the 3.3 series needs ESP-IDF 5.5; on a computer with ESP-IDF 6.0 installed this component may not compile.
- In the ESP-IDF terminal, create a new project: idf.py create-project hibrit, then idf.py set-target esp32.
- Add the Arduino component: idf.py add-dependency "espressif/arduino-esp32^3.3.0". The command writes the dependency into idf_component.yml.
- With idf.py menuconfig, set the FreeRTOS tick rate (CONFIG_FREERTOS_HZ) to 1000; the Arduino component requires it.
- In the Arduino Configuration menu, turn Autostart Arduino setup and loop on boot on or off. If on, you write setup() and loop() in main.cpp; if off, you call initArduino() inside app_main().
- Rename main/main.c to main.cpp and update the SRCS line in main/CMakeLists.txt accordingly.
- Build with idf.py build, then flash and watch the output with idf.py -p PORT flash monitor.
1// main/main.cpp — ESP-IDF projesinde Arduino bileşeni (Autostart kapalı)
2// Arduino component inside an ESP-IDF project (Autostart disabled)
3#include "Arduino.h"
4#include "esp_log.h"
5#include "esp_system.h"
6
7static const char *TAG = "hibrit";
8
9extern "C" void app_main(void)
10{
11 initArduino(); // Arduino çekirdeğini başlat / start the Arduino core
12 Serial.begin(115200);
13 pinMode(2, OUTPUT);
14
15 while (true) {
16 digitalWrite(2, !digitalRead(2)); // Arduino API
17 ESP_LOGI(TAG, "free heap: %lu",
18 (unsigned long) esp_get_free_heap_size()); // ESP-IDF API
19 vTaskDelay(pdMS_TO_TICKS(1000)); // FreeRTOS API
20 }
21}In this file you see three APIs in one function: digitalWrite() comes from Arduino, esp_get_free_heap_size() and ESP_LOGI from ESP-IDF, and vTaskDelay() from FreeRTOS. Because Autostart is off, setup() and loop() are never called; if you forget the initArduino() line, Arduino objects such as Serial and Wi-Fi are not set up. The extern "C" declaration is also required, because ESP-IDF looks for app_main() with C linkage; without it in a C++ file, the linker reports that app_main can't be found.
Moving over gradually with PlatformIO
The smoothest way to move from the Arduino IDE to ESP-IDF is PlatformIO, because you can try all three modes in the same project file just by changing the framework line: framework = arduino, framework = espidf, and both together with framework = arduino, espidf. One detail to watch: at the time of writing, PlatformIO's official espressif32 platform has stayed on the 2.0.x series of the Arduino core. To use the Arduino 3.x core, or Arduino and ESP-IDF together with current versions, you need to switch to the community-maintained pioarduino platform. Setup details are in the PlatformIO installation article, and the functions that changed from 2.x to 3.x are in the ESP32 Core 3.x migration guide.
1; platformio.ini — aynı projede üç ortam / three environments in one project
2
3; Arduino çekirdeği (resmî platform, Arduino 2.0.x) / Arduino core (official platform)
4[env:arduino]
5platform = espressif32
6board = esp32dev
7framework = arduino
8monitor_speed = 115200
9
10; Saf ESP-IDF: kaynaklar src/ içinde, app_main() / pure ESP-IDF: sources in src/, app_main()
11[env:idf]
12platform = espressif32
13board = esp32dev
14framework = espidf
15monitor_speed = 115200
16
17; Arduino 3.x + ESP-IDF birlikte (topluluk platformu pioarduino) / together (community platform pioarduino)
18[env:hibrit]
19platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
20board = esp32dev
21framework = arduino, espidf
22monitor_speed = 115200- Step 1: Stay in your Arduino project but start using ESP-IDF functions; as in the first example above, the gpio, esp_sleep and nvs APIs compile in Arduino too.
- Step 2: Move long jobs out of loop() into separate FreeRTOS tasks with xTaskCreatePinnedToCore(), and write delays with pdMS_TO_TICKS().
- Step 3: Make the project hybrid with framework = arduino, espidf; get access to menuconfig while keeping your Arduino libraries.
- Step 4: Replace Arduino-dependent libraries with ESP-IDF components; once all are gone, switch to framework = espidf and drop the Arduino component.
Which one should you choose?
| Your situation | Recommendation | Why |
|---|---|---|
| You're meeting the ESP32 for the first time | Arduino | Quick results, lots of examples and libraries |
| School project, competition, quick prototype | Arduino | Time is short and ready-made libraries decide |
| Sensor that runs on battery for months | ESP-IDF or hybrid | You fine-tune sleep modes and power management |
| Product for sale, OTA and security | ESP-IDF | Flash encryption, secure boot, partition table control |
| New chip such as ESP32-C6, H2 or P4 | ESP-IDF | New features arrive in ESP-IDF first |
| You need an Arduino library but also menuconfig | Hybrid (Arduino component) | You get the tools of both worlds |
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Arduino.h: No such file or directory in ESP-IDF | Arduino component not added | Add espressif/arduino-esp32 with idf.py add-dependency |
| undefined reference to app_main | No extern "C" in main.cpp | Write extern "C" void app_main(void) |
| FREERTOS_HZ error while building the Arduino component | Tick rate is 100 Hz | Set CONFIG_FREERTOS_HZ to 1000 in menuconfig |
| Dozens of build errors in the Arduino component | ESP-IDF version doesn't match the component | Install the ESP-IDF version the Arduino series needs (5.5 for 3.3) |
| Delays are 10 times too long or too short | vTaskDelay() written in ticks | Write every delay with pdMS_TO_TICKS(ms) |
| Stack overflow in task main | Main task stack is small (about 3.5 KB) | Increase Main task stack size or move the work to its own task |
| Arduino 3.x function not found in PlatformIO | Official platform installs the 2.0.x core | Use the pioarduino platform or write with the 2.x API |
The short answer: if you're learning and want quick results, start with Arduino, and as you get to know the ESP32 itself, mix ESP-IDF functions into your Arduino sketches. When you one day need menuconfig, secure boot or a new chip, switching won't mean starting from scratch; you'll carry on with the FreeRTOS and ESP-IDF calls you already know. If you haven't settled on a board yet, take a look at the what is ESP32 article first. Arduino and ESP-IDF aren't rivals but two steps of the same ladder: Arduino gets you quickly to a working circuit, and ESP-IDF lets you turn that circuit into a product. In the BlueGrays app's ESP32 projects you'll find LED, button, PWM, Wi-Fi, OTA and deep sleep examples with step-by-step circuit diagrams and ready code; building them with Arduino and then rewriting the same ideas with ESP-IDF functions is the most practical way to learn both worlds.
Frequently asked questions
Is ESP-IDF faster than Arduino?
Between well-written programs doing the same job there is no big difference, because the Arduino core also calls ESP-IDF functions. The Arduino layer adds a small overhead; calls such as digitalWrite() are slightly slower than writing a register directly. The real difference is that in ESP-IDF you can fine-tune CPU frequency, cache and Wi-Fi settings with menuconfig.
Can I use Arduino libraries in ESP-IDF?
Not directly in a pure ESP-IDF project, because those libraries rely on Arduino APIs such as Wire, SPI and digitalWrite. If you add the Arduino core to ESP-IDF as a component, most libraries work; you put each library in the components folder and give it its own CMakeLists.txt. With framework = arduino, espidf in PlatformIO, PlatformIO handles most of that for you.
Does ESP-IDF support C++?
Yes. ESP-IDF itself is written in C, but you can use .cpp files in the main folder and work with classes and the standard C++ library. The only rule is to declare app_main() with extern "C"; otherwise the linker can't find it.
How do I install ESP-IDF?
The easiest way is to install Espressif's ESP-IDF extension in VS Code or use Espressif's ESP-IDF Installation Manager (EIM); both download the toolchain, the Python environment and the ESP-IDF version you choose. On Windows, the idf.py commands are ready in the ESP-IDF terminal that opens after installation. The installation takes several GB and the first build takes a few minutes.
How do I port ESP32 code from the Arduino IDE to ESP-IDF?
The easiest way is to move the project to PlatformIO first and build it with framework = arduino, espidf; your code runs unchanged and you get access to menuconfig. Then you replace Arduino calls step by step with their ESP-IDF equivalents: ESP_LOGI instead of Serial, gpio_set_level instead of digitalWrite, vTaskDelay(pdMS_TO_TICKS()) instead of delay. Once no Arduino library is left, switch to framework = espidf.
Should a beginner start with ESP-IDF?
In most cases, no. Getting to know the ESP32's pins, Wi-Fi and sensors with Arduino first is far more productive than wrestling with CMake, menuconfig and the component system all at once. If your C skills are solid or your goal is to build a product straight away, starting with ESP-IDF also makes sense.
Projects to build after reading this
See all projects
LED Blink with ESP32
Teaches basic GPIO output usage with ESP32. We achieve a blinking effect by turning an LED on and off from a digital pin. ESP32 version of the classic blink project on Arduino UNO; the basic blink commands in the Arduino environment are the same, but the ESP32's pin layout and 3.3 V GPIO levels differ from those of the Arduino UNO.

ESP32 LED Control with Push Button (Push)
The LED lights up when the button is pressed and turns off when released. Shows how the ESP32's digital input pin and internal pull-up resistor are used. The INPUT_PULLUP mode eliminates the need for an external resistor.

ESP32 Built-in LED Blink
Blinking the built-in blue LED on the ESP32 DevKit V1. No external components required! The first project you should try when you buy an ESP32. GPIO 2 is connected to the built-in LED.

ESP32 Traffic Light
Real traffic light simulation with 3 LEDs red-yellow-green. Timings close to real traffic logic: red long, yellow short, green long. Classic example of sequential GPIO control.

ESP32 LED Fade with PWM
Smoothly changing the brightness of the LED from 0 to max, from max to 0. We control PWM with analogWrite() as in Arduino - the same syntax as ESP32 Arduino Core 3.0+ works without problems. Pin definition + pinMode + analogWrite is enough.

ESP32 Wi-Fi STA Connection (with LCD Screen)
In this project, we connect the ESP32 to the home Wi-Fi network in Station (STA) mode in a secure, fault-tolerant manner. We store the SSID and password in a separate secrets.h file to prevent leaking to Git, set up an auto-reconnect mechanism, and display the RSSI signal level and IP address on an I2C LCD screen. The internal LED works as a status indicator. It is a production-grade connection manager.

ESP32 OTA Update — Wireless Firmware Installation (With LCD Screen)
In this project you'll learn to upload new firmware to the ESP32 over Wi-Fi, without a USB cable. With the ArduinoOTA library the ESP32 becomes visible on the network and shows up automatically as bluegrays-ota under "Network port" in the Arduino IDE. The first upload goes over USB; after that every update is wireless, a key feature for devices out in the field.

ESP32 Deep Sleep — Battery Saving (OLED + RTC RAM Counter)
The ESP32's Deep Sleep mode shuts down the CPU and most peripherals, cutting current draw to about 10µA, which is vital for battery-powered IoT devices. This project uses three wake-up sources: a timer (15 s), an external pin (EXT0, the button on GPIO 33) and a touch pin (T0/GPIO 4). Counters marked with RTC_DATA_ATTR survive deep sleep.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 750+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

