The ESP32 WiFi RGB Controller teaches advanced techniques for creating wireless IoT applications with real-time hardware control using web interfaces and hardware PWM signals on microcontroller platforms.
This project enables wireless control of an RGB LED through a modern web-based interface accessible from phones or computers on the same WiFi network. Users adjust independent red, green, and blue channel sliders in real-time to create any color while viewing live HEX color values and animated color previews.
When you run the project, the ESP32 connects to an existing WiFi network and hosts a responsive web server with an interactive color control panel. The web interface sends color commands to the ESP32 which converts them to PWM signals controlling the RGB LED brightness across all color channels.
Key Features: WiFi connectivity to existing networks without access point creation, HTML5 web interface with real-time responsiveness, independent PWM control of red green and blue channels with 8-bit precision, quick color preset buttons for common colors, live HEX color display and visual feedback, mobile-friendly responsive design adapting to any screen size, lightweight code optimized for microcontroller platforms.
To build this project, collect these specific items from your kit and ensure each component is in good working condition.
ESP32 Development Board x 1, RGB LED (common cathode) x 1, 220 Ohm Resistors x 3, Breadboard x 1, Jumper Wires x 4, USB Cable x 1.
Connect the ESP32 GND ground pin directly to the negative rail of your breadboard to establish a shared ground connection for your entire circuit and all connected electronic components throughout the system.
Position the RGB LED carefully on your breadboard ensuring proper spacing from other components for convenient access and safe wiring. The longest pin of the RGB LED is the common cathode which connects to ground through a resistor path.
Insert a current-limiting resistor between the RGB LED red pin and a new breadboard row then connect this row to ESP32 GPIO pin 26 for PWM red channel control.
Insert a current-limiting resistor between the RGB LED green pin and a separate breadboard row then connect this row to ESP32 GPIO Pin 13 for PWM green channel control.
Insert a current-limiting resistor between the RGB LED blue pin and another breadboard row then connect this row to ESP32 GPIO pin 14 for PWM blue channel control.
Connect the RGB LED common cathode (longest pin) through the final resistor to the breadboard ground rail completing the current return path for all color channels.
Double-check all resistor values for appropriate current limiting and verify all GPIO pin connections match the code configuration. Confirm LED polarity with the longest pin as common cathode and test connections with a multimeter before uploading code.
Important: RGB LEDs require current-limiting resistors on each channel to prevent damage. Use appropriate resistor values typically 220-330 ohms depending on LED brightness requirements and current availability from the ESP32.
Before uploading code to your ESP32, install the following software components, libraries, and drivers on your development system.
Arduino IDE : Download and install the latest version from the official Arduino website for code development, editing, and uploading to your microcontroller board.
ESP32 Board Package : Add the ESP32 board package to Arduino IDE by accessing Boards Manager and searching for ESP32 with proper version selection.
Wi-Fi Library : This library comes built-in with the ESP32 Board Package providing WiFi connection and network management capabilities for wireless networking.
Adafruit SSD1306 Library : Install this library for complete SSD1306 OLED display control, initialization, and I2C communication protocol implementation.
WebServer Library : This library comes built-in with the ESP32 Board Package enabling HTTP server functionality for hosting web interfaces on the microcontroller.
Verify Installation : Open Arduino IDE, select your ESP32 board from Tools menu, and confirm the COM port shows your connected microcontroller device.
The setup function configures ESP32 GPIO pins 26, 13, and 14 as PWM output pins with 8-bit resolution supporting values from 0 to 255. The ESP32 connects to a predefined WiFi network using stored credentials then initializes the WebServer listening for HTTP requests.
The PWM initialization configures each RGB channel with appropriate frequency and resolution for smooth color transitions without flickering. The initial LED state is set to a default color with all channels at zero brightness or a specific startup color.
The web server includes handler functions for processing GET requests from the web interface including the setRGB endpoint receiving color values. The handleRoot function serves the embedded HTML page containing the web interface while handleSetRGB processes color change requests.
The RGB values extracted from HTTP requests are validated for range between 0 and 255 then directly mapped to PWM duty cycle values. The analogWrite function sends the PWM signals to the GPIO pins controlling the LED brightness for each color channel.
The embedded HTML page includes JavaScript code handling slider input events and sending color updates to the ESP32 without page refreshes. The web interface displays live RGB values, HEX color codes, and provides quick preset buttons for common colors.
After uploading your code to the ESP32, open the Serial Monitor at 115200 baud and observe the connection status messages.
The RGB LED powers on displaying the initial color configuration while the ESP32 connects to WiFi and prints its local IP address. Copy the IP address from Serial Monitor and open it in a browser on any device connected to the same WiFi network.
The web interface displays interactive sliders for each RGB channel, a live color preview, HEX value display, and quick preset buttons. Adjusting any slider immediately changes the LED color in real-time with smooth PWM transitions and updated color values.
RGB LED Remains Off or One Color Channel Does Not Light :- Verify the RGB LED polarity with the longest pin as common cathode connected to ground. Check that current-limiting resistors are present on each color channel and measure resistance values with a multimeter. Test LED continuity and confirm GPIO pins 26, 13, and 14 have secure connections without loose wires.
ESP32 Fails to Connect to WiFi or No IP Address Appears :- Verify the WiFi network name and password in the code match your actual wireless network credentials exactly including capitalization. Check that your WiFi network is broadcasting and within range of the ESP32 board. Restart the ESP32 using the reset button and monitor Serial output for connection status updates.
Web Interface Page Does Not Load or Shows Connection Error :- Ensure both the ESP32 and your device are connected to the same Wi-Fi network without using separate networks. Verify the IP address copied from Serial Monitor is correct and try refreshing the browser page multiple times. Check that the WebServer is running by monitoring Serial output for HTTP request logs.
Color Sliders Move But LED Colors Do Not Change as Expected :- Confirm the PWM pins 26, 13, and 14 are correctly configured in the code and match your physical wiring connections. Check that the analogWrite function properly receives the RGB values from the HTTP requests. Verify resistor values are appropriate and not causing excessive voltage drop limiting LED brightness.
By finishing this project, you understand how to create wireless IoT applications combining WiFi connectivity with hardware PWM control for real-time remote device operation. You have learned techniques for hosting web servers on microcontrollers, designing responsive web interfaces, and translating user input into precise PWM signals.
You can apply WiFi and web server technologies to control various hardware devices remotely from anywhere on a network. You have experienced how microcontroller-based servers enable interactive applications while maintaining efficient resource usage on embedded platforms.
Explore more Lifetronix projects, improve your skills, and turn your ideas into real working prototypes.