How to Make an Easy WiFi Controlled MOSFET RGB LED Strip Using an ESP8266

ESP8266 running WiFi controlled LEDs from benchtop powersupply
So red. Pure speed.

In this guide, you will learn how to use an ESP8266-based board to create a WiFi controlled LED strip. I will be using a Wemos Mini for this example, but any board with the ESP8266 microchip should work. For example, you might consider making a Wemos D1 LED strip.

There are many guides for making smart LED lighting on the internet. However, many are for expensive projects that suggest using individually controllable LEDs or separate LED controllers. I wanted something cheap.

When I originally tried this a year ago, I couldn’t get any of the guides that use the cheaper standard LED strips to work for me. The following guide shows how I finally got it to work.


Table of Contents


Materials needed

  • 1 ESP8266-based microcontroller
  • Standard LED strip
  • 3 N-channel MOSFETs
  • 12V power source
  • 3 330Ω / 3 10kΩ resistors (optional)
  • Voltage converter (optional)
  • Jumper wires

Notes on materials

Microcontroller

Wemos Mini
WiFi and a handful of pins for a couple of bucks

I used a Wemos Mini for my LED strip because I can get them for a couple of dollars where I live. Bigger boards do have some advantages (see voltage converter below).

You could also use an Arduino with a WiFi module or an ESP32 board, but they cost more. For a budget-friendly WiFi controlled LED strip, use something like the Mini.

LED strip

RGBV LED Strip
Cheap cheap cheap

There are many LED strips on the market. When I did an Amazon search, at first I thought the ones with the individually-controlled pixels and the “dumb” ones were about the same price, but then I noticed the length. Three feet of the smart LEDs cost roughly the same as sixteen feet of standard ones.

Also, pay attention to voltage. There are many LED strips designed to work on five volts, but twelve volts will draw less current and produce less heat.

Price also varies depending on the LED count per foot. There are some cheap strips out there that only have one LED per inch. They work well with a diffuser but may be lackluster in other applications.

MOSFET

MOSFET
The breadboard made this one a little swervy

The MOSFET you choose will depend on how long your LED strip is and how many amps it will draw. Some things to pay attention to are how much voltage is required to operate the gate, and how much current it can handle.

I used the 40T03GP for my 4-foot long strip. Is it appropriate? Probably not. Does it work? Yes.

Power supply

Again, this will depend on how long your strip is. I used one rated for two amps, far above what my setup draws.

Resistors

I originally made this project a year ago. I could only get it to work then by adding some resistors. In researching for this article, I found out that the resistors weren’t necessary. See the wiring diagram section for more details.

Voltage converter

Although some sources claim that you can power the Wemos Mini with twelve volts on Vin, there are just as many that say doing so will make it release the magic smoke. To be safe, use a voltage regulator. Beefier boards with a barrel jack, like the non-mini Wemos boards, should have no problem with twelve volts.


Wiring diagram(s) – How to drive MOSFET from microcontroller

I’m going to share two wiring diagrams in this guide. When I first tried this build a year ago, it would just not work. Eventually, I found this forum post, which resulted in the following design:

When I started writing this guide, I couldn’t remember what the resistors were for, so I posted my diagram to Stack Exchange where I was told I didn’t need any of the resistors at all. That resulted in this:

Wiriing diagramr of WiFi controlled LED strip
Diagram made with fritzing

*** Make sure of the pin-out of the transistor you use! In this diagram from left to right, it’s gate, drain, source.

I have no idea what happened last year, but the second setup works just the same as the first one.

I suggest you try it without the 10k resistors first. If it doesn’t work, then try it with them. I am no expert, but I have heard that the gate on some resistors get stuck when there is no signal being sent to them. The 10k resistor to ground keeps them open when no voltage is coming from the pin on the dev board.

The 330Ω resistors are just to protect the board. They’re not necessary but I recommend that you include them. I found that this setup works:

Wiring diagram for WiFi Controlled LED strip
Diagram made with fritzing

My build

You can just put everything on a breadboard for testing, but you might want to build something more rugged if the LED strip is going to be something you use every day. Here comes more evidence of me not being a professional (my soldering skills are not great).

I didn’t put heatsinks on my transistors because they weren’t getting hot under full load. That’s because my LED strip is pretty short. If you are drawing more current, you will definitely need to find a solution for heat dissipation.

WiFi RGB LED strip controller
Original design with 10k resistors going to ground
WiFi RGB LED controller
In hindsight, I probably should have put the WiFi antennae pointing up

Code

Once you have everything wired up, it’s time to test the lights. Make sure your IDE is set up for ESP8266 and upload a WiFi LED strip remote controller program. There are already many adequate sketches for RGB control out there including:

Although the design of the user controls of each of the above programs varies quite a bit, they are all interacting with the LED strip in the same way. By using the analogWrite() function, the dev board is controlling the LED strip by using pulse width modulation (PWM).

Using the MOSFETs and PWM, we will control how long each color of LED is on for any given amount of time. If we were to pass the value 1023 (the maximum available for the ESP8266 chip) to the analogWrite() function, that color of LED would be on 100% of the time. On the other hand, passing 0 would mean that color is never on, or entering 511 would mean it’s on about half of the time.

By Thewrightstuff – Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=72876123

The lights are turning on and off too fast for the human eye to see. But by controlling the average amount of time they are on, we are controlling their brightness. And through changing the brightness of one color compared to the brightness of the other colors, we can control the overall color put out by the WiFi controlled LED strip.


Conclusion

Controlling stuff remotely is fun, as we saw in my OBS Recording Sign project. In this guide, we made a WiFi LED strip that can be controlled over a local network. Wouldn’t it be great if you could control it when you are away from home, just like the Webduino?

So, in my next guide, I am going to show you how to control this LED strip when you are away from home, over the internet.

3 thoughts on “How to Make an Easy WiFi Controlled MOSFET RGB LED Strip Using an ESP8266”

  1. Pingback: Internet LED Strip with ESP8266, Python, and WordPress – Maker WS

Leave a Comment

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