WLED Animated Staircase Wipe

Published 22nd Mar 2025 · 17 min read · #electronics#wled#led#esp32#ws2812b

Introduction

In my last post, I talked about wanting to learn more about electronics but not having a good project to learn from. After the success of the smart garage door opener, I was looking for another project to do that would help me to level up when I came across someone who had added LED light strips to their staircase. PERFECT. This project had it all - soldering, embedded programming, and a final product that looks cool as hell.

My idea for writing all this out is that when I was first reading up on how to put all this together, I found it a little bit tricky finding a good resource to explained all the new terms and concepts simply. My hope is that while this probably won’t (and shouldn’t be treated as) as authoritative and conclusive source for info on this type of project, this post will be a good place to start for someone in the same position I was in.

Dive in with me as I learn all about addressable LED strips and WLED.

Planning is fun!

Now that I had a goal in mind, I needed to figure out how to actually do it. The video I saw was using an microcontroller called an ESP8266 and something called WLED. They triggered the strip using 2 independent motion sensors, and played a wipe animation so that the light would follow them as they walked up or down the stairs. Off to google I went to learn all about these new concepts.

After some lazy googling and youtube watching, I’d worked out that:

  • WS2812B LED strips are addressable LED strips that can be controlled by a microcontroller
  • ESP8266 or the newer big brother ESP32 are microcontrollers that can be programmed to control the LED strips
  • WLED is an open-source project that allows you to control the LED strips over wifi which runs on the microcontroller.

Putting it all together, the LED strip is connected to the ESP microcontroller which is running WLED. This allows you to control the LED strip over wifi and powers the cool effects that you see in the video, such as the wipe.

So at minimum we would need to acquire an LED strip and an ESP that we can flash with WLED. Additionally, we would need a power supply to power both the strip and the esp, some sort of motion sensors and soldering materials to connect everything together.

In the video, the person who posted it used 2 separate battery powered wireless motion sensors that were not connected to the controller, and triggered the effect using something external. I thought this would be a bit annoying, since you would have to charge the motion senors every so often, as well as having the extra hassle of setting up an external automation to trigger the strip. I thought it would be simpler to combine the two and have the motion sensors connected directly to the controller. So I would need to get some sort of motion sensor and figure out how to trigger the strip using them.

To be honest, at this point I was still a little hazy about the details, but I figured the best way to learn would be to just start and figure it out as I went. Worst case scenario, I fry a few components. With how cheap most of this stuff is, I reckoned it would be worth the risk.

So I went ahead and ordered everything I thought I would need.

Materials breakdown

Because there is quite a bit of stuff to go through (and I don’t think anyone cares about the journey of how I landed on these), I’ll break it down into sections what I eventually decided to go with for each category.

LED Strip

The most common strip beginners use for LED strip projects when starting out is the ubiquitous 5v WS2812B addressable LED strip. However, after doing some reading it was not what I landed on for this project in the end. Skip to the end of the section if you don’t care about the details.

The WS2812B is 5v, or 5 volts for you non-nerds. This is a pretty common hobby electronics voltage, and is very safe to work with - it’s almost impossible to give yourself a shock at 5v. USB power banks and chargers are all 5v, so it’s easy to find power supplies for them (ignoring the current requirements). The trouble is, 5v is almost too safe.

To run the length of my stairs, I would need a strip around 5m long. They make 5m strips in a range of voltages, so that is no problem, HOWEVER, the 5v strip does have one big limitation.

Voltage drop.

To put it simply, the voltage carried by the strip drops due to resistance in the wires that make it up and because of the 5v nature of the strip, the voltage at one end is noticeably lower than the other. The lower voltage causes the LED colors at the end of the strip to fade towards red compared to the start of the strip, which looks a bit bad when you can see the entire strip at once.

The other problem is that you need a beefier power supply to power the strip. Since power = voltage * current, for a given wattage at 5v, the current required is higher than at 12v or 24v. This isn’t a problem per se, but it means you need to use thicker cables to carry the power or you may have issues with the wires heating up, which worst case could cause a fire if you aren’t careful.

There are various ways around this problem, but they involved a fair bit more wiring for this length of strip, as well as increasing the size of the power supply needed. So rather than mess around with all that, it is simpler to get a higher voltage strip. Since the voltage is higher, there is a smaller drop due to the resistance, and fewer wires needed. This ofc presents a different problem for powering the controller, but more on that later.

After doing some research on various strips from the fantastic Quinled website, I decided on a 24v strip, which I think is a SK6812 COB strip. Using 24v means that I could use thinner wires to power the strip, and I wouldn’t have to worry about voltage drop as much. The only other downside was that the pixels on this strip are grouped into bundles of 3, so you lose a little bit of resolution. This wasn’t a problem for me, but something to be aware of.

What the heck is voltage drop?

