01 Overview
GPIO is the most basic way for the ESP32 to exchange signals with the outside world. Each pin can be configured as input or output, with internal pull-up/pull-down, interrupt triggers (rising, falling, any edge), and open-drain mode.
This example demonstrates how to initialize GPIO, read button states, control relays, and handle interrupts. It solves the most common I/O needs in products: detecting external level changes and driving actuators.
Typical applications include: device panel buttons, door/magnetic alarm inputs, relay control (e.g., lights, pumps, fans), and simple level detection (e.g., comparator output for battery voltage).
GPIO is suitable for low-speed, non-timing-critical signals. For protocols requiring precise timing (e.g., WS2812, DHT11, or high-speed SPI), use dedicated peripherals like RMT, SPI, or I2S.
This example does not cover analog sampling (ADC), PWM output, or communication protocols; those are covered by other examples.
Understanding GPIO electrical characteristics and software configuration is fundamental to product stability; incorrect pull-ups or drive circuits can cause false triggers or device damage.