Ugenz Academy/IoT Tutorial

ESP32 GPIO and Peripherals

Learn how to control ESP32 GPIO pins, read analog signals, generate PWM, use timers and interrupts, communicate with peripherals, and debug embedded programs.

3 min read574 words

Reading progress

Keep learning

What you'll learn

  • Understand digital and analog input/output
  • Control LEDs, buttons, sensors, and other electronic components
  • Learn ADC, DAC, and PWM concepts
  • Understand UART, I2C, SPI, and I2S communication
  • Use timers, interrupts, and millis() for time-based tasks
  • Debug ESP32 programs using the Serial Monitor
  • Apply peripheral concepts in practical IoT projects

ESP32 GPIO and Peripherals

Welcome to the ESP32 GPIO and Peripherals section at Ugenz Academy. GPIO pins and built-in peripherals allow an ESP32 to interact with electronic components, collect sensor readings, control actuators, and communicate with other devices.

In this section, you will learn how to use digital and analog signals, generate PWM output, communicate with peripherals, perform time-based operations, and debug your programs.

What You Will Learn

  • Digital inputs and outputs
  • Analog input and output capabilities
  • ADC, DAC, and PWM
  • UART, I2C, SPI, and I2S interfaces
  • Timers, interrupts, and non-blocking timing
  • Serial communication and debugging techniques

Learning Path

Follow these lessons in order.

1. Digital and Analog I/O

Learn how to read inputs and control outputs using ESP32 GPIO pins.

Topics include:

  • Configuring pins as inputs or outputs
  • Reading buttons and digital sensors
  • Controlling LEDs and other compatible outputs
  • Understanding analog sensor readings
  • Using pinMode(), digitalRead(), and digitalWrite()

Start learning: Digital and Analog I/O

2. ADC, DAC, and PWM

Understand how the ESP32 works with analog signals and generates output signals.

Topics include:

  • Analog-to-digital conversion (ADC)
  • Digital-to-analog conversion (DAC), where supported
  • Pulse-width modulation (PWM)
  • LED brightness control
  • Motor speed control using a suitable driver
  • Reading and interpreting sensor values

Start learning: ADC, DAC, and PWM

3. I2C, SPI, UART, and I2S

Explore communication interfaces used to connect displays, sensors, storage devices, audio peripherals, and other microcontrollers.

Topics include:

  • I2C communication
  • SPI communication
  • UART serial communication
  • I2S digital audio
  • Wiring and pin configuration
  • Choosing the right interface for a project

Start learning: I2C, SPI, UART, and I2S

4. Timers, Interrupts, and millis()

Learn how to manage time-dependent tasks and respond to hardware events.

Topics include:

  • Hardware timer concepts
  • Interrupt service routines
  • Button and sensor events
  • Non-blocking timing with millis()
  • Periodic operations without unnecessary delays
  • Avoiding long-running operations inside interrupts

Start learning: Timers, Interrupts, and millis()

5. Serial Monitor and Debugging

Learn how to inspect program behavior and troubleshoot common ESP32 problems.

Topics include:

  • Initializing serial communication
  • Printing values and status messages
  • Monitoring sensor readings
  • Identifying compilation and runtime problems
  • Diagnosing wiring and communication issues
  • Using debugging messages effectively

Start learning: Serial Monitor and Debugging

Practical Projects

Apply these concepts by building projects such as:

  • LED control with a push button
  • Automatic night light using an LDR
  • Sensor data monitoring through the Serial Monitor
  • PWM-based LED brightness control
  • Ultrasonic distance measurement
  • I2C LCD or OLED display integration
  • Non-blocking LED and buzzer control
  • Event-based sensor alerts

Hardware and Safety Notes

ESP32 GPIO pins generally use 3.3 V logic and are not designed to accept arbitrary 5 V signals. Use suitable level shifting when required, and do not drive motors or other high-current loads directly from GPIO pins.

Peripheral availability differs between ESP32 variants. For example, DAC channels and ADC capabilities vary by chip, and some pins may be reserved for flash, boot configuration, or other board functions. Consult the datasheet and pinout for your exact ESP32 model.

Next Step

Start with Digital and Analog I/O, then continue through the remaining lessons to learn how to connect and control hardware using your ESP32.

Learn • Build • Protect • Grow — Ugenz Academy

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy