← 返回
效率工具 中文

ESP32

Avoid common ESP32 mistakes — GPIO conflicts, WiFi+ADC2 trap, deep sleep gotchas, and FreeRTOS pitfalls.
规避ESP32常见错误——GPIO冲突、WiFi与ADC2陷阱、深度睡眠误区及FreeRTOS易错点。
ivangdavila
效率工具 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 3
Stars
📥 1,739
下载
💾 82
安装
1
版本
#latest

概述

GPIO Restrictions

  • Strapping pins boot behavior — GPIO0, GPIO2, GPIO12, GPIO15 affect boot mode
  • GPIO6-11 connected to flash — don't use, crashes immediately
  • GPIO34-39 input only — no output, no pullup/pulldown
  • ADC2 unusable with WiFi active — use ADC1 (GPIOs 32-39) when WiFi enabled

Deep Sleep

  • Only RTC GPIOs for wakeup — GPIO0, 2, 4, 12-15, 25-27, 32-39
  • RTC_DATA_ATTR for persistent variables — regular RAM lost in deep sleep
  • esp_sleep_enable_ext0_wakeup() for single pin — ext1 for multiple pins
  • WiFi reconnect takes 1-3 seconds after wake — plan for this delay

WiFi Gotchas

  • Call WiFi.mode() before WiFi.begin() — mode affects behavior
  • WiFi.setAutoReconnect(true) doesn't always work — implement reconnect in loop
  • Event-driven with WiFi.onEvent() more reliable — don't poll WiFi.status()
  • Static IP faster than DHCP — saves 2-5 seconds on connect

FreeRTOS

  • Default stack too small for printf/WiFi — use 4096+ for complex tasks
  • Task watchdog triggers at 5s default — call vTaskDelay() or feed watchdog
  • xTaskCreatePinnedToCore() for core affinity — WiFi on core 0, your code on core 1
  • delay() yields to scheduler — vTaskDelay(pdMS_TO_TICKS(ms)) in tasks

Memory

  • Heap fragments over time — preallocate buffers, avoid repeated malloc/free
  • ESP.getFreeHeap() for monitoring — log periodically in long-running apps
  • PSRAM available on some boards — heap_caps_malloc(size, MALLOC_CAP_SPIRAM)
  • String concatenation fragments heap — use reserve() or char arrays

Peripherals

  • No native analogWrite() — use LEDC: ledcSetup(), ledcAttachPin(), ledcWrite()
  • I2C needs external pullups usually — internal pullups too weak for fast speeds
  • SPI CS pin must be managed — SPI.begin() doesn't auto-configure
  • UART0 is Serial/USB — use UART1/2 for external devices

OTA Updates

  • Needs two OTA partitions — default partition scheme may have only one
  • Check ESP.getFreeSketchSpace() — OTA fails silently if not enough space
  • ArduinoOTA blocks during update — handle in loop, not in time-critical code

Power

  • Brown-out detector resets at ~2.4V — esp_brownout_disable() if using battery
  • WiFi TX uses 300mA peaks — power supply must handle spikes
  • Deep sleep ~10µA — but RTC peripherals add more if enabled

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 00:22 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,363 📥 319,033
productivity

Baidu web search

ide-rea
使用百度AI搜索引擎(BDSE)进行网络搜索。适用于获取实时信息、文档资料或研究课题。
★ 238 📥 105,752
productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 440 📥 148,111