Sensors and I/O

GPIO in and out

Buttons, relays, level detect. The I/O baseline.

Sensors and I/O GPIOButton / relay ESP32 family

Official path: examples/peripherals/gpio/generic_gpio

01 Overview

Direction, interrupts, pulls.

  • Use when: buttons, alarm in, relays.
  • Skip when: high-speed timing (RMT/SPI).

02 Hardware

  • Debounce inputs; watch 3.3V tolerance.
  • Relays need a driver and flyback diode — never direct GPIO.
  • Long cables need ESD and filtering.

03 Software flow

1. Pin, direction, pulls.

2. ISR or poll.

3. Debounce keys; interlock relays.

04 Core points

  • Strapping pins are not casual buttons.
  • Custom work: I/O map, protection, key/relay logic.

中文

传感器与外设

GPIO 通用输入输出

按键、继电器、电平检测。产品 IO 的基础课。

传感器与外设 GPIO按键 / 继电器 ESP32 family

官方路径: examples/peripherals/gpio/generic_gpio

01 项目概述

配置输入/输出、中断、上下拉。

  • 适用: 按键、告警输入、继电器。
  • 不适用: 高速时序(看 RMT/SPI)。

02 项目硬件描述

  • 输入要防抖、注意 3.3V 容忍。
  • 继电器需驱动管和续流二极管,不要直驱 GPIO。
  • 长线输入要 ESD 和滤波。

03 项目软件流程描述

1. 选脚、方向、上下拉。

2. 中断或轮询。

3. 产品按键要软件防抖,继电器要互锁。

04 项目核心点

  • Strapping 脚上电有特殊功能,不能随便当按键。
  • 可定制: IO 表、保护电路、按键/继电器逻辑。