Look, i’m not an expert at electricity, so take anything I say with a grain of salt. But put simply, every wire has resistance (with the unit Ohm - Ω) which causes the voltage to decrease over the length of the wire. So if you start with 5v, you will end up with less than 5 at the other end, and the longer the cable, the more the voltage drops and the less you end up with at the end. There is a formula to calculate the exact drop, but you can google that one yourself.

You can get around this at 5v by doing something called power injection, which is where you run a second (or third if you have a really long strip) power line to the end of the strip. This second cable will have lower resistance than the strip and so it will drop less voltage when connected to the other end of the strip. I didn’t want to do this because it would mean running even more wires, and I thought the tradeoffs of 24v were worth it.

Microcontroller

There are 2 main choices for microcontrollers that are commonly used with WLED - the ESP8266 and the ESP32. The ESP8266 is the older version of the ESPs, and is a little less powerful and has less memory. When comparing the prices on AliExpress, they were both pretty similar, around 6 bucks. So it made sense to just opt for the 32. They both take 5V power inputs, with the only difference being which GPIO pins are used for data.

What are GPIO pins?

These are what connect the microcontroller to the LED strip.

Power

Because the strip is 24v, we need a 24v power supply. You can get these in a range of different current outputs so you need to pick one that should provide enough current for the LED strip you want to power. Different strips draw different amounts of power depending on their length and how many LEDs are actually on at a given time. Quinled has a good article on calculating how much power a given strip will need. I went with a 3 amp one because that should be good enough to power the strip at 100% white brightness.

There is an added complication with going for 24v of power however, in that the esp only takes 5v inputs. The 24v power supply would fry that poor little fella like a chicken wing if connected directly.

Thankfully there is an easy solve in the form of little electronic components called buck converters that can help with this. They take a higher voltage and convert it to a lower voltage. So we just need to find one that can convert 24v to 5v, and we are good to go.

I found one called the MP1584 that seemed like it would work. Going back to my philosophy of, ‘this stuff is pretty cheap, so try and (hopefully don’t) fry’, 1 I went ahead and ordered it.

Relay

This is an optional component, but i’ll include it for completeness. The LED strips have a downside with their power usage in that when the strip is turned off in software, it is still actually on and consuming (a small amount of) power. I think it’s a fairly negligible amount, but we might as well try and do this properly while we’re here.

To fix this problem, we can use a relay. This is a small electromagnetic switch that allows you to toggle the power off via circuit. By connecting the power coming in to the LED strip through the relay, we can cut the power to the strip and reduce its draw down to zero. WLED even includes a handy relay control setting to do this automatically.

Motion sensors

There are 2 basic types of motion sensors that would work for what I wanted, passive infrared and time of flight sensors.

Passive Infrared (PIR) sensors are the most common type of motion sensor, and are what you would find in most home automation systems, or your standard home alarm system. They detect motion by sensing changes in infrared radiation, like the heat from a human body. They are cheap and easy to use, but they can be triggered by other heat sources, and have a wide detection area.

Time of flight (TOF) sensors are a little more advanced, and use a laser to detect motion through measuring how long it takes the beam to return a reading. They are more accurate and have a smaller detection area, but they are also more expensive and require more programming to use correctly.

Since I wanted to turn the lights on before someone reached the stairs, I opted for the PIR sensors to make use of their wider detection area. They are also cheaper and simpler to use, so it made sense.

Misc stuff

Wires, connectors, soldering iron, solder, heatshrink tubes, etc. I had most of this already, but I did need to get some connectors to connect the LED strip to the microcontroller. I went with JST connectors because they are small and easy to use.

For wires, I used 22 awg for data and low current connections, then 18 awg for the power connections to the LED strip. 18 awg is probably not strictly required, but I had it lying around.

I used a solderable breadboard to hold the ESP and connect everything to as it made it a little bit easier to work with. Not strictly required either.

The prototype

Once all the parts arrived, it was time to get building.

Microcontroller

I started by attaching the ESP32 to header pins, placing that in the breadboard and soldering the connections in place. Jokes, I didn’t do that because i’m an idiot who loves pain. I soldered the esp directly to the breadboard, making it very impractical to remove later on. Don’t do this, use header pins - it will save you a lot of pain later on.

Header pins

Header pins are little bits of plastic that fit between the breadboard and the microcontroller. While you can solder the microcontroller directly to the breadboard, it means that your microcontroller is stuck there forever, and if you ever accidentally fry it you will have a nightmare trying to remove it from the board. Using the pins means that if you do end up breaking something, you can easily remove the microcontroller and test it in isolation, or just replace it. No desoldering and cursing required.

