Hambone Blues Jam

Home Decoration Tips
DIY WiFi RGB LED Lamp || ESP8266 & Blynk

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.5V. 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.3V. 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.3V. 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!

100 comments found

  1. Good job! The constant current drive circuits were a nice touch. Only thing I'd be concerned about would be the heat dissipation; that enclosure looks like it gets pretty hot inside

  2. Hiii… Sir I want to know that can i use a hand made air cored inductor instead of the shielded type actually I am unable to find it in the market… please help me… I am looking forward for your reply… please reply as soon as possible sir…

  3. Do you know instead using ESP8266 you use Particle Photon? It's okay if the light is simple just the bulb no more color but still using slider to control the brightness of the light.

  4. hi can you update app by including the time input widget , to schedule the on and off time , and update the coding !!!
    i am a civil engineer trying to learn electronics
    please help me

  5. I'm a rookie when it comes to arduino, but would it be any difficulties using an RGB-ring from Luxorparts or NeoPixel instead of the RGB's you're using?

  6. Hi sir is there having arduino cords creator because i dont know the cord this some kind of graphical thing

  7. Thanks for this great project!!!! …Can we use optocoupler instead of using op-amp and driver circuit in this project??

  8. led rgb light bulbs exist, 4€ where i live (also remote controlled and im pretty sure if you have a phone with a IR blaster that works too) combine that with a nice little 6€ light much easier and im sure its cheaper since the led itself is 6$ and the heatsink is like 10$ also to add in solder, all your time and work, honestly not worth it (not throwing hate, i love all the hard work and editing <3)

  9. Could I just swap the built in power supply with a power adapter and just use a barrel jack connector?

  10. I 've got a problem. When I upload the sketch into my esp8266, arduino software says 'Done uploading.', but the board doesn't come online. Why?

  11. Im 2nd year electronic engineering student watching his videos from 1st year i barely understand his videos( not fully). I think its way too hard to understand Those who doesnt have some background electronic knowledge

  12. I hate the fact that you have to pay to add more stuff to your blynk app, that is why I switched to Android Studio because you have full control of your app. Tbh, the creator of blynk probably used android studio to create the app.

  13. Great video! I was wondering if it is possible to extend this circut a little bit to instead of only the RGB led also connect an high power White led with a higher voltage and current draw. I don't have any experience with electronics so I kind on need some help there. (Thanks)

  14. I would like you to use my code for the esp8266 with it you can controll the lamp with alexa and blynk at the same time. Also i have added a fade effect for color change so i would be much easier for the eyes. I'll be glad if you could do that.

  15. Hm… I don't think you need a mosfet driver at all and I actually believe the whole circuit can be much, much simpler. You only need a single opamp, mosfet and a shunt resistor.

    Mosfet drivers are used for SWITCHING operation of the mosfets, that is to make sure the mosfets stays in the linear region for as short of a time as possible for switching applications!!
    What a mosfet driver does is it buffers the current, so you can use a low current source (such as the opamp) to quickly charge the parasitic capacitance of the mosfet gate.

    Once the base of the mosfet has been charged, it doesn't need any current at all, it's fine to just plug the output of the opamp into it directly.

    For a linear application (that is, when the mosfet is used in the linear region as "variable resistor" as opposed to "on-off switch"), you gain nothing by using a driver. In fact, it adds to the complexity of the project and hinders the behavior. The oscillations you see around the setpoint value are most likely due to the high nonlinearity of the mosfet driver.

  16. you could select node mcu instead of esp8266 in the blynk app, and when setting up the sliders you could turn off "send on release".

  17. I know that this Video is old but has anyone a clue HOW TO CALCULATE THE SHUNT RESISTORS? I want to know because i want to build it with a 30W RGB LED instead of a 10W one.

  18. Hey I have a big project (project smarter home) with a smart home product but I need people who can help me.

    Do you know how you can make your own program for on the smart gadget.

    For more information about the smart light pleas Join this discord.

    https://discord.gg/2SBFfk5

  19. Instead of a relatively larger inductor, why not add a small capacitor or two to the 11 gain amp, such that it acts similarly to pid and reduce the fast voltage swings and therefore reduces the interference? I'm still learning so let me know if I'm just way off on this idea.

  20. hello everyone, great project I am willing to build it.
    but I would like to ask, is it possible to buy the led driver circuit instead of having to solder it ?

  21. Hi, great video as always! I just have a question regarding the theory of the voltage smoothing circuit. At 6:28, why do you use a resistor AND a capacitor to smooth out the output? I thought smoothing out voltage was the entire purpose of a capacitor? What purpose does the resistor serve?

    Thanks!

  22. I am studying electrical engineering in germany.
    Electronics where my least favorite part of my studies.
    However i came to your videos for an assignement and got absolutely hooked.
    It's absolutely amazing how you make your own circuits for the projects you want to accomplish and you are a great inspiration for me.
    Now i can see the connections to the calculations and schematics we learned and how to use them in real life.
    Thank you so much.

  23. I've been thinking about making something like this instead of paying for the Philips Hue version. Is this bright enough to partially light up a wall?

  24. Ich hab mir auch ein esp8266 gekauft und überhaupt nicht kapiert wie ich das ding ins Internet bekomme, dank deinem Video hab ich es endlich hin bekommen,vielen dank, like und Abbo hab ich natürlich da gelassen.

  25. Wowowoowow ! This is soo cool, after watching this I ordered an ESP8266 board for myself. I will post picture once I make a project with it

  26. Übrigens, es gibt von Diamex eine 10Watt WS2812B und von Ikea 2 so Lampen in verschiedenen Größen die vorn eine Milchglasscheibe haben. Das dürfte dann alles ein wenig einfacher machen.

  27. When I come to visit earth later next year I will be coming to take your brain.
    My apologies for any inconveniences this may cause.

  28. Sometimes, i would like to know, how long it took or will take to build it up, which skills are User and what the average cost was….

Leave comment

Your email address will not be published. Required fields are marked with *.