ESP32 Variant Comparison📖 Reference
Quick comparison of ESP32 chip variants to choose the right one for your project.
⚡ All variants support Arduino IDE and MicroPython. ESP32-S3 is recommended for new USB HID, camera, or AI/ML projects.
Quick comparison of ESP32 chip variants to choose the right one for your project.
ESP32 (original / classic) CPU: Dual-core 240 MHz Xtensa LX6 RAM: 520 KB SRAM WiFi: 802.11 b/g/n 2.4 GHz BT: Bluetooth 4.2 + BLE 4.2 GPIO: 34 usable, 18x ADC, 2x DAC, no native USB Best for: General IoT, huge community, great library support ESP32-S2 CPU: Single-core 240 MHz Xtensa LX7 RAM: 320 KB SRAM WiFi: 2.4 GHz, no Bluetooth at all GPIO: 43 usable, 20x ADC, 2x DAC, native USB-OTG Best for: USB HID devices, more GPIO, no BT needed ESP32-S3 (recommended for new projects) CPU: Dual-core 240 MHz Xtensa LX7 RAM: 512 KB SRAM + optional 8 MB PSRAM WiFi: 2.4 GHz BT: BLE 5.0 GPIO: 45 usable, native USB-OTG, vector instructions Best for: USB HID, camera + display, AI/ML acceleration ESP32-C3 CPU: Single-core 160 MHz RISC-V RAM: 400 KB SRAM WiFi: 2.4 GHz BT: BLE 5.0 GPIO: 22 usable, native USB-serial (not full OTG) Best for: Low-cost BLE sensors, small enclosures ESP32-C6 CPU: Single-core 160 MHz RISC-V RAM: 512 KB SRAM WiFi: 2.4 GHz + WiFi 6 (802.11ax) BT: BLE 5.3, Zigbee, Thread (802.15.4) Best for: Matter/Zigbee home automation
Flash MicroPython — ESP32⌨ Command
Erase ESP32 flash and install MicroPython firmware using esptool.
⚡ Adjust the port: /dev/ttyUSB0 (Linux), /dev/cu.usbserial-* (Mac), COM3 (Windows).
Erase ESP32 flash and install MicroPython firmware using esptool.
# Install esptool pip install esptool # Find your port # Linux: ls /dev/ttyUSB* # Mac: ls /dev/cu.* # Windows: Device Manager -> Ports # 1. Erase the flash completely esptool.py --port /dev/ttyUSB0 erase_flash # 2. Download firmware for your chip: # https://micropython.org/download/ # Choose ESP32 / ESP32-S3 / ESP32-C3 as appropriate # 3. Flash (original ESP32 -- offset 0x1000) esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 \ write_flash -z 0x1000 esp32-vX.X.X.bin # 4. Flash (S2, S3, C3 -- offset 0x0) esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 460800 \ write_flash -z 0x0 ESP32_GENERIC_S3-vX.X.X.bin # 5. Connect: Thonny auto-detects, or serial at 115200 baud
ESP32 WiFi — MicroPython💻 Code
Connect ESP32 to Wi-Fi in MicroPython with reconnect handling. Save as boot.py to run before main.py.
Connect ESP32 to Wi-Fi in MicroPython with reconnect handling. Save as boot.py to run before main.py.
import network, time
SSID = 'YourSSID'
PASSWORD = 'YourPassword'
def connect_wifi():
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if wlan.isconnected():
return wlan.ifconfig()[0]
wlan.connect(SSID, PASSWORD)
timeout = 15
while not wlan.isconnected() and timeout > 0:
print('.', end='')
time.sleep(1)
timeout -= 1
if wlan.isconnected():
ip = wlan.ifconfig()[0]
print(f'\nConnected: {ip}')
return ip
print('\nFailed to connect')
return None
# Access Point mode (create your own network)
def start_ap(ssid='ESP32-AP', pwd='12345678'):
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid=ssid, password=pwd, authmode=3)
print('AP IP:', ap.ifconfig()[0])Arduino IDE — ESP32 Setup⌨ Command
Configure Arduino IDE to program any ESP32 board.
⚡ Always check Espressif's GitHub for the latest board package URL.
Configure Arduino IDE to program any ESP32 board.
1. File -> Preferences -> Additional Boards Manager URLs: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json 2. Tools -> Board -> Boards Manager -> search 'esp32' Install: esp32 by Espressif Systems (v3.x recommended) 3. Select your board: Tools -> Board -> ESP32 Arduino -> [your board] Common: ESP32 Dev Module, LOLIN D32, ESP32-S3 Dev Module 4. Upload settings: Tools -> Upload Speed -> 921600 Tools -> Port -> your port 5. Hold BOOT button during upload if upload fails 6. Monitor: Tools -> Serial Monitor -> 115200 baud
ESP32 GPIO & PWM — Arduino💻 Code
GPIO, analogue read and PWM using the ESP32 Arduino core (LEDC peripheral).
⚡ ADC2 pins (GPIO 0,2,4,12-15,25-27) are unavailable when WiFi is active. Use ADC1 pins (GPIO 32-39) with WiFi.
GPIO, analogue read and PWM using the ESP32 Arduino core (LEDC peripheral).
// Basic I/O
const int LED = 2; // On-board LED on most ESP32 DevKit boards
const int BTN = 0; // BOOT button
void setup() {
Serial.begin(115200);
pinMode(LED, OUTPUT);
pinMode(BTN, INPUT_PULLUP);
}
void loop() {
digitalWrite(LED, !digitalRead(BTN));
}
// Analogue read (12-bit: 0-4095)
int val = analogRead(34); // ADC1 pin -- safe with WiFi
float v = val * 3.3f / 4095.0f;
// PWM using LEDC (replaces analogWrite on ESP32)
const int FREQ = 5000;
const int CHAN = 0;
const int RES = 8; // 8-bit: 0-255
ledcSetup(CHAN, FREQ, RES);
ledcAttachPin(LED, CHAN);
ledcWrite(CHAN, 128); // 50% duty cycle
// Interrupt on falling edge
void IRAM_ATTR handleIRQ() { /* keep very short */ }
attachInterrupt(BTN, handleIRQ, FALLING);No entries match