This project allows you to control a fan using hand gestures detected via OpenCV, cvzone and an Arduino board. The system can use a esp32 microcontroller to receives commands from a Python script running on the a computer and pass them to a motor_controller The Python script detects hand gestures using OpenCV and sends the corresponding commands to the microcontroller to control the fan speed.
This is done as a group practical for our TCC2 (Technology Challenge Competition) module in the University.
- Demo
- Overview
- Features
- Hardware Requirements
- Software Requirements
- Installation
- Usage
- Project Structure
- Arduino Code
- Python Code
- License
The project consists of three main components:
- Python Script: Detects hand gestures using OpenCV and sends commands to the Arduino.
- ESP32 sketch: Receives commands from the Python script and controls the fan accordingly.
- Hand gesture detection using OpenCV
- Fan speed control based on detected gestures
- WiFi communication between the PC and the microcontroller
- Real-time feedback on fan speed and connection status
- ESP32 microcontroller
- Fan (or motor) with speed control
- OLED display for feedback
- Temperature sensor (optional)
- Python 3.10 or above
- OpenCV
- cvzone
- Arduino IDE
- Install the Arduino IDE from Arduino's official website.
- Connect your microcontroller board to your PC.
- Upload the provided sketch (
esp32_sketch.ino
) to the microntroller.
-
Clone this repository to your local machine.
git clone https://github.com/Teammate-2-0/Smart-Fan-Control-System.git cd smart-fan-control
-
Creating a virtual environment is recommended (You can skip this if you prefer to install libs globally)
in python3
python -m venv my-env # For Windows and Unix .\my-env\Scripts\activate # For Windows source my-env/bin/activate # For unix
in conda
conda create -n my-env conda activate my-env
-
Install the required Python libraries.
in python3
pip install opencv-python cvzone
-
Arduino Setup: Ensure your microcontroller is connected to the PC and powered on.
-
Python Script: Run the Python script to start detecting hand gestures and sending commands to the Arduino.
python main.py
The Python script uses OpenCV to detect hand gestures. Depending on the number of fingers detected, it sends a command to the Arduino to control the fan speed and on/off status. Key Functions