Bring-up

Blink status LED

The first proof a board is alive. On a product this is the power or status lamp.

Bring-up GPIOStatus LED ESP32 family

Official path: examples/get-started/blink

01 Overview

The official Blink example (examples/get-started/blink) toggles one LED to prove GPIO output. It is the minimum heartbeat of any ESP32 board, and the first firmware you run on a fresh board. It verifies that the clock, boot, and GPIO driver are working.

  • Use when: first bring-up, fixture test, product status lamp.
  • Skip when: I/O is already proven and you are working on radios or sleep.
  • Official proves: the configured GPIO can toggle on a fixed period and source/sink enough current.
  • Official does not: size the resistor, place the lamp in an enclosure, or turn it off in sleep.
  • Note: the default 1 Hz blink is for validation only; a product must use a state machine to avoid misleading users.

02 Hardware

  • Chip: any ESP32-class module or DevKit; the example is portable.
  • Minimum parts: LED + series resistor (often 220Ω–1kΩ, choose based on LED current rating). Some modules have an onboard LED, but often without a series resistor — driving it directly may overcurrent the GPIO.
  • Pin: BLINK_GPIO in menuconfig. GPIO2 is common on ESP32-DevKit, GPIO8 on many C3 boards. Do not copy blindly.
  • Power: 3.3V. Do not drive the LED from a 5V pin.
  • Connection: LED anode to GPIO, cathode via resistor to GND; or anode to 3.3V, cathode via resistor to GPIO (active low). Mind the GPIO sink/source limits.
  • Production: the lamp must be visible through the housing; silkscreen polarity matters for SMT.
  • Layout: place the resistor close to the LED, keep traces short to avoid noise pickup.

03 Software flow

1. Select the GPIO in menuconfig or change the Kconfig default.

2. Reset the pin and set it as output.

3. Loop: high → delay → low → delay.

4. Newer trees may drive a WS2812 via RMT/led_strip — that is not a plain GPIO lamp.

5. Product firmware should encode states (boot, connected, error), not blink 1Hz forever.

6. Turn off the LED before deep sleep to avoid leakage.

7. If the LED is on an open-drain pin, add an external pull-up or pull-down.

04 Core points

  • Pin numbers change by chip. Copying GPIO2 from ESP32 to C3 will miss the lamp.
  • The DevKit LED is not your product LED. Custom boards need a new footprint.
  • Do not blink through deep sleep. Status policy is a power decision.
  • Custom work: status logic, GPIO map, schematic and PCB.
  • Size the resistor. Different LEDs have different forward voltages and current ratings; connecting directly may burn the LED or the pin.

中文

点亮与上电

Blink 状态指示灯

第一块板活没活,先看这颗灯。量产产品里它就是电源/状态指示。

点亮与上电 GPIO状态灯 ESP32 family

官方路径: examples/get-started/blink

01 项目概述

官方 Blink 示例(examples/get-started/blink)用一颗 LED 证明 GPIO 输出可用。这是所有 ESP32 硬件的最小心跳,也是新板第一次上电时最先跑的固件。

  • 适用: 新板第一次上电、产测治具、产品状态灯。
  • 不适用: 已经确认 IO 正常、要做通讯或低功耗的阶段。
  • 官方能证明: 配置的 GPIO 能按固定周期翻转,驱动能力正常。
  • 官方没做的: 限流电阻选型、灯的颜色与外壳开孔、低功耗时关掉指示。
  • 注意: 官方示例默认 1Hz 闪烁,只适合验证;产品上必须改成状态机,否则会误导用户。

02 项目硬件描述

  • 芯片: 任意 ESP32 系列开发板或模组,示例代码通用。
  • 最小物料: LED + 限流电阻(常见 220Ω–1kΩ,按 LED 额定电流选)。部分模组板载 LED,但通常没有限流电阻,直接接 GPIO 可能过流。
  • 引脚: 由 menuconfig 的 BLINK_GPIO 决定。ESP32-DevKit 常见 GPIO2,C3 常见 GPIO8,不能抄错。
  • 供电: 3.3V。LED 不要直接接 5V 脚,否则会过压损坏。
  • 连接: LED 阳极接 GPIO,阴极经电阻到 GND;或阳极接 3.3V,阴极经电阻到 GPIO(低电平点亮)。注意 GPIO 的灌电流能力。
  • 量产: 指示灯要能被外壳看到;贴片灯方向和丝印要对产线,防止贴反。
  • 布局: 电阻靠近 LED,走线短,避免长走线引入噪声。

03 项目软件流程描述

1. menuconfig 选定 GPIO,或改 Kconfig 默认值。

2. 复位该脚,设为输出。

3. 循环:置高 → delay → 置低 → delay。

4. 部分新示例对板载 WS2812 走 RMT/led_strip,和普通 GPIO 灯不是同一条驱动。

5. 产品固件应改成状态机:开机闪、联网常亮、错误快闪,而不是永久 1Hz。

6. 进入深睡前关闭 LED,避免漏电。

7. 若 LED 接在漏极开路引脚,需外部上拉或下拉。

04 项目核心点

  • 脚号随芯片变。 抄 ESP32 的 GPIO2 到 C3 会点不亮或点到别的功能。
  • 板载灯不等于你的产品灯。 定制板要重新画灯位和电阻。
  • 不要在深睡里还闪灯。 指示策略要和功耗一起定。
  • 可定制: 状态灯逻辑、GPIO 分配、原理图与 PCB。
  • 限流电阻必须算。 不同 LED 压降和额定电流不同,直接接 GPIO 可能烧灯或烧引脚。