ESP32
Espressif ESP32 Wi-Fi/Bluetooth SoC design, firmware, and power considerations.
The ESP32 is Espressif Systems' dual-core Xtensa LX6 (or RISC-V for the ESP32-C series) system-on-chip, integrating Wi-Fi, Bluetooth/BLE, and a comprehensive peripheral set in a compact, low-cost package. It is one of the most widely used SoCs for IoT products and connected embedded applications.
What Is the ESP32?
The ESP32 family covers a range of SoCs sharing Espressif's SDK:
- ESP32 — dual-core Xtensa LX6 at 240 MHz, Wi-Fi 802.11 b/g/n, Bluetooth Classic + BLE 4.2, 520 KB SRAM, extensive peripheral set. The original and most capable variant.
- ESP32-S3 — dual-core Xtensa LX7 at 240 MHz, Wi-Fi + BLE 5.0, with AI acceleration (vector instructions), USB OTG. Best choice for ML at the edge.
- ESP32-C3 — single-core RISC-V at 160 MHz, Wi-Fi + BLE 5.0. Lower cost and power than ESP32; ideal for simple connected sensors.
- ESP32-C6 — RISC-V, Wi-Fi 6 (802.11ax), BLE 5.0, and Thread/Zigbee (802.15.4). The choice for Matter-based smart home applications.
- ESP32-S2 — single-core Xtensa LX7 at 240 MHz, Wi-Fi only, USB OTG, more GPIO than ESP32. Good for USB HID and Wi-Fi-only applications.
This subtopic is part of the Embedded Systems topic.
Why Use the ESP32?
- Integrated wireless — Wi-Fi and BLE in a single chip eliminates the separate radio module and its certification complexity (Espressif-certified modules are pre-certified for many markets including Australia).
- Cost — bare ESP32 SoCs and pre-certified modules (WROOM, WROVER, MINI series) are among the lowest-cost options for connected embedded products.
- Ecosystem — ESP-IDF (the official Espressif SDK, based on FreeRTOS) and the Arduino-ESP32 framework provide a large community, many libraries, and good documentation.
- Power management — the ESP32 supports several low-power modes including Light Sleep and Deep Sleep, enabling battery-powered operation with adequate management.
Key Concepts
- ESP-IDF — Espressif IoT Development Framework; the official SDK based on FreeRTOS with drivers for all ESP32 peripherals. The recommended framework for production commercial products.
- Arduino-ESP32 — the Arduino framework port for ESP32. Simpler to get started but less control over FreeRTOS tasks, Wi-Fi stack, and power management.
- WROOM / WROVER module — pre-certified ESP32 modules with integrated flash and antenna. WROOM has no external PSRAM; WROVER adds 4–8 MB PSRAM for larger data buffers.
- RF calibration — the ESP32's Wi-Fi and BLE performance is calibrated at the module level; the host PCB must maintain the antenna keepout and reference design layout to preserve the module's certified RF performance.
- Dual core / single core operation — the ESP32's two cores (PRO_CPU and APP_CPU) can run independently or be used together; tasks can be pinned to a specific core for determinism.
- Deep Sleep — a low-power state where the CPU and most peripherals are off; the ULP co-processor and RTC domain remain active. Wake sources include RTC timer, GPIO, touch sensor, and ULP co-processor.
Common Tools and Software
- VS Code with ESP-IDF extension — Espressif's official ESP-IDF extension for VS Code provides project creation, build, flash, monitor, and JTAG debug integration in one workflow. The recommended development environment for new ESP-IDF projects.
- ESP-IDF CLI —
idf.pybuild system tool (wraps CMake and Ninja) providesidf.py build,idf.py flash,idf.py monitor, andidf.py menuconfigfrom the terminal. - esptool.py — Espressif's open-source flash utility for UART firmware flashing. Used by ESP-IDF and Arduino-ESP32 under the hood; also useful for manual flashing and reading flash contents.
- Arduino IDE / Arduino-ESP32 — the Arduino framework port for ESP32; lower barrier to entry than ESP-IDF, suitable for prototyping and community-library-heavy projects.
- ESP-PROG — Espressif's JTAG debug adapter for ESP32. Connects to the ESP32's JTAG pins and enables on-target debugging through OpenOCD and the VS Code ESP-IDF extension.
Common Mistakes
- Using bare ESP32 SoC instead of a pre-certified module for a regulated product — the ESP32 SoC alone is not RF-certified; placing it on a custom PCB with a custom antenna requires full radio type acceptance (RCM radio certification for Australia). Pre-certified modules (WROOM-32, S3-MINI, C3-MINI, etc.) carry Espressif's ACMA certification, drastically reducing the compliance effort for the host product.
- Not following the module's reference design for antenna keepout — using an ESP32 module with a PCB trace antenna or on-board ceramic antenna and then violating the antenna keepout zone (placing copper, vias, or components under the antenna) detunes the antenna and degrades RF performance. This typically invalidates the module's certification in the host PCB context.
- Blocking the main FreeRTOS task with delays or blocking calls — ESP-IDF is built on FreeRTOS;
vTaskDelay()and non-blocking event patterns are the correct approach. Long blocking calls in a task ordelay()inherited from Arduino patterns can starve the Wi-Fi and BLE stacks running on the other core, causing connectivity drops. - Not measuring actual Deep Sleep current — ESP32 Deep Sleep current varies significantly with configuration: RTC peripherals left on, GPIO state, and power domain settings all affect the actual figure. Measure with a current analyser (Nordic PPK2, Otii Arc, or current-sensing setup) rather than relying on datasheet typical values.
- Using Arduino-ESP32 for a production product where ESP-IDF is the right choice — Arduino-ESP32 hides task management, Wi-Fi stack configuration, and power management behind a simplified API that is appropriate for prototyping but limits control in production. The
loop()function runs as a single FreeRTOS task; complex concurrent behaviour requires understanding the underlying FreeRTOS architecture anyway.
Common Questions
Should I use the bare ESP32 chip or a pre-certified module (WROOM/WROVER)?
For most products, use a pre-certified module. The ESP32 SoC alone is not RF-certified; placing it on a PCB with a custom antenna requires full radio certification in each target market, which is expensive and time-consuming. Pre-certified modules (ESP32-WROOM-32, ESP32-S3-MINI, etc.) carry Espressif's ACMA certification for Australia, simplifying the compliance path. The bare SoC makes sense only for very high-volume products where the module cost premium is significant and a custom antenna design is worth the full certification effort.
How do I reduce ESP32 power consumption in a battery application?
Use Deep Sleep mode with an RTC timer or GPIO wake source for the majority of time; the CPU's active power draw is typically 80–150 mW, while Deep Sleep can be under 10 µA. Wi-Fi and BLE are the dominant power consumers during active use; minimise their on-time. Use ESP-IDF's Wi-Fi power save mode (modem sleep) when the radio must stay connected. Measure the actual current waveform with a current analyser — advertising packets, DHCP, and TCP keepalives all create unexpected wake events.
What is the difference between ESP-IDF and Arduino for ESP32?
ESP-IDF is Espressif's native SDK based on FreeRTOS; it provides full access to all hardware features, well-structured multitasking, and is the framework used by professional firmware teams. Arduino-ESP32 wraps ESP-IDF with the Arduino API (setup()/loop(), familiar library ecosystem); it is faster to get started but provides less control and abstraction of the underlying FreeRTOS. For production products, ESP-IDF is the better choice. Zeus Design develops ESP32 firmware using ESP-IDF for connected IoT products.
Knowledge Base
ESP32 Foundations
- ESP32 Variants Compared: How Do You Choose the Right One? — ESP32 vs S3 vs C3 vs C6 vs H2: architecture, wireless capabilities, and which variant suits which application
- ESP-IDF vs Arduino for ESP32: Which Framework to Use? — when each framework is right, key differences in FreeRTOS control and power management, and how to migrate
- How Do You Choose a Microcontroller? — the selection framework for evaluating ESP32 vs STM32 vs nRF and other MCU families
- What Is an RTOS? — ESP-IDF is built on FreeRTOS; understanding tasks, queues, and semaphores is essential for ESP-IDF development
- Bare-Metal vs RTOS: Which Should You Use? — why the ESP32 is almost always used with FreeRTOS (ESP-IDF)
Wireless on the ESP32
- How Do You Set Up Wi-Fi and Provision an ESP32 Device? — station mode, event loop, SoftAP and BLE provisioning, and the ESP32 HTTP server
- How Does BLE Work on the ESP32? — GATT server setup, NimBLE vs Bluedroid, advertising, notify vs indicate, and connection parameters
- Bluetooth vs Wi-Fi vs LoRa vs Zigbee: Which Protocol Should You Use? — choosing the right wireless stack when the ESP32's Wi-Fi and BLE are both available
- What Are RF Signals and Frequency Bands? — frequency bands used by ESP32's Wi-Fi (2.4 GHz and 5 GHz) and BLE (2.4 GHz)
Hardware Peripherals
- How Do You Use GPIO, ADC, and Timers on the ESP32? — GPIO configuration with gpio_config(), strapping pins to avoid, ADC1 vs ADC2 (Wi-Fi conflict), calibration API with calibrated millivolt output, and periodic timers with esp_timer and GPTimer
Power Management
- How Do You Manage Power and Use Deep Sleep on the ESP32? — active, modem sleep, light sleep, deep sleep modes; RTC wake sources, ULP co-processor, and battery runtime estimation
PCB Design for the ESP32
- How Should You Lay Out the RF Section of a PCB? — antenna keepout zones and ground plane requirements for ESP32 module designs
- What Antenna Types Are Used in Embedded Wireless Designs? — choosing between on-module PCB trace antennas and external antenna options
Forum Discussions
ESP32 keeps dropping Wi-Fi after 20–30 minutes in deployed location — reconnect loop doesn't always recover
Having a frustrating one. Built an ESP32 environmental monitor (SHT40 temp/humidity, reports to an MQTT broker every 5 minutes). Works flawl
Is a double-sided PCB enough for a simple ESP32 sensor board, or should I go multi-layer?
Building a little battery-powered sensor board around an ESP32 module (the kind with the PCB antenna already built into the module, not desi