Controlling RGB Lights From ESP32 Web Server

Introduction

In this project we are going to make a web server in ESP32 with an interactive web page to controls the color and brightness of a 12 volt RGB LED strip.

Video

Hardware Used

Components
Amazon.comamazon
Banggoodbanggood
AliExpressali express
Utsource
utsource
ESP32 or
cart icon
cart icon
cart icon
cart icon
cart icon
cart icon
cart icon
Bread Board
cart icon
cart icon
cart icon
cart icon
TIP120
cart icon
cart icon
cart icon
cart icon
10k Resistor
cart icon
cart icon
cart icon
cart icon
RGB LED Strip
cart icon
cart icon
cart icon

Choose the transistor according to the current consumption of the LED strip you are using

Software Needed

Arduino IDE arduino icondownload icon

Working Theory

A five-meter 12 volt RGB LED strip has been connected to an ESP32 NodeMCU board because the NodeMCU board cannot directly drive the LED strip we have used a NPN transistor(TIP120) to drive the LED strip from the NodeMCU. The transistors are connected to the PWM supported pins of the ESP32 development board each for red, green and blue lines of the LED strip.

In the coding part, we have created a web server with a small and lightweight web page that will load in the browser when we typed the IP address of our ESP32. The web page contains some buttons to turn on/off each color and there are also buttons for mixing the red, green, blue colors to make any color combination.

TIP120 Pinout Diagram

tip120 pin out

Circuit

  • Connect the R, G & B terminal of the LED strip to the collector of the transistor as shown.
  • Through a 10Kohm resistance connect the base of the transistors to the D25, D26 & D27 pins of the ESP32 NodeMCU.
  • All the grounds have to be connected together as shown, the ground of ESP32, the ground of transistors and ground of the 12v power supply used for the RGB LED strip.
  • You can power the NodeMCU board either through the USB cable or through the VIN terminal.

Code

Pros & Cons Of Current Implementation

Pros

  • Easy for beginners to understand the concept and code.
  • Only HTML and CSS used for webpage.

Cons

  • Webpage refresh every-time a button is pressed.

Whats On Next Update

  • Implementing java script for the web page to avoid full reload of the page when the buttons are clicked.
  • Storing the code for web page in PROGRAME memory instead of flash memory.
  • Soft coded WiFi credentials with WiFi manager.
  • Access point when no WiFi network is found.
  • So, subscribe to our mailing list to not to miss the update

You might also like…

To buy electronic components order from UTSOURCE

Leave a Reply