This is one of the projects I have been working on recently. I have been trying to create customizable lighting for my 3D Printer's enclosure.
To do this, I wanted something that could be controlled remotely, and most importantly controlled programmatically.
After alot of googling I could only find really expensive(>$100) WiFi controllers with no public API's or wired Arduino based controllers.
That brought me to this project, I decided to make a WIFI enabled microcontroller powered LED strip controller.
An LED strip is just a bunch of SMD LED's wired together in parallel. I wanted an RGB strip so I chose one powered by the very widely used 5050 SMD LED's.
These LEDs have 4 Pins, one each for Red, Blue and Green colors and one pin for the cathode or anode depending on what type of LED's they are. The intensity of each color can be controlled by applying PWM signals to the corresponding pin.
The number of possible colors is limited by the resolution of the PWM of the microcontroller.
The one big problem surrounding the control of these LEDs is that they require 12 volts and relatively high amperage which the ordinary microcontroller cannot provide directly.
We rectify this issue by using MOSFET's. MOSFET's are special transistors that are used for switching electronic signals. The concept is similar to a Relay where when a voltage is applied to one pin, it allows current to flow through the other 2.
As I am by no means an expert I encourage you to read more about them on the Internet.
The last problem I faced was connectivity, I had 2 main options, BLE or WiFi. I ended up choosing Wifi as then I do not have to worry about being in the same room or even the same house to control the lighting.
In the end, I decided on the WeMos D1 Mini microcontroller as it is based on the ESP8266 chip which has built-in WiFi and is easy to program through the Arduino IDE.
- A WeMos D1 Mini, or any ESP8266 powered microcontroller.
- 3 Logic Level Mosfets per LED strip to be controlled(I used the IRLZ44N).
- 1 Switch(optional) and 1 220 ohm resistor per LED Strip to be controlled
- LED Strips(I used these common anode strips).
- 12V Power Supply
Wiring It Up
The wiring for this project looks much more complicated than it is. It involves connecting the Gate's of each MOSFET to a PWM capable pin of the microcontroller. The D1 Mini has 8 PWM capable pins so I can control 2 LED Strips independently.
I am using the remaining 2 pins as master switches to turn each LED strip on or off. As my LED strips are common anode, the source of each MOSFET is connected to Ground, and the drain to a color pin of the LED strip.
The +12V pins of each LED strip are connected to the 12V power supply and the ground of that is connected to the ground of the microcontroller.
Here is the Fritzing diagram for the connections:
And this is what my setup looks like:
The code for the microcontroller is essentially a webserver which has HTTP endpoints to control the LED strips and one to get the current status, I will not go through it here as I have documented it quite well and you can have a look at it at the Github Repository
To control the LED strips you should have a look at my Webserver Series. You can also add HTML pages to the webserver itself so that you do not need another device to contol it.
Here is a quick demo, I know the quality is terrible but it shows the basic capability of this project.
Here it is, you now have an LED Strip controller that can control 2 LED Strips all for less than $10. If you like this project and would like to get a PCB made you can see the full schematic and the PCB layout on Upverter.