Tuesday, 13 May 2025

Hand Gesture Controlled LEDs with ESP32 and Python

Hand Gesture Controlled LEDs with ESP32 and Python

This project demonstrates how to control LEDs using hand gestures by integrating an ESP32 microcontroller with Python-based computer vision libraries. Utilizing OpenCV and MediaPipe, the system captures hand gestures via a webcam and translates them into commands sent to the ESP32 over Wi-Fi. The ESP32 then controls LEDs connected to its GPIO pins based on these commands.

Components Required
  • ESP32 Board
  • 5 LEDs (representing Thumb, Index, Middle, Ring, Pinky)
  • 5 Resistors (220Ω each)
  • Breadboard and Jumper Wires
  • Webcam
  • Computer with Python Installed
Circuit Setup for ESP32 Hand Gesture Project
Circuit Diagram of Hand Gesture Controlled LEDs with ESP32 and Python


Each LED is connected to a specific GPIO pin on the ESP32 (e.g., GPIO14, GPIO27, GPIO26, GPIO25, GPIO33). A 220Ω resistor is placed in series with each LED to limit current. The anode of each LED connects to the GPIO pin, and the cathode connects to the ground.


Python Script for Gesture Detection

On the computer, a Python script uses OpenCV to capture video from the webcam and MediaPipe to detect hand landmarks. It determines which fingers are raised and sends corresponding HTTP requests to the ESP32 to control the LEDs. For instance, raising the index finger sends a request to /led/index/on. If all fingers are lowered, a special command can be sent to perform a predefined action, such as turning off all LEDs.

In practice, this system allows for intuitive control of LEDs through simple hand gestures. Raising a specific finger turns on the corresponding LED, while lowering it turns the LED off. This real-time interaction demonstrates the seamless integration of computer vision and microcontroller-based hardware control. The project serves as a foundational example for more complex gesture-controlled applications, such as home automation or robotic control systems.

ESP32 Hand Gesture Project - Working Demo

ESP32 Hand Gesture Project - Working Demo

No comments:

Post a Comment