# π RGB LED Strip Control System - Custom Project Guide ## πΎ YouTube Video [YouTube Video](https://youtube.com/shorts/QAX4ULTzuk8) ## π Project Overview This document details an ESP32-based RGB LED control system with the following capabilities: - π 2-channel PWM control for red and green LED strips - π Automatic relay control after 19:00 based on Turkey/Istanbul time - π± Web interface and physical button control - π HC-SR04 presence detection for energy saving - π€οΈ LED dance mode based on Turkey/Ankara weather conditions ## π οΈ Hardware Details ### π§ Required Components | Component | Qty | Notes | |----------------------|-----|----------------------------| | ESP32 DevKit v1 | 1 | Other versions compatible | | IRFZ44N MOSFET | 2 | For red and green LEDs | | 5V Relay Module | 1 | Room light control | | HC-SR04 | 1 | Distance measurement | | 128x64 OLED (I2C) | 1 | GPIO6 SDA, GPIO7 SCL | | 10K Potentiometer | 2 | GPIO4 and GPIO5 | | Button | 3 | GPIO8, GPIO9, GPIO10 | | 10K Resistor | 5 | For pull-up | | Breadboard | 1 | Prototyping | | Jumper Wires | 20+ | For connections | ### ποΈ Pin Connection Diagram ```mermaid graph TD; ESP32-->|GPIO4|POT1[Potentiometer 1]; ESP32-->|GPIO5|POT2[Potentiometer 2]; ESP32-->|GPIO8|BTN1[Button 1]; ESP32-->|GPIO9|BTN2[Button 2]; ESP32-->|GPIO10|BTN3[Button 3]; ESP32-->|GPIO12|MOSFET1[IRFZ44N Red]; ESP32-->|GPIO13|MOSFET2[IRFZ44N Green]; ESP32-->|GPIO21|RELAY1[Relay]; ESP32-->|GPIO7|OLED_SCL[OLED SCL]; ESP32-->|GPIO6|OLED_SDA[OLED SDA]; ESP32-->|GPIO14|TRIG[HC-SR04 Trig]; ESP32-->|GPIO15|ECHO[HC-SR04 Echo]; MOSFET1-->LED1[Red LED Strip]; MOSFET2-->LED2[Green LED Strip]; RELAY1-->LIGHT[Room Light]; ``` ### β‘ Power Management ```mermaid pie title Power Consumption (Maximum) "ESP32" : 120 "LED Strip (12V)" : 2000 "Relay Module" : 80 "HC-SR04" : 15 "OLED Display" : 25 ``` ## πΎ Software Installation ### π₯ Required Libraries 1. **Core Libraries**: - `Adafruit_GFX` (v1.10.12) - `Adafruit_SSD1306` (v2.5.7) - `WiFi` (v2.0.0) - `ESPAsyncWebServer` (v3.1.0) 2. **Time and Weather**: - `NTPClient` (v3.2.1) - `ArduinoJson` (v6.19.4) - `HTTPClient` (v1.2) ### βοΈ Code Structure (Detailed) ```plaintext /RGB-Control-System-with-ESP32-C6 βββ /web-server β βββ config.php β βββ connect.php β βββ color.php β βββ relay.php βββ /includes β βββ functions.php βββ index.php βββ /src β βββ main.ino βββ βββ settings.h ``` ### π Flashing Process 1. In Arduino IDE: - Tools > Board > ESP32 Dev Module - Flash Mode: "QIO" - Flash Size: "4MB (32Mb)" - Partition Scheme: "Default 4MB" 2. Custom settings: ```cpp #define WIFI_SSID "YourSSID" #define WIFI_PASS "YourPassword" #define OWM_API_KEY "YourAPIKey" ``` ## ποΈ System Features ### π‘ LED Control System - **PWM Specifications**: - 8-bit resolution (0-255) - 5kHz PWM frequency - **Control**: - POT1 for red LED adjustment - POT2 for green LED adjustment ### β±οΈ Timing System - Turkey/Istanbul timezone (GMT+3) - Relay activates after 19:00 based on HC-SR04 data: - Person in room: ON - Person leaves: OFF ### π€οΈ Weather Integration - Ankara weather (OpenWeatherMap API): ```http GET https://api.openweathermap.org/data/2.5/weather?q=Ankara,TR&appid=YOUR_API_KEY&units=metric&lang=en ``` - BTN3 dance mode: LEDs synchronize based on weather conditions. ## π₯οΈ User Interface ### πΊ OLED Menu Structure ```mermaid graph TD; A[Main Menu] --> B[LED Values]; A --> C[Relay Status]; A --> D[MOSFET Status]; B --> B1[Red: 0-255]; B --> B2[Green: 0-255]; C --> C1[ON/OFF]; D --> D1[PWM Setting]; D --> D2[ON/OFF]; ``` ### πΉοΈ Button Controls | Button | Single Click | Double Click | Usage | |--------|------------------|---------------------|--------------------------| | BTN1 | Menu down | Relay status | POT1 value adjustment | | BTN2 | Menu up | MOSFET status | POT1 value adjustment | | BTN3 | Confirm selection | Dance mode | Toggle operations | ### π Web Interface - **Endpoints**: ``` / # Homepage /relay/on # Relay on /relay/off # Relay off ``` ## π§ Troubleshooting - Ultimate Guide ### π¨ Common Issues 1. **LEDs not lighting**: - Check MOSFET gate resistor (10K-100Ξ©) - Verify 12V power supply adequacy - Reduce PWM frequency (try 500Hz) 2. **HC-SR04 incorrect measurements**: ```cpp // Correct settings: #define TRIG_PULSE 10 // 10ΞΌs trigger pulse #define MAX_DISTANCE 400 // Maximum 4m ``` 3. **WiFi connection issues**: - Use `WiFi.mode(WIFI_STA);` - Channel setting: ```cpp WiFi.begin(ssid, password, 6); // Channel 6 ``` ### π Test Commands (Serial Monitor) ```bash # System info > SYSTEM INFO # LED test > LED TEST RED 255 # Relay test > RELAY TOGGLE # Sensor test > SENSOR READ ``` ## π Advanced Settings ### βοΈ EEPROM Configuration | Address | Data | Size | |---------|------------|---------| | 0x00 | WiFi SSID | 32 byte | | 0x20 | WiFi Pass | 64 byte | | 0x60 | LED Settings | 16 byte | | 0x70 | Timing | 32 byte | ## π License - **License**: CERN-OHL-S-2.0 ## π€ Our Sponsors
π Official Site | βοΈ Support | πΌ LinkedIn
Elecrow's engineering team reviewing our project requirements
π Official Website | βοΈ Support | πΌ LinkedIn
Design stages of our ESP32-based casing using Rhino 3D
Place this badge on your project enclosures, documentation, or web dashboard