After soldering in the ESP, I connected a female barrel jack to two WAGO 3 way splitter connectors on the positive and negative wires. Using these is a bit nicer than soldering as they look much neater than a solder joint, and you get the added bonus of making them much easier to remove later on if you need to. From there, I connected another wire to the connector, then soldered it to the buck converter, matching positive to positive and negative to negative. I measured the output of the converter using a multimeter to tune it down to the correct level. The buck converter I am using has a tiny screw that allows you to set the output voltage, so I had to adjust this to be below 5v for the esp. The esp comes with its own built in voltage regulator, so anything between 5 and 3.3v should be fine. Once happy with the voltage, I could solder the output of the buck converter to the left power rails of the breadboard, then connect the rails to the gnd and vin pins on the esp32. Because the esp32 has 5v inputs on the left, and 3.3v outputs on the right, I stuck with this pattern for the breadboard power rails and designated the left side as 5v and the right side as 3.3v. This way, I could use the 5v for the LED strip and the 3.3v for the PIR sensors.

Turning on the power to check everything yielded no magic smoke, and the esp booted up.

LED strip

Next up, the LED strip itself.

Because our power rails on the breadboard are 5v (and because its a bad idea to run any serious current through the breadboard), we need to power the strip directly from the power supply instead of using the rails on the breadboard.

The WAGO connectors I chose have more than one output, so I could take another wire from each of the positive and negative terminals and attach them directly to the strip. Soldering the power lines direct to the strip works, then we just need to connect a data line from the esp to the strip.

Another thing to pay attention to is the direction of the strip. Digital LED strips work because each small segment forwards the data signal on to the next segment in the strip, but this only happens in one direction. So if you solder your data line to the back end of the strip, nothing will work. They will have an arrow printed on them telling you which way the data flows, so as long as you follow this arrow you will be sweet.

PIR sensors

The last piece of the puzzle. The sensors I found on AliExpress are very ideal for this kind of project; they accept a range of voltages, including 3.3v. In order to detect when someone is at the top OR the bottom of the stairs, we need 2 sensors. This means we need to solder 2 sets of leads to the 3.3v side of the breadboard, then 2 different data pins.

Once the power wires were in place, I used the multimeter to check the output by touching the negative probe to the 3.3v side negative rail on the breadboard, and the positive probe to the output pin of the sensor. Waving my hand in front of it produced a nice little voltage spike, so I could tell everything seemed to be working.

WLED

Once the sensors were in place, it was time to flash the code to the esp. This is pretty straightforward and I won’t cover it here since the WLED documentation is pretty good. Once installed, we just needed to set the GPIO pins to match what we had chosen for the LED data pin and the sensor pins.

With that in place, we could test everything properly. WLED has options for PIR sensors built it, so we can test both of the sensors individually. Happily, it all seemed to be working.

Updating the software

At this point, I was pretty happy with the hardware side of thing, but I still needed to set up WLED to trigger when I walked up to either end of the staircase.

WLED doesn’t have this built in, but it has a pretty comprehensive addon system called usermods, where people have contributed custom code to modify the base software.

There are 2 main usermods that WLED provides for staircase lighting, neither of which did exactly what I was after:

  1. The Animated Staircase Wipe usermod - This gets you to divide your strip into segments, then turns one segment on at a time. This is really cool, but it’s designed to have one strip running along the base of each step, which wouldn’t have worked easily for me.
  2. The Stairway lighting usermod - This usermod turns the whole strip on or off with a wipe animation, which is exactly what I wanted except it is implemented without any sensor handling, so you need to toggle the animation on and off manually via http commands. You could do this via home assistant when combined with something like mqtt events for the PIR sensors, but that seemed needlessly complicated.

I decided to just combine the two usermods into a new one that I could use that would work without requiring an external trigger.

After a few days of messing around, I got something I was happy with and flashed it. There’s probably a nicer way to do it, but it gets the job done.

You can find the code for the usermod here. You’ll have to compile it yourself, but the instructions are detailed on the WLED homepage.

Software setup for night mode

With the new usermod running, all that remained to do was setting up some presets and automations.

I thought it would be cool to have the strip not be active at all during the day as well as turn red during ‘midnight’ hours (since red is supposedly better for keeping night vision).

WLED has a handy macro feature that allows you to activate presets based on the time of day. It can even track sunrise/sunset based on your geographical location. I have 3 of these macros configured to change the preset of the strip over the course of the day:

  • Day - Sunrise +30 minutes - Strip off
  • Evening - Sunset -30 minutes - Warm white
  • Night - 11pm to sunrise +30 minutes - Dim red

The day preset is actually ‘off’. So the strip is just set to black with 0 brightness. This means that during the day when there is no need for extra light, the strip doesn’t trigger at all from motion.

The evening preset is a nice warm white color, which provides plenty of light for someone walking towards then up/down the stairs.

The night preset is a dim red color. I used red because it preserves your night vision better than white light, so is a little bit more gentle if you need to get up in the middle of the night.

Using the macros, WLED will automatically rotate between the 3 presets based on the time of day without even needing to set it via homeassistant or some other automation software.

The final product

Conclusion

So there you have it, a completed staircase wipe LED strip.

Hopefully this post has given a decent overview of how to put together an LED strip WLED project, including motion sensors and relays.

Footnotes

  1. Popularly known as ‘YOLO’