WiFi Controlled RGB LED Strip With ESP8266

47K2833

Intro: WiFi Controlled RGB LED Strip With ESP8266

The idea is to create an LED lights that can be controlled from WiFi. I have some spare LED strip from Christmas lying around, so I am recycling this to ESP8266 which allow the LED to be controlled from WiFi.

ESP8266 can function as webserver, this will be used to create the Remote layout to control the LED Strip. The LED strip that I have is 12V, so I will need a 12 V power supply for this, otherwise if you have the 5V LED, you can power the LED strip from the same power source that power the ESP8266 circuit.

STEP 1: Gather All the Materials & Tools

For this you will need the following materials:

- 1 x ESP8266

- 3 x MOSFET IRF510

- RGB LED Strip

- Prototype board

- Connector Wire

- 12 V Power supply for LED Strip

- 5 V Power supply for the ESP8266

The following are the tools that you will need:

- Wire stripper

- Soldering Iron

- Multimeter (Handy tools for trouble shooting)

STEP 2: Connect the Circuit

Connect the circuit as per the diagram above. We need 3 MOSFET to power the 3 colours (RED, GREEN, BLUE) of the LED. Note that I am not using the individual addressable LED strip. For that you will need a different connection.

Using the 3 colours of the LED, we are able to create many more colours. For educational purposes, it is great to be able to teach the kids about the Primary colours, and the combination that made up the other colours.

Another thing to note is you will need to make sure that the GND of the 12 V power supply is connected to the GND of the 5V power supply. Another alternative is you can use the 12V power supply to power the 5V using the 5V regulator LM7805.

STEP 3: Configure the Code From Arduino Interface

You can download the code that I have used from my website in the following location. The code will need the following library to run.

- ESP8266WiFI

- ESP8266Webserver

- Arduino OTA

Once you load the code in the Arduino interface, there are a couple of things that you need to configure.

1. Change the following to point to your wifi ssid and password

/* Network settings */
const char* ssid = "yourWIFISSID"; // SSID - your WiFi's name const char* password = "yourwifipassword"; // Password

2. Change the IP address to reflect your Router subnet, and make sure that there is no devices in the same IP address.

IPAddress ip(192,168,1,111);  // static IP adress of device 
IPAddress gateway(192,168,1,1); // Gatway IPAddress subnet(255,255,255,0); // Network mask

3. Change the OTA (On the air update) password in the Setup section in around line 62.

// OTA code
ArduinoOTA.setHostname("LEDStrip"); ArduinoOTA.setPassword((const char *)"ledstripOTApassword"); ArduinoOTA.begin();

STEP 4: Upload the Code to ESP8266

Once you have configured the code to suit your WiFi setup, it is time to upload the code to the ESP8266. Make sure you select the correct port where your ESP8266 is attached to. In the example above, I have mine on /dev/cu.wchusbserial14750, this might be different from your PC or Mac.

Then Select Sketch->Upload.

Wait until the upload is finished. If all goes well the ESP8266 should connect to your WiFi router and have the IP address of 192.168.1.111. This might vary if you have change it in the previous step. Point your browser to that IP address, http://192.168.1.111, you should see the LED remote control as shown in the picture.

Click on the colour to change the colour of the LED according to your mood, and enjoy.

STEP 5: Future Upgrades


Now that you have a working WiFi controlled RGB LED strip, you can play around with the code to add more different combination of disco lights. Some of the suggestion of future upgrade include:

- Connecting the circuit to MQTT so that you can control it via internet

- Add motion detection circuit, to automatically turn the LED lights on for night light

- Add code for different flashing modes (Flash, Strobe, Fade, Smooth), these button at the moment is not functional.

- Change the light colour based on Music.

That's all, I hope you enjoy this post. And if you like this, you can vote for me in the Lighting contest. You can visit my website for other simple IoT projects.

You can also drop me a comment on what suggestion for the future upgrade that you would like to see, so that I can use this idea to post on the next instructables.

26 Comments

Hi, i want to create a similar solution. But I have a strip with RGB and white. Is it the same principle for the whites? so just alter the code with an extra colour?
Hmmm, that is interesting, so does your strip 5 wires (RGBW+-) The code will still works, but it will never light up the white. Combination the same intensity of RGB will produce white. Try it out and let me know how did you go.
yes, 5 wires, but it is a combination of rgb leds and white leds.
Look like the alternate LED is white. So have the option to mix white light with any colour as well. code accordingly.
Hi !
first , i can't find any code for this mode (FLASH, STROBE, FADE, SMOOTH)
second, when i press the "lightup" rainbow mode is turning ON , i can't change the any color until rainbow mode OFF and rainbow mode is not loop
.

please help to fix the incomplete code
Arduino: 1.8.16 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
ESP8266LEDStripWiFi:50:10: fatal error: Color.h: No such file or directory
50 | #include "Color.h"
| ^~~~~~~~~
compilation terminated.
exit status 1
Color.h: No such file or directory
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

this is the error that is displaying
DId you put the Color.h and Color.cpp inside the same folder as the source code ESP8266LEDStripWiFi.ino is located?
Putting your code behind a pay wall or even just requiring the user to put their details in your site is NOT the intention of instructables.
I too cannot download the code, even if I enter "Australia", the site wants to charge $10.

It would benefit the whole community massively if source code was kept in a proper source code repository like GitHub, and then more folk can appreciate your excellent (and free) Instructable.

Thanks
Hi Andrew,
You should be able to check out for free. Don't click on the paypal button.

Let me know if you still have any issue.
Sorry I’m new to this and interested in achieving this setup. How do i determine which MOSFET to get (I.e. how do I figure how much V and A will pass through the 3 gates)? Thanks!
Hi Busterho,
You can use N-Channel MOSFET IRF510, or any equivalent to this. As per the datasheet, Source to Drain current can be up to 5.6 Amps.
Multicoloured LED draws about 60mA per strip (20mA for Red, Green and Blue). So with the configuration above one MOSFET per colour, we can power about 280 LEDs, so lets be conservative, it can power up to 250 LEDs safely.
The source to drain voltage is 2.5V, which is enough voltage to power the LEDs.
I hope this answers your questions.
i didnt find the code is it paid??
Link redirect me to a paypal painment of $0.00… when I click on the pay button its shows the following warning:
"PayPal error (10525): An error (10525) occurred while processing your PayPal payment. Please contact the store owner for assistance."

Assistnace is needed...
Best regards...
Hi e_cuara,
Don't click on the "paypal" button, but instead, click on the "view cart" button and you can checkout from there without going through "paypal". Please let me know if you still having an issue.
hi dear
i can't download
Hi Mo1726,
What is the issue? Can you tell me more?
hi
i can't see download link

More Comments