DIY WiFi RGB LED Lamp || ESP8266 & Blynk

In this video I will show you step-by-step how to create this rather modern looking spherical RGB LED lamp.

Its brown 3D-printed enclosure in combination with the milky white acrylic glass gives it a simple yet in my opinion intriguing look that should fit everywhere in your living space.

The insides of the lamp are a bit more complex though, since they consist of a 10 watt RGB LED year whoop suitable heatsink, a 12V 1A power supply, and finally a three channel constant current driver circuit that is controlled by the ESP8266 microcontroller.

Due to its Wi-Fi capabilities the lamp can thus be controlled by a smartphone to increase/decrease the brightness of the red, green, and blue light in order to create any color you could think of.

So without wasting any more time, let's get started with the project.

First off, let's have a look at the ESP8266 and find a way to control it easily.

For that I visited the App Store and downloaded an application called Blynk.

After opening it and creating a new account, I start a new project called ESP8266 LED lamp whose target device should obviously be ESP8266 and the connection type is through Wi-Fi.

As soon as I click Create, the app sent an authentication token to my email address, which we will need in a second.

Beforehand we can add three vertical sliders to the project screen though which we can configure to send out a 10-bit PWM signal on the GPI0 pins 0, 15 and 1.

And while we're at it, we can also change the color of the sliders to red, green, and blue.

Now after clicking the start button we can utilize the sliders without a problem, but obviously our target device is not online yet.

For that I connected my ESP8266 to a computer, started the Arduino software and opened its preferences in order to include this URL which allows me to download and install the ESP8266 board through the board manager.

Then I went into the board selection and chose the NodeMCU 1.

0 since that is apparently the development board I'm working with.

Last but not least I installed the Blynk library through the library manager, opened the newly added example sketch called NodeMCU under Boards_WiFi, typed in my network name and password As well as the authentication token I received earlier and clicked on Upload.

Once the data transfer was complete.

I hooked up a jumper wire to D3, D8 and TX of the board and connected them all to separate oscilloscope probe.

And if you're wondering why exactly those pins, then you should know that they represent the GPIO 0, 15 and 1 we utilized earlier in the app Anyway, after restarting the Blynk project we cannot only see that the device is now online, but also that by varying the value of the sliders we create a PWM signal of a variable duty cycle on the three GPIO pins.

A value of 0 represents a duty cycle of 0% while the maximum value of 1023 represents a duty cycle of 100%.

And since we can now control the microcontroller through Wi-Fi with our smartphone.

It was time to move on to the LED part of the project The 10W RGB LEDs that I got have one anode and three cathodes.

That means I have to grab a positive voltage of 6 to 12V depending on the color to the anode and the ground potential to one of the three cathodes corresponding to the color I want to light up.

But of course we cannot illuminate a high power LED like this without a proper heat sink.

For that I got myself those 35 x 35 x10 mm aluminum heat sinks to whose adhesive tape I simply pushed on the LED firmly.

This way even while illuminating all three colors the LED stays cool enough, which guarantees a long lifespan.

Now as I demonstrated earlier, we could simply set a constant voltage on the lab bench power supply and power our LED like this.

Dimming would then be possible by lowering or increasing the voltage.

An equivalent constant voltage dimming circuits for our ESP8266 Would look something like this in theory and like this on a breadboard.

By increasing or decreasing the duty cycle of the PWM signal the LED would stay on longer or shorter and thus achieve the same dimming effects.

But even though this method is possible and often used, it is not the best way to drive high-power LEDs.

As an example let's set the apply voltage for the red LEDs to a value of 6.


This way the maximum LED current of 300mA flows.

At first there seems to be no problem, but as time passes on the LED heats up a bits and the forward voltage of it drops, which means, since we use a constant voltage, the current will increase.

That however means that the light gets slightly brighter.

But more importantly this method can surpass the maximum current flow and thus shorten the lifespan of the LED.

So in conclusion we don't want a constant voltage driver, but instead a constant current driver with a maximum current flow of 300mA.

Here's the circuits that I came up with.

