Arduino core for ESP32
Espressif's official Arduino support for the ESP32 family; can also be used as an ESP-IDF component.
software
also known as arduino-esp32, Arduino ESP32, Arduino-ESP32
Knowledge about Arduino core for ESP32
- Arduino millis() rollover: compare durations, never timestampsprocedure · unverified · millis() wraps to zero after about 50 days. Code that subtracts timestamps as unsigned long (now - start >= interval) keeps working across the wrap; code that compares timestamps directly (now >= start + interval) breaks.
- ESP32 'Interrupt wdt timeout on CPU1': don't print or wait inside an interrupt handlerwarning · unverified · Calling Serial.print, delay or other slow code inside an attachInterrupt handler blocks the CPU and trips the interrupt watchdog. Set a volatile flag in the ISR and do the work in loop() or a task.
- ESP32 FreeRTOS task crashes: 'Stack canary watchpoint triggered' and tasks that returnwarning · unverified · Two classic crashes when using xTaskCreate on ESP32: a task stack that is too small (Stack canary watchpoint triggered) and a task function that simply returns. Size stacks generously and end tasks with vTaskDelete(NULL).
- ESP32 OTA updates that can't brick the device: partitions, validation and rollbackprocedure · unverified · OTA needs two app partitions (ota_0, ota_1) plus otadata. With app rollback enabled, a new image boots as pending-verify and must call esp_ota_mark_app_valid_cancel_rollback() after a self-test, otherwise the bootloader reverts to the previous image.
- ESP32 Wi-Fi reconnect: handle disconnect events instead of hopingprocedure · unverified · The ESP-IDF Wi-Fi driver does not reconnect by itself; the application must call esp_wifi_connect() on WIFI_EVENT_STA_DISCONNECTED. In Arduino, use WiFi.setAutoReconnect() and WiFi.onEvent(), keeping callbacks thread-safe.
- ESP32 analogRead() is non-linear: use analogReadMilliVolts() and the right attenuationwarning · unverified · Raw ESP32 ADC counts don't map linearly to voltage and the reference voltage varies between chips. Espressif confirmed the non-linear ADC front end; use the calibrated analogReadMilliVolts() (ESP-IDF: ADC calibration) and stay inside the attenuation's input range.
- ESP32 deep sleep in Arduino: timer and button wake-up, RTC memory, wake causecode · unverified · Deep sleep powers down the CPUs and most RAM; only RTC memory survives and the sketch restarts from setup() on wake-up. Example with timer and GPIO wake-up and an RTC_DATA_ATTR counter.
- ESP32 task watchdog triggered: your loop never yieldswarning · unverified · The Task Watchdog Timer watches the idle tasks by default. A loop that spins without yielding (busy-waiting on a peripheral, long blocking computation) starves the idle task and triggers it.
- ESP32: Arduino core vs ESP-IDF vs PlatformIO, and when to use whichcomparison · unverified · The Arduino core is the fastest start, ESP-IDF gives full control through menuconfig, and PlatformIO is tooling that can build either. Arduino can also run as an ESP-IDF component to get both.
- Fix ESP32 upload errors: "Failed to connect" and "Wrong boot mode detected"procedure · unverified · Upload failures mean the chip didn't enter download mode. Check the port, cable, drivers and power, enter download mode manually with BOOT (GPIO0) + EN, and lower the baud rate. Native-USB chips can drop off the bus in sleep or after reconfiguring USB pins.
- Logging sensor data often on ESP32: buffer in RTC RAM, write flash in batchesrecommendation · unverified · Writing every reading to flash wears it out and costs energy. Keep readings in RTC slow memory across deep sleep, flush them in batches, use NVS only for rarely changing settings, and leave headroom in SPIFFS.
- Store ESP32 settings with Preferences (NVS): limits and a safe patterncode · unverified · Preferences stores key-value data in the NVS flash partition and survives restarts and power loss. Namespaces and keys are limited to 15 characters, and NVS is meant for many small values, not large data.
Related
- alternative to: ESP-IDF – Arduino APIs are quicker to start with; ESP-IDF exposes every configuration option. Arduino can also run as an ESP-IDF component.
- part of: Arduino – Arduino platform support for ESP32 chips.