At the top left side we got an RC low-pass filter, which connects to the GPIO pin of the ESP8266.

Its function is to turn the PWM signal into a proper DC voltage between zero and 3.


By utilizing a 5.

1kΩ resistor and a 220nF capacitor, we can see that the conversion does kind of work, but the output is not smooth enough yet for the rest of the circuit.

To fix that I simply added one line to the Arduino code and uploaded it once again to the board.

Now the PWM frequency is around 20kHz instead of the 1kHz beforehand and the thus the filter works a lot better and creates a precise and dynamic voltage between zero and 3.


And in order to understand the rest of the circuit, let's assume we set a voltage of 1 volt at the non-inverting inputs of the first op-amp.

Since the voltage at the inverting input is zero volts because there's no voltage drop across the 1Ω resistor, the output of the comparator gets pulled high.

This high voltage activates the output of the MOSFET driver, and thus turns on the MOSFETs Since the MOSFET now acts as a closed switch, current can flow through the LED and the 1Ω resistor.

But as soon as 91mA fell through the resistor There's a voltage drop of 91 millivolts across it which of the amplifying with the non-inverting op-amp configuration with the gain of 11 equals a voltage of 1 volt which is now applied to the inverting input of the comparator we talked about earlier.

Once the current rises more, the voltage at the inverting input is higher than on the other input, which means the output of the comparator gets pulled low which tells the MOSFET driver to turn off the MOSFETs.

That however decreases the current and as soon as the voltage at the inverting input is once again lower than 1V, this switching madness starts from the beginning and thus oscillates around a constant current of 91mA.

And if we increase the reference voltage to 3.

3V this circuit spits out a maximum constant current of 300mA.

Now with the theory out of the way, I created the described circuit with proper components on a breadboard, powered it up and notice that it only works partly As you can see we can control the brightness of the LED but apparently with a slight offset of the constant current.

The problem is that due to the fast current rises our reference voltage from the ESP8266 gets distorted.

So to slow it all down a bit, I added a 10μH inductor in combination with a flyback diode in series to the LED which pretty much solved the problem completely.

Now we can set a constant current between 25 and around 300mA.

And as you can see the current value stays constant no matter how much the LED heats up But one remaining problem was that the LED can never be turned off completely with my design so to fix that I added a second MOSFETs between the 1Ω resistor and ground, as well as a power button to the app which turns on/off GPIO pin 4 and connected this pin to a separate MOSFET driver, which thus turns on/off the MOSFET and therefore all the constant current drivers.

And with that being done, I got rid of my breadboard build, gathered all the components for three of those constant current drivers and created the finals schematic of the circuit.

But before soldering the components to a perf board with copper dots, I designed the enclosure for the lamp with 123D Design, and printed it with my Delta 3D printer.

While the result of the 3d printing was certainly not perfect, it was definitely good enough for me.

So I brought in a piece of milky white acrylic glass with a thickness of around 2mm, Created a smaller piece of its and secured it firmly in my CNC.

With it I created a precise circle with a diameter of 12cm but then again you can also use a handsaw for the job since the cap of the lamp enclosure will cover up all rough edges.

And with that being done, the enclosure was complete, and I could use it to position my power supply and LED inside in order to see how much space I got left for the controller circuit.

With those reference values in mind, I created a suitable piece of perfboard and started soldering all the components onto its and to one and other.

And if you want to create something similar, you can of course find the schematic and more information about this project as always in the video description.

Once I was close to finishing the circuit however, I know this that I was running out of space on the perfboard.

So I connected the inductors with flyback diodes right next to the LED.

And after inserting all the ICs, I did a final successful test, drilled a 6mm hole into the enclosure for the mains power wire, wired up all the components to one and other and secured them inside the enclosure with hot glue.

And as soon as the acrylic glass and the cap was in place, this project was finally complete, and turned out pretty awesome.

I hope you enjoyed watching this video.

If so don't forget to like, share and subscribe, consider supporting me through Patreon to keep such videos coming, stay creative and I'll see you next time!.

Leave a